0
我创建了一个带有inputdialog的函数来有条件地移动行(tnx到Romainl)。
首先要做的是搜索,然后调用下面的代码。在不离开输入框的情况下从输入框验证输入
我的代码:
if !exists("char")
let char = "Move Lines with search match after/before?
\ \n
\ \nMove Line Backwards: Start input with: '?'
\ \nMove Line Forwards: Start input with: '/'
\ \n
\ \np.e.
\ \n?=\\s*$
\"
endif
let a = inputdialog(char)
if a == ""
return
endif
if matchstr(a, '^?') != ''
let minplus = '-'
elseif matchstr(a, '^/') != ''
let minplus = '+'
else
echo "wrong input: input does not start with '?' or '/'"
return
endif
我想改变的“返回”命令“返回到使用inputdialog”命令:
我想检查在输入框输入的输入立即不留输入框,这可能吗?
如果我改变了''中让return' = inputdialog(char)'输入不受控制我怎么回到上面代码中的第一个'let a = inputdialog(char)'?Vim没有Sub例程,不是吗? – Reman
Vim没有_goto_(幸运的),但是你可以在输入+验证周围放一个':while 1' ...':endwhile',并且当验证通过时只有':return'。 –
是的,这似乎是解决方案(使用'break'而不是'return')。唯一不起作用的是,当我按下输入对话框中的“取消”按钮或“”键时,它不会退出循环。 –
Reman