Move forward / backward one word in command mode?

Suppose I copy a file using the vim command mode and my cursor is at the end of the line.

:!cp path/to/original/file path/to/new/file 

Is there a way by which I can rescan a word, as I can, in a shell by typing Esc b ?

+4
source share
4 answers

You cannot use "Esc b" because obviously this will drop the command you are typing in. However, you can bind some keys to move.

A question that can already be answered here: Switching to Vim command mode

The easiest way is to simply add:

 cnoremap <Ca> <Home> cnoremap <Ce> <End> cnoremap <Cp> <Up> cnoremap <Cn> <Down> cnoremap <Cb> <Left> cnoremap <Cf> <Right> cnoremap <Mb> <S-Left> cnoremap <Mf> <S-Right> 

In your .vimrc

+5
source

A good vim function is ctrl-f . Entering ^f (or any other key is specified in the cedit option, with ctrl-f being the default) from command line mode has the same effect as entering q: from normal mode; it transfers the entire history of commands to the window and allows you to edit it as a buffer. Try :help cmdwin for more details.

+1
source

To enter and edit complex commands, you may like to work directly in the command prompt window, which is accessed by the q: normal mode command. See :h 20.5 and :hq: Or, if you are already in command mode, you can access the command line window using Cf

  • For example, in normal mode, enter q: to enter the command prompt window. (or enter Cf from command line mode.
  • You can move previous commands using standard movements, and you can edit them as usual.
  • When you want to execute the command that you just edited, press enter normally in this command window. The line where your cursor is located will be executed as a command in
    in which you were before opening a command prompt window.

Another possibility to consider is to edit / remove a command from another buffer. You can do this by pulling the desired text and inserting it into command mode by typing CR n , where n is the register you pulled at.

BTW: I like the comparisons provided by @rks. But if you do not have these mappings, you can use the commands out of the box. Find :h c_<S-Left> and :h c_<S-Right> and :h 20.1 .

+1
source

In vim command line mode, I just use the ctrl-left and ctrl-right arrows. The same thing works in bash - I did not know about the esc-b method.

No editing of the .vimrc file is required for this on my Ubuntu and Debian systems, but YMMV for others. Presumably, this is based on a standard configuration packaged for the OS

0
source

Source: https://habr.com/ru/post/1432912/


All Articles