我希望能够点击标签并让它跨过/移出Vim中的结束标记。 I can kind of achieve this by adding
inoremap <C-e> <C-o>A
到我的.vimrc,但这只能按Ctrl + e工作(它会移动到行尾,而不是在结束标记之外)。我更喜欢使用tab。
我使用以下方法在Sublime Text 2中设置了这个:
[
{ "keys": ["tab"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
[
{ "key": "following_text", "operator": "regex_contains", "operand": "^[;=><',)\"\\]]", "match_all": true },
{ "key": "auto_complete_visible", "operator": "equal", "operand": false }
]
}
]
感谢您的帮助
答案 0 :(得分:2)
前段时间我写了这个小vimscript,我认为你想做什么。希望它有所帮助
if !exists( "g:out_of_expression_quick_key" )
let g:out_of_expression_quick_key = "<Tab>"
endif
execute "imap " . g:out_of_expression_quick_key . " <C-r>=IncreaseColNumber()<CR>"
execute "imap " . g:out_of_expression_quick_key[0] . 'S-' . g:out_of_expression_quick_key[1:] . ' <C-r>=DecreaseColNumber()<CR>'
let s:delimiters_exp = '[\[\]{}())"' . "'" . '<>]'
fun! IncreaseColNumber()
let l:colnum = col('.')
let l:line = getline('.')
if l:line[col('.') - 1:l:colnum] =~# s:delimiters_exp
return "\<Right>"
endif
if g:out_of_expression_quick_key =~# "<Return>"
return "\<CR>"
endif
if g:out_of_expression_quick_key =~# "<Tab>"
return "\<Tab>"
endif
endfunction
fun! DecreaseColNumber()
let l:line = getline('.')
if l:line[col('.') - 2] =~# s:delimiters_exp
return "\<Left>"
endif
if g:out_of_expression_quick_key =~# "<Return>"
return "\<S-CR>"
endif
if g:out_of_expression_quick_key =~# "<Tab>"
return "\<S-Tab>"
endif
endfunction
答案 1 :(得分:1)
怎么样?
<Esc>va(<Esc>`<
将光标置于前一个“(”字符匹配后的当前位置?
“&lt;”,而不是最后一个“&gt;”,将光标置于下一个不匹配的“)”...“(”可以替换为“{”或“[”或“s”(句子)或“p”(段落)或“”“(字符串)。更多可能性通过以下方式显示:
:help a(
要在当前段落的末尾,您还有:
<C-o>}
将“}”改为“)”,以便在当前句子的末尾。
要转到next()或{}或[]的末尾,您可以输入
<C-o>%