My main problem is that I don't realize which mode I am in each time I use vim.

Sometimes I forget to <ESC> into normal mode, hence pressing vim commands in insert mode. I have to waste time deleting those characters, but that's not the worst.

The worst is when I don't realize I am in command mode, and I do several characters of typing. Then I realize, gosh! I made a mess to my notes. I don't know what have I changed, and that's my nightmare. To undo them back to the correct state is hard because I don't know what the correct state is.

5 Answers 5


Try to make NORMAL your main mode. So after you did change/insert text goto normal mode right away. Then start all your typings and commands knowing you are in NORMAL mode.

And by default vim shows other than NORMAL modes in the bottom left corner:

enter image description here

  • i know it shows the "modes status " on status bar. but i don't have the habit of starring the status bar when i type. often i forget and was in wrong mode doing wrong cmd.. causing data being messed up. that's my main serious problem.
    – andrew_ysk
    Aug 27, 2020 at 17:47
  • 2
    I think you missed the point of the answer which is a very good recommendation in general. If you're not actively typing content you should be in normal mode. Yes, you might not be in the habit of doing this but the answer is to make it a habit. It's worth it. BTW, I guarantee you no Vim power user relies on those little indicators in the status bar so don't go down that path if you have your sights set high. Cheers.
    – B Layer
    Aug 30, 2020 at 0:43

There are several ways to distinct between modes. First of all - if not in normal mode then in lower left corner Vim will display name of the mode.

Another way to distinct between modes is to use cursor visual clues. For example one can set in .vimrc cursor in normal mode to block, in insert mode to vertical bar and replace to underline.

Detailed instructions can be found Change cursor shape in different modes

  • i have cursor line as horizontal line when in insert mode, still i don't aware of mode diff.. what more "block" . lol thx.
    – andrew_ysk
    Aug 27, 2020 at 18:26

If you know how long you used the wrong mode (let's say it's during 10 seconds), you can run :earlier 10s to go back in time regardless on how many changes you did.

These two plugins that can help you:

  • airline to have a colored bar showing your current mode (the color depends on the mode you are in).
  • undotree can help you to see what you changed (modified lines can be colored).

Edit : Another solution without plugin: add this in your ~/.vimrc

set cursorline
au InsertEnter * hi CursorLine ctermbg=52
au InsertLeave * hi CursorLine ctermbg=234

then, when you go to insert mode, the background line where your cursor is becomes red, and when you leave it, the line becomes grey. You can chose between 256 colors.

And if you prefer to do it for the column,

set nocursorcolumn
hi CursorColumn ctermbg=52
au InsertEnter * setlocal cursorline
au InsertLeave * setlocal nocursorcolumn

I don't do it the same way because I don't want to see the cursor column at all in normal mode (to avoid blinks on empty lines).

  • 1
    maybe the cursor shape isn't enough, and the status line is too far from your eyes (assuming you are looking at what you write). I added another solution in my post to get a colored cursor line when you are in insert mode. I personally use airline + the cursor… column (not line actually) changing its color. Aug 27, 2020 at 18:41

Setting 'showcmd' and 'showmode' can help with this, but <esc> also needs to be kind of a habit. That way you rarely type commands in insert mode (but it happens to all of us, not such a big deal. Occasionally I even hit <esc>ZZ in Word or some such! (Though I try not to use it much now...)

When you type commands in normal mode trying to insert text, just hit u until thinks look ok; there's nothing wrong with u!

P.S. Some people don't like the Escape key. If that's you, you might like to try Ctrl-[ instead. Whatever you do, do not get into the habit of using Ctrl-c as a poor man's escape; things will look fine until they don't.

  • No, it wont quit vim. But try and spot the difference between 5ii<Esc> and 5ii<C-c>
    – D. Ben Knoble
    Aug 27, 2020 at 18:12
  • @andrew_ysk right, but ctrl-c breaks the count (among other things)
    – D. Ben Knoble
    Aug 27, 2020 at 18:20

I don't know how to program, i just found this code from internet and twig it into workable .. there might got some useless code inside.

I have entered this into .vimrc It will make Insert mode status line to be red color "1" Replace mode into green color "2" Normal mode statusline white color.

function! InsertStatuslineColor(mode)
  if a:mode == 'i'
    hi statusline ctermfg=1
  elseif a:mode == 'r'
    hi statusline ctermfg=2
    hi statusline ctermfg=4

au InsertEnter * call InsertStatuslineColor(v:insertmode)
au InsertChange * call InsertStatuslineColor(v:insertmode)
au InsertLeave * hi statusline ctermfg=7

" default the statusline to green when entering Vim
hi statusline guibg=green

"status bar and "Color TERMinal" color code explaination:
"ctermfg is refering to statusbar color
"ctermbg is refering to words color of statusbar
"No.4 x No.0 (don't fit)
"0=No color or black color ?? 
"1=Red color
"2=Light green
"3=Dark Yellow
"4=Light blue
"6=Light Blue
"8=Cyan (dark grey)
"9=Dull Red
"10=some sort of pale blue greenish
"11=some sort of pale yellow
"14=blue greenish
"15=dull white
"16=dark black
"17=deep blue
"18=deep blue
"19=lighter deep blue
"20= blue of diff intensity
"21= blue of diff intensity
"22= dark green
"23= pale blue

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.