Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In TextMate, when you're not at the end of a line and you want to enter a newline, you can type Cmd-Return.

Is there an equivalent for this in Vim, when you're in insert mode?

share|improve this question
up vote 9 down vote accepted

Would ESCo do? It's two keypresses, just like CmdReturn, and you don't have to hold them at the same time. The only drawback I can think of is that you temporarily leave insert mode.

share|improve this answer
    
Yes, that'll do just fine. I've seen people discuss mapping the Esc key in Vim to another key. I may look into that depending on pinkie fatigue. – Matthew Rankin Feb 24 '11 at 12:12

this should do the trick:

ctrlo o

share|improve this answer
    
Just to clarify for folks, it appears your recommend is Ctrl-o followed by just o. Works brilliantly, especially with my Caps Lock and Control keys swapped, so as to reduce pinkie fatigue. – Matthew Rankin Feb 24 '11 at 12:14
    
That's useful. I forgot Ctrl-O means "use normal mode for the next command! – JI Xiang Jul 4 at 15:47

I was used to Home/End getting me to the start and end of lines in Insert mode (from use in Windows and I think Linux), which Mac doesn't support. This is particularly annoying because when I'm using vim on a remote system, I also can't easily do it. After some painful trial and error, I came up with these .vimrc lines which do the same thing, but bound to Ctrl-A for the start of the line and Ctrl-D for the end of the line. (For some reason, Ctrl-E I guess is reserved or at least I couldn't figure a way to bind it.) Enjoy.

:imap <Char-1> <Char-15>:normal 0<Char-13>
:imap <Char-4> <Char-15>:normal $<Char-13>

There's a good chart here for the ASCII control character codes here for others as well:

http://www.physics.udel.edu/~watson/scen103/ascii.html

You can also do Ctrl-V + Ctrl- as well, but that doesn't paste as well to places like this.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .