1
votes

Is there a way to remain in -- (insert) -- mode in VIM to enter multiple normal mode commands while using INSERT mode.

I understand we can enable -- (insert) -- mode by using ctrl+o, when we are using INSERT mode. But that will only allow us to enter only one normal mode command/shortcut. Then, it jumps back to basic INSERT mode.

We have shortcuts in INSERT mode to traverse through text, which can be found using :help ins-special-special command in VIM.

Yet, I would like to know if there is a way to use normal mode shortcuts multiple times in the insert mode without having to toggle on and off.

Much appreciate any information on this.

2
How is that different from pressing <esc>, doing multiple normal-mode commands, and then pressing i to start insert mode again? What are you trying to do? Some kind of evim mode?Matt
Hi Matt, what I'm trying to achieve is, using vim normal mode shortcuts for traversing through text, such as 'w', 'b', 'v' for visual mode and 'y' for copying, etc, in the Insert mode. When we use CTRL+O we can use any one of these commands but not more than that. So I'm curious if there's a way to remain in the --(insert)-- mode while we input text.hel
Is there a problem with using escape for you? Which could be unfortunately placed for some people's keyboards. Here is an article all about avoiding the <Esc> key, maybe you find inspiration there: vim.fandom.com/wiki/Avoid_the_escape_keySander Vanhove
@SanderVanhove Thanks for your article. I found another useful article through this (vim.fandom.com/wiki/…), which helps me map <Ctrl+O> instead of <Esc>.hel
That indeed looks interesting, if you find a solution that fits for you, you can answer your own question and accept it so others trying the same thing know what worked for you :)Sander Vanhove

2 Answers

3
votes

With regard to this question, I found below article and mappings much helpful for me.

This is an article on how to map "Ctrl+O" with a specific shortcut, to a custom command.

I was trying to find a shortcut to easily traverse code/text in insert-mode, using normal-mode commands or something similar. That way it reduces the effort of toggling back and forth normal and insert modes.

There are already some shortcuts defined specifically for insert mode and it can be found using :help ins-special-special command in vim.

Apart from that I also added below custom mappings to my ".vimrc" file for most common commands. This reduces the amount of typing and makes traversing much easier for me.

"navigate to the next word in the line
:imap <C-w> <C-o>w

"navigate back to the previous word
:imap <C-b> <C-o>b

"navigate to the end of each word
:imap <C-e> <C-o>e
1
votes

For those who are too lazy to read THE answer by hel.

Put <c-o> before your normal mode commands.

e.g
innoremap <c-t> <c-o>:<your command>