问题描述:

With the DelimitMate, it auto generates the closing parentheses. When I'm finished typing inside the parenthesis, what key strokes do I press to quickly go to the right of the closing parenthesis? (Right now I have to manually press ESC then 'a')

网友答案:

You can do a custom map. I guess you want to go to the right of the closing parenthesis while you're in insert mode. Just add to your .vimrc this mapping:

:inoremap <F8> <ESC>f)a  

In this way, while your in insert mode and you've finished to write inside the parenthesis, F8 will bring your cursor ad the right of the closing parenthesis. If you want you can change the mapped key, using another key instead of F8.

As Kent said in the comment a more general solution would be:

:inoremap <F8> <ESC>%%a  

Which will work for [ and { brackets.

网友答案:

The idea of these auto-closing plugins (like the original feature implementation found in IDEs like Eclipse) is that you just type the closing character to go over it. The plugin should detect this situation and instead of inserting the character jumps over the existing, auto-inserted one.

If that's not working for you, there are several plugin alternatives on offer. The Vim Tips Wiki has a list of them.

网友答案:

With delimitMate, Shift-tab will jump out of the current delimiter and Control-g g will get you out of nested delimiters. No need to remap anything.

网友答案:

You could try auto-pairs's Fly Mode

eg:

( hello| world )

press ) at |

( hello world )|

If jump incorrect, use <M-b> to do the back insert.

eg:

(hello| world()

press ) at |

(hello world()|

press <M-b>

(hello)| world()

Repository: https://github.com/jiangmiao/auto-pairs

Plugin: http://www.vim.org/scripts/script.php?script_id=3599

add

let g:AutoPairsFlyMode=1 

to .vimrc to turn Fly Mode on

网友答案:

I kinda agree with Atropo on this one: if you want to stick with DelimitMate then the least disruption to your workflow might be to make a custom imap to get to the other side of the auto inserted character.

Personally I prefer to have more control over where/when the characters are auto-inserted, and how I can navigate around the auto-inserted characters; UltiSnips or SnipMate does that for me. Maybe they're more what you're looking for.

网友答案:

If you typing on a new line, you try A which will append text at the end of the line.

网友答案:

I have autoClose installed. what I am doing currently is ("I" is cursor)

- (xxxxI)
- ( xxxxI )
- ( xxxxIxx )
- text (xxxxI) other text
- text ( xxxxI ) other text
- text ( xxxxIxx ) other text

I just make a mapping, to <esc>%%a then in above case, the cursor will move to (...)I..whatever

it doesn't work for quotes.

网友答案:

A little late to the party, but note that it can be done easily without any custom mappings. In insert mode, you can press <C-O> (a default mapping) to enter a "one shot" normal mode where you can enter a single normal mode command.

So to answer your question, what you could do is <C-O>a.

相关阅读:
Top