How to emulate Command-Return TextMate function in Vim

TextMate has a function in which pressing Command-Return at any point inserts a new line below the current line, placing the cursor at the beginning of a new line. It works a lot (exactly?), For example, by pressing "o" while in command mode in Vim.

Is there any way to emulate this TextMate function in insert mode in Vim? The same question is worded differently: can I make Cmd-Return in insert mode, which does “o” in command mode?

+7
vim textmate
source share
2 answers

Unverified, since I am not using a Mac, I tried with Ctrl-Return ( <C-CR> ). Ctrl-O executes one command in normal mode.

 :inoremap <D-CR> <CO>o 
+13
source share

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

 macmenu Window.Toggle\ Full\ Screen\ Mode key=<nop> inoremap <D-CR> <CO>o 
+2
source share

All Articles