3

Is there a way to make vim stuck in command mode with a : already typed in?

In that way, for instance:

  • I would type /fooEnter 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.

4 Answers4

7

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.

Keith Thompson
  • 254,901
  • 44
  • 429
  • 631
  • When you are in Ex mode, the "visual" window is not updated: you don't get highlighting or cursor movement which is what the OP is asking for. Hell, when you start in Ex mode there's no "visual" window. – romainl Dec 28 '12 at 20:10
  • @romainl: That wasn't clear (at least to me) from the question; the OP didn't specifically say he wanted to keep the visual display. But given the wording ("the cursor would go to the beginning of the next line ..."), you're probably right. I'll post a comment on the question asking for clarification. – Keith Thompson Dec 28 '12 at 20:25
  • Yes, I want visual display of the text.. Tried to `cmap :`, but of course this causes many problems, for instance, when inputing text with ':a` – VimQuestion Dec 28 '12 at 20:39
  • And I don't see the point of ex; It doesn't print syntax highlighted text. The Up key doesn't retype the last command. It doesn't show the visual window (although there is code implemented that does that). I would just stick with ed... – VimQuestion Dec 28 '12 at 20:46
  • `ex` is here because `vi` is a `vi`sual mode written for it. Ex is somehow core of Vi(m). – romainl Dec 28 '12 at 21:34
0

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

Shay
  • 1,368
  • 11
  • 17
0

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.

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
  • don't know exactly what to do with it.. writing directly on command or on my .vimrc does not seem to work.. – VimQuestion Dec 29 '12 at 02:06
  • Type it in Vim :-) After that, you can submit additional Ex commands (like `%s/e/E/g`), and should see its effects applied immediately in the current buffer. – Ingo Karkat Dec 29 '12 at 02:21
  • No, it doesn't work properly. For instance it doesn't jumps to lines when typing numbers, and it breaks everything when a wrong command is entered. – VimQuestion Dec 29 '12 at 14:21
  • It does, it just isn't visible. `:redraw!` instead of `:redraw` seems to fix it. As I said, it's just a demonstration that needs to be extended for real use. – Ingo Karkat Dec 30 '12 at 01:05
0

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.

Community
  • 1
  • 1