将 vim 光标移动到函数后面
我同时使用 supertab 和 snipmate 插件。假设我正在使用 snipmate 创建 if 语句结构。在 if 语句中添加完语句后,如何快速将光标移动到 if 语句后面。例如:
if [ $a = "b" ]; then
bla;
fi
如果我的光标位于分号右侧并且我处于插入模式。将光标移动到“fi”之后的行最少可以执行多少次操作?如果我按 Tab,超级选项卡只会打开一个自动完成窗口。
谢谢
I'm using both the supertab and snipmate plugins. Let's say I'm using snipmate to create an if statement structure. Once I'm done adding statements inside the if-statement, how can I quickly move the cursor after the if-statement. For example:
if [ $a = "b" ]; then
bla;
fi
If my cursor is right on the semicolon and I'm in insert mode. What is the fewest number of actions I can take to move the cursor to the line after the 'fi'? If I press tab, supertab just open an autocomplete window.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您使用 snipMate,我建议您根据您的文件类型修改代码片段。例如,您给出的示例在我看来就像是 shell 脚本片段。在这种情况下,我会将 YOUR-VIM-CONFIGURATION-FOLDER/snippets/sh.snippets 修改为如下定义(在代码片段末尾添加额外的 TAB 变量):
然后 snipMate 将允许您使用TAB 和 SHIFT-TAB 键可在条件、语句和 if 块结尾之间来回移动。
If you are using snipMate I'd suggest modifying the snippet for your file type. For instance the example you give looks to me to be something like a shell script snippet. In that case then I'd modify YOUR-VIM-CONFIGURATION-FOLDER/snippets/sh.snippets to us a definition like the following (adding an additional TAB variable at the end of the snippet):
snipMate will then allow you to use the TAB and SHIFT-TAB keys to move back and forth between the condition, statements and end of the if block.
不确定插件(我不使用它们,但在常规 vim 中):
$ 符号在大多数情况下可能是多余的。
Non sure about the plugins (I don't use them, but in regular vim):
The $ sign might be superfluous most of the time.
只需按
Co o
Just press
C-o o
我会按 Esc o 在下一行启动插入模式。但也许您可以重新配置 snipmate,以便您可以按其他键而不是 tab 来完成代码片段?
如果您还没有映射它,向下箭头键也应该将光标移动到下一行。
I would press Esc o to start insert mode on the next line. But perhaps you could reconfigure snipmate so that you can press some other key instead of tab to finish the snippet?
If you haven't mapped it, the down arrow key should also move the cursor to the next line.