7

TextMate has a feature where pressing Command-Return at any point inserts a new line below the current line placing your cursor at the beginning of the new line. This works much (exactly?) like pressing 'o' while in command mode in Vim.

Is there a way to emulate this TextMate feature while in insert mode in Vim? The same question phrased differently: Can I make Cmd-Return in insert mode do what 'o' does in command mode?

dstrelau
  • 353
  • 1
  • 4
  • 5

2 Answers2

13

Untested, since I don't use a Mac, tried with Ctrl-Return (<C-CR>). Ctrl-O executes a single command in normal mode.

:inoremap <D-CR> <C-O>o
Jörn Horstmann
  • 33,639
  • 11
  • 75
  • 118
2

Updating this page to say that Jörn's answer worked for me, too, although it's worth noting that in Snow Leopard or higher, you have to disable the Full Screen menu option, because that's also mapped to Cmd-Enter by default. So here's what I have in my ~/.gvimrc:

macmenu Window.Toggle\ Full\ Screen\ Mode key=<nop>
inoremap <D-CR> <C-O>o
Elliot Winkler
  • 2,336
  • 20
  • 17