Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

3 Answers 3

up vote 8 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

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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