Insert mode default keys in vim

半腔热情 提交于 2021-01-28 16:47:45

问题


The following items are useful to me in editing text, and I was wondering if vim had something for this built out of the box (though I didn't see it on the https://vimhelp.org/index.txt.html#index.txt page), or I had to create mappings for it:

  • Forward-delete a character. This is X in normal mode.
  • Forward-delete all text to the right of the cursor on the line. This is the inverse of ctrl-u.

Are either of these mappings available? And if not, are there 'standard' mappings for this that are common (for example, how it might be done in another unix program).

Note that this is the keyboard I have -- there is only one delete key (which acts like a normal backspace key) and there is no backspace key:

Note: for forward-delete, I am currently mapping ctrl-d as:

"Ctrl-d to forward-delete when in insert or command mode
noremap! <C-d> <Delete>

However, this interferes with the tab in insert mode (which I don't use) and the help-options in command mode (which I do use!) so I may have to modify this later, or hopefully someone suggests a better solution.


回答1:


though I didn't see it on the https://vimhelp.org/index.txt.html#index.txt page

If you can't find it in the documentation, then it doesn't exist.

  • You can use fn+delete for "Forward-delete a character".

  • "Forward-delete all text to the right of the cursor on the line" is ctrl+k in MacOS, but Vim has its own use for that combo, :help i_ctrl-k so it is up to you to create a mapping for it.

    Something like:

    inoremap <key> <C-o>ld$
    


来源:https://stackoverflow.com/questions/62520603/insert-mode-default-keys-in-vim

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!