简体   繁体   English

保持vim始终处于命令行模式,并带有“:”

[英]Keep vim always in command line mode with a “:”

Is there a way to make vim stuck in command mode with a : already typed in? 有没有办法让vim卡在命令模式下:已输入?

In that way, for instance: 以这种方式,例如:

  • I would type /foo Enter and the cursor would go to the beginning of the next line containing foo . 我会输入/foo Enter ,光标将转到包含foo的下一行的开头。
  • Next, I would be still on command line mode with a : already typed in for the next command. 接下来,我将继续使用命令行模式:已经为下一个命令输入了内容。

Yes, start it in Ex mode, by invoking it either as ex or as vi -e . 是的,通过以exvi -e调用它,在Ex模式下启动它。

You can also enter Ex mode from the normal visual mode by typing Q (must be upper case). 您也可以通过键入Q(必须为大写)从正常的可视模式进入Ex模式。

You can return from Ex mode to normal visual mode by using the vi command. 您可以使用vi命令从Ex模式返回到正常的可视模式。

EDIT : This doesn't actually do what the OP is looking for. 编辑 :这实际上并没有做OP正在寻找的东西。 He wants to keep the visual display while keeping the cursor on the bottom command line. 他希望保持视觉显示,同时将光标保持在底部命令行。 That may not be possible. 这可能是不可能的。

No, but you can map ; 不,但你可以映射; to : to put yourself "closer" to command mode. to:让自己“更接近”命令模式。

I'll link to the Vim wiki instead of reposting identical information here. 我将链接到Vim wiki,而不是在此处重新发布相同的信息。

http://vim.wikia.com/wiki/Map_semicolon_to_colon http://vim.wikia.com/wiki/Map_semicolon_to_colon

You can build your own REPL , like this: 您可以构建自己的REPL ,如下所示:

:while 1 | execute input(':') | redraw | endwhile

This is just a conceptual demo; 这只是一个概念演示; you probably want to add a condition to quit this special mode. 你可能想添加一个条件退出这种特殊模式。 Also, commands like :append would need special handling to work properly. 此外,像:append这样的命令需要特殊处理才能正常工作。

As a last try, I could just initialize vim with -servername=FOO and then code a little script that would read from stdin and send remote-send to FOO whenever it detects(by parsing) a whole command was typed on stdin. 作为最后一次尝试,我可以使用-servername=FOO初始化vim,然后编写一个从stdin读取的小脚本,并在检测到(通过解析)在stdin上键入整个命令时将remote-send到FOO。

Then I would just use Vim and this other script side by side on different xterms/gnu screens. 然后我会在不同的xterms / gnu屏幕上并排使用Vim和其他脚本。

EDIT 编辑

OK, I will use this one. 好的,我会用这个。 This way I can even make :a command to enter vim's Insert mode and switch back to command mode when entering a line with a single . 这样我甚至可以做:a进入vim的插入模式:a命令,并在输入单行时切换回命令模式 . This way I would also have syntax highlight on the fly when inserting text (you know, vim has a very pretty visual display of the text, I'm just too used with ed's interface). 这样我在插入文本时也会有动态的语法高亮(你知道,vim有一个非常漂亮的文本视觉显示,我只是用于ed的界面)。 When I have so time I'll write this script and link it here. 当我有这么多时间我会写这个脚本并在这里链接它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM