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?
5 Answers
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.
-
I'm trying to use the commands from this page vim.wikia.com/wiki/… but I can't get them to work– rkrdoJun 14, 2012 at 17:20
-
8No need for a new mapping to go to the end of the line. On descent keyboards, just press
<end>
. Jun 14, 2012 at 17:26 -
1@sidyll, why not?
<C-a>
and<C-e>
already work in Vim's command line. Actually I'm so used to it that I didn't even think about<End>
. Stupid me.– romainlJun 14, 2012 at 17:43 -
1@romainl I know, that was just an infamous joke. About
<End>
, well I find it harder than<C-O>A
which in my opinion is yet harder than<esc>A
, but you might want to consider the fact that my esc is in place of my caps lock key.– sidyllJun 14, 2012 at 17:53 -
OK, I know it is not cool to chime in here and say 'THANKS', but I don't care. I have been searching for this my entire life. You have saved me from the forever annoying '<Esc>A'– lwmMar 2, 2013 at 2:20
If you install the delimitMate plugin you can achieve this with the <S-e>
or <C-g>g
mapping.
-
-
These days
<S-Tab>
will jump over a single closing delimiter or quote,<C-G>g
will jump over contiguous delimiters and/or quotes.– RavexinaMar 13, 2020 at 15:33
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.
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.
I remapped alt-h,j,k,l
to move the cursor without having to reach for the arrow keys. So it's just <m-l>
to jump over a single parenthesis. I also have <C-a>
and <C-e>
to go to the beginning and end of line, and <C-h>
and <C-l>
to jump a word left or right:
" alt-h,j,k,l move cursor left,down,up,right
inoremap <m-h> <Left>
inoremap <m-j> <Down>
inoremap <m-k> <Up>
inoremap <m-l> <Right>
" ^a and ^e move cursor to begin and end of line
inoremap <C-a> <C-o>I
inoremap <C-e> <C-o>A
" ^h and ^l move cursor 1 word left and right
inoremap <C-h> <C-o>b
inoremap <C-l> <Esc>ea