3

I tried VIM and liked it but something stopped from using it: I had to type ESC to often, very often, something like each 5 seconds, and it was highly uncomfortable, so I stopped using it as a primary text editor (now I use emacs, nice for programmer as I am).

After my sad experience with VIM, I could get why some much intensive users love vim. But now I suppose that maybe, after a bigger training, the frequency of mode switching could decrease dramatically.

So, to verify this hypothesis, I am asking to you, old vim users, how frequently do you switch the mode?

1

9 Answers 9

8

I've been using vi/vim for nearly 30 years now, and I must say I've never found the mode switching an issue. And you don't think emacs has modes????

As to your question, I really couldn't say. I suppose my work pattern is:

  • open a file
  • move around in command mode until I find the right place
  • go into insert mode and write some text
  • go into command mode and savethe file
  • compile
  • in command mode (note probably NOT in insert mode) fix syntax errors
  • repeat as needed

So I tend to do reasonable sized blocks of work in each mode. It's not like I'm typing a character, switching to command, issuing a command, going to insert, typing another character.

1
  • 1
    emacs doesn't have modes, not in the sense of edit and command mode like vi. Aug 29, 2011 at 10:52
8

I can't tell you how often I switch modes, because it's almost second nature. It's not something I do consciously and I think most people agree on this. I did remap Caps Lock to Esc and it is much better, highly recommended.

Maybe the first week was like that as you paint it. I forced myself to use it for everything and it stopped being frustrating after a week. If you want to master it, I suggest the same. There are some good blog posts out there about setting up a comfortable environment (mainly about the tons of options configurable in .vimrc).

4
  • 3
    +1 "can't tell you how often...because it's almost second nature" Jun 14, 2011 at 13:38
  • I like to map jj -> ESC. Use the imap command. Jun 14, 2011 at 16:18
  • how is that useful? Jun 14, 2011 at 16:32
  • 1
    Scratch that, I tried and it's good :) Jun 23, 2011 at 10:23
2

I switch modes... always. Esc is the most popular key on my keyboard. Even in browser, typing this very message, I've hit Esc a couple of times, because it's already a habit. And I don't care! Smoking, for instance, would be a much worse habit.

However, if it really bothers you that much, I suggest you to see a shrink.

2

Most vim users would be switching between insert and visual mode all the time. Esc does suck to type a often. The day I started using Ctrl-c in place of Esc was the day my productivity increased tenfold. I think reaching for the Esc key a lot would mildly strain my left hand too...

3
  • Do you feel the same about the quite frequently uses "1" key, located within millimetres of ESC on my keyboard? Jun 14, 2011 at 12:30
  • @Neil: No, I don't. Esc is much further away from the asdf keys.
    – J.K.
    Jun 14, 2011 at 12:45
  • 1
    +1, for swapping Esc and Ctrl. I also liked switching Caps Lock with Ctrl, to make Ctrl easier to reach. Jun 14, 2011 at 13:39
1

It depends on what I am doing.

When I'm banging out new code I am in Insert mode most of the time.

When I'm editing code on the PC I make use of the arrow keys quite a lot so I can stay in insert mode quite a lot. Its a bad habit, but one that's hard to break.

When coding on my iPhone over SSH, I don't have the arrow keys so have to come out of Insert mode pretty often to navigate.

You get used to it. Even when coding in Visual Studio I find myself pressing escape every 10 seconds.

3
  • 2
    "When coding on my iPhone over SSH" I sure hope this is a last ditch effort and not a regular thing. I tried that a few times and could not manage to handle it.
    – Chris
    Jun 14, 2011 at 11:21
  • @Chris, yeah we've just had a baby so I have to take whatever chances to code that I can get! I very rarely find myself in front of a laptop in my spare time any more. Jun 14, 2011 at 11:39
  • I can totally understand that!
    – Chris
    Jun 14, 2011 at 13:41
1

The trick for me is to stay in command mode by default. Switch to insert/replace mode, enter text, switch straight back. If I leave the screen and come back, I'm in command mode; if I'm moving around the document, I'm in command mode. And so on.

That's not to say that I don't spend a fair amount of time in insert mode. It just means that while I'm there, I'm aware that I'm not in command mode and that I need to hit escape when I stop typing.

Why is this useful to you? What I quickly found is that I stop thinking of it as switching "modes" and started thinking of i/a/o (etc) as commands, which are followed by a string of characters and completed using ESC.

1

You can remap ESC to whatever key combination you want :

I have the following code in my .vimrc :

" remap ESC to ii to avoid leaving home row to leave insert mode
" i to enter insert mode, ii to leave
inoremap ii <Esc>
vnoremap ii <Esc>
snoremap ii <Esc>

When you are in Insert, Visual or Select mode you can use 'ii' instead of ESC.

As long as you are not editing a file with variables containing 'ii' it works fine.

If I remember correctly, when Vi was developed the ESC key was at the same place that the CAPS lock on current keyboards. It was much easier to reach. As a consequence some people are using CAPS lock to switch mode.

3
  • Good, I will test soon.
    – BenjaminB
    Aug 24, 2011 at 17:42
  • This is language-dependent; I've seen a lot of "ii"s in assorted Finnish names, and suspect it's reasonably common in the language, so it would be a pain when typing comments also. Aug 29, 2011 at 16:03
  • @David Thornley : I agree. Still it should be possible for any language to find a two key combination that should work. I have seen people mentioning jk as a replacement for escape. It works well too. ( And if all 2 keys combination are equally likely in your language of choice, you can use a 3 keys combination ). That being said I suppose that most people writing comments are usually writing them in English, since this is the lingua franca of our time, particularly for software.
    – Xavier T.
    Aug 29, 2011 at 16:20
0

I'm a new VIM user, and switch modes just about as often. Though, I hasn't remapped my keys, the default secondary Ctrl-[ works well for me.

However, what I find important, isn't that I need to switch modes often. It's simply that I rarely need to switch context. When I'm working, I'm working, and the mechanics doesn't really matter.

-2

to change the mode ,you can use ctrl-[ to replace the esc

It will work better! stick with it and you will done!

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