开发者

Readline's vi-mode in vim ex mode

开发者 https://www.devze.com 2022-12-09 16:34 出处:网络
Let\'s see if I can explain myself. I use vi-mode in bash, which is really great since I\'m used to Vi.

Let's see if I can explain myself.

I use vi-mode in bash, which is really great since I'm used to Vi.

When I'm inside vim and type : (to go to ex mode), since I'm used to the vi-mode from bash, I feel开发者_JAVA百科 the slowliness of having to use this mode like the "regular" way of using bash.

Question is: is there a way of using vim's ex-mode like bash's (or readline) vi-mode?


Not sure if I understand what you're trying to do, but it might be something like hitting q: in normal mode?


For users that use Vim or vi bindings almost everywhere, including on their shell command line, it really hurts when you leave that environment. If you're used to the vi bindings hyperdrive, going back to chords for skipping words and other manoeuvres is painful and slow. Operating systems also differ on their default bindings so Mac, for instance, supports option-arrow instead of control-arrow, adding to the pain.

But there is one place where this also happens where it's really upsetting: in Vim itself. When working in Vim and entering command mode using : the default readline editing returns. Chords all over again. How to fix this?

Simple: When in "normal" mode, that is, when navigating around, type q:

  • Vim will drop you at the bottom of a full Vim full screen editing experience, go for your life
  • Additionally the command history is available on previous lines in the buffer
  • You can yank and paste lines and edit the commands as much as you wish
  • To execute a command in "command" or "ex" mode just hit ENTER on the line you want to execute
  • Hitting enter on an empty line closes the buffer and does nothing
  • But this is just another buffer so you can quit it as usual with :q as well
  • Although ESC leaves the "ex" command line, ESC in the buffer will not leave the buffer, because it's an actual buffer

The q prefix is used to introduce macro recording, so the q: variant is perfectly mnemonic for entering recording of an "ex" command line.

Note that q: to enter the buffer editing mode is very similar to :q ! You may have hit that by accident sometimes ;-) Now you know how to get out of it!

Zigdon had this answer a long time ago, of course, but it's pretty darn sparse, but then again, so is the question. If Zigdon adds this extra detail to his answer I'll be happy to delete this answer so that there can be one good answer.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号