移至下一个大写字母

gre*_*ire 4 vim

有没有一种简单的方法可以用 vim 移动到下一个大写字母?我经常使用驼峰式变量,它可能很有用。

Gil*_*il' 8

有一些脚本可以重新定义单词运动命令 ( b, e, w) 以停在 CamelCase 单词中的大写字母处;camelcasemotion看起来很成熟(免责声明:我从未使用过它)。如果您喜欢自己动手,Vim wiki有一些更简单的脚本示例。这是重新映射C-LeftC-Right处理caml 大小写单词的相对简单的方法。

nnoremap <silent><C-Left> :<C-u>call search('\<\<Bar>\U\@<=\u\<Bar>\u\ze\%(\U\&\>\@!\)\<Bar>\%^','bW')<CR>
nnoremap <silent><C-Right> :<C-u>call search('\<\<Bar>\U\@<=\u\<Bar>\u\ze\%(\U\&\>\@!\)\<Bar>\%$','W')<CR>
inoremap <silent><C-Left> <C-o>:call search('\<\<Bar>\U\@<=\u\<Bar>\u\ze\%(\U\&\>\@!\)\<Bar>\%^','bW')<CR>
inoremap <silent><C-Right> <C-o>:call search('\<\<Bar>\U\@<=\u\<Bar>\u\ze\%(\U\&\>\@!\)\<Bar>\%$','W')<CR>
Run Code Online (Sandbox Code Playgroud)


Kus*_*nda 5

下面的 Vim 命令将 Control-t 键组合(使用您希望的任何方便的组合)映射到命令/[A-Z](后跟返回),它将在“正常模式”(命令模式)中搜索下一个大写字母。.vimrc如果你愿意,你可以把它放在你的文件中(减去:)。该<c-t><return>的类型为我在这里写他们,Vim会明白。

:nmap <c-t> /[A-Z]<return>
Run Code Online (Sandbox Code Playgroud)