15 November 2007

More on vi, the Esc key, and Ctrl-[

Many thanks to everyone who sent in their thoughts on my post about vi and CTRL-[. Here's a quick summary of the comments I received on my blog and by IRC/email:

  • The vast majority of the people who commented use the Esc key.
  • Very few people use CTRL-[ (4 out of ~70).
  • Many people use keyboard layouts where CTRL-[ is difficult to type (French, German, Finnish, Swedish, Spanish, ...)
  • A few people have moved Esc elsewhere, such as the Caps Lock key (and here's how to do it, thanks Mark).
  • A better alternative is to use CTRL-C, which works on all keyboard layouts. It doesn't do the exact same thing as Esc/CTRL-[ because it doesn't check for abbreviations; dato notes in a comment that this can be remedied in Vim with inoremap <C-c> <Esc><Esc>.
  • Some people use the Esc key because it's hard to miss, being physically apart from other keys. Some people, on the other hand, complain that Esc is error-prone on laptops because it's too close to F1, or just awkwardly placed.
  • Everybody ♥ helix! (not to be confused with the helix wind turbine)
As a closing note, a followup question from reader Laurent C.: :wq, :x or ZZ? :)

14 comments:

toupeira said...

:x most of the time. But what I'd like to know is how many actually use the Vim7 tabs, I find them very awkward and prefer minibufexpl.vim.

jamessan said...

:wq here.

@toupeira:
The problem with Vim's tabs is that they don't follow the behavior that most people expect when they hear "tab". Vim uses them as another way to organize windows instead of as a way to organize buffers. People find them cumbersome because you can't setup a 1:1 relationship of buffers to tabs.

What people seem to want from tabs is just as easily solved by using "set hidden" and getting used to buffer navigation whether via a plugin like minibufexpl, bufexplorer, etc. or simply using <C-6>, :ls, :bn, :bp.

Julien Danjou said...

ZZ, definitively, so more leet it impresses people watching because nothing is printed on screen. :-)

toupeira said...

@jamessan: thanks for your comment, that's exactly what I meant but couldn't find the words for ;) I think what I really wanted to ask if anybody actually likes the tab behaviour.

I do already use "set hidden" and the other buffer commands, but I didn't know <C-6> (or ^^ actually) yet, thanks for mentioning it!

Anonymous said...

map F1 to Esc!

I don't know what they were thinking with that help shortcut anyway. As if vim users would need help!

curson said...

Definitely :wq is my favourite, but sometimes ZZ is way faster :D

Dedalus said...

:w often times while editing is in progress then when I'm finished with editing simply :q, my work being already saved previously with :w :)

Joachim Breitner said...

:x!

And thanks about the Ctrl-C-comment, I didn’t know about that! Here, Esc is close to F1 and Ctr-] is quite bad...

Meike said...

:wq

Learned about :x much later and somehow never got used to it

Hrw said...

:wq all the time. I also use ESC.

Jon Dowland said...

Some people at work use :wq! which makes me cringe.

bimone said...

I didn't know ZZ. I like it. But right now I'm used to :wq all the time, while I should :x or ZZ.

Are all of those vi compatible ?

I use Ctrl C a lot by the way.

And on the tab topic, I have too many buffer opened so :ls is a bit awkward. I use gvim for real coding.

For terminal lovers check-out cgdb for debugging.

Anonymous said...

ZZ here.

@bimone: ZZ is vi compatible.

dave noble said...

now that you point it out, ^[ is a lot more efficient (especially on the SGI keyboard I use where the esc key is located miles away from the main area)! Thanks for the tip!