How can I go to end of parenthesis/brackets/quotes without switching insert mode in Vim?

笑着哭i 提交于 2019-12-21 03:40:16

问题


I'm looking for a plugin that makes you get out of parenthesis/brackets/quotes/etc when you're inside them. I find it kind of hard having to ESC to command mode and typing A to get out of the parenthesis to go to the end of the line in Insert mode, is there a plugin that meets my needs?


回答1:


A plugin would be overkill. Add this mapping to your ~/.vimrc:

inoremap <C-e> <C-o>A
  • <C-o> is used to issue a normal mode command without leaving insert mode.
  • A, well… you know what it does.



回答2:


If you install the delimitMate plugin you can achieve this with the <S-e> or <C-g>g mapping.




回答3:


I'm use to using Tab to jump out of things like parenthesis, curly braces, etc., so I just made a simple mapping to Shift+Tab that simply moves the character 1 character to the right from INSERT mode. Here's my simple mapping that seems to be just fine for my purposes.

inoremap <S-Tab> <esc>la

Edit: It seems that delimitMate has this same mapping (Shift+Tab) for jumping over a closing delimiter. I think i'll just use that since I already use delimitMate.




回答4:


Since I use auto-pairs plugin, I have changed its default g:AutoPairsShortcutJump option

" Jump outside '"({
if !exists('g:AutoPairsShortcutJump')
  let g:AutoPairsShortcutJump = '<C-l>'
endif

Now it's easy not only to jump ouside pairs but also insert them.



来源:https://stackoverflow.com/questions/11037825/how-can-i-go-to-end-of-parenthesis-brackets-quotes-without-switching-insert-mode

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