Is there a way to jump to the next word when in the insert mode. Something similar to w
when in non-insert mode or Ctrl+Left or Ctrl+Right in windows?
Vim does have some keybindings to navigate in insert mode. Check :h ins-special-keys . ctrl-h : backspace, ctrl-w : delete word, ctrl-u : delete to beginning of line, alt-b : go back a word.
Esc + i to exit insert mode and enter it again, effectively going to the beginning of line.
Open a new or existing file with vim filename . Type i to switch into insert mode so that you can start editing the file. Enter or modify the text with your file. Once you're done, press the escape key Esc to get out of insert mode and back to command mode.
In insert mode, Ctrl-o escapes user to do one normal-mode command, and then return to the insert mode. The same effect can be achieved by <ESC> ing to normal mode, doing the single command and then entering back to insert mode. Ctrl-i is simply a <Tab> in insert mode.
There's a very useful table of insert mode motions at :h ins-special-special
.
<S-Left> cursor one word back (like "b" command)
<C-Left> cursor one word back (like "b" command)
<S-Right> cursor one word forward (like "w" command)
<C-Right> cursor one word forward (like "w" command)
You'll find that Shift-Left/Right and Ctrl-Left/Right will do the trick.
Ctrl/Shift with cursor keys isn't guaranteed to work flawlessly in all terminals, however. You can avoid any problems entirely by using a mapping. Here's one right on to the home row:
:inoremap <C-H> <C-\><C-O>b
:inoremap <C-L> <C-\><C-O>w
Now use CTRL-H
and CTRL-L
to move by word in insert mode.
However, please be aware that many Vimmers prefer not to move at all in insert mode. That's because once you have moved in insert mode, the .
command loses its utility, as does CTRL-A
and maybe some other commands.
For me, the Vim way of jumping to the next word in insert mode is <C-[>wi
and it's become completely automatic.
With <CTRL-O>
, you can execute one command without exiting insert mode.
So you can try <CTRL-O>w
, <CTRL-O>3w
, etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With