How can I map ctrl + enter
to go to new line from anywhere in the current line in vim ? I just want to do it for insert
mode. I tried
:set <C-<CR>> <Esc>o
but that doesn't seem to work.
For an insert mode mapping, you need :imap
; :set
is for setting Vim options. Ctrl + Enter is written as <C-CR>
; cp. :help key-notation
. Ergo:
:inoremap <C-CR> <Esc>o
Note that this key combination mostly only works in GVIM, as most terminals do not send different keycodes for Enter in combination with modifier keys. If you need a solution that also works in terminals, you need another key (combo), eg <Cg><CR>
.
On windows Terminal-App, CMD or Powershell the Ctrl+Enter
is getting translated to Ctrl+j
and so you can do:
:inoremap <C-j> <ESC>o
vim.keymap.set('i', '<C-j>', '<ESC>o')
The preferred way is to use the "Keyboard Manager" utility of PowerToys and target any app you want to remap it's keys , like:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.