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?
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With