简体   繁体   中英

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?

In that way, for instance:

  • I would type /foo Enter and the cursor would go to the beginning of the next line containing 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 .

You can also enter Ex mode from the normal visual mode by typing Q (must be upper case).

You can return from Ex mode to normal visual mode by using the vi command.

EDIT : This doesn't actually do what the OP is looking for. 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.

I'll link to the Vim wiki instead of reposting identical information here.

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

You can build your own REPL , like this:

: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.

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.

Then I would just use Vim and this other script side by side on different xterms/gnu screens.

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 . . 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). When I have so time I'll write this script and link it here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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