How do I move to the next capital letter?

前端 未结 5 1143
庸人自扰
庸人自扰 2021-02-01 02:25

In vim I can use f followed by a character to go to the next occurrence of that character on the current line. For example, if I have the following (cursor position

5条回答
  •  囚心锁ツ
    2021-02-01 02:29

    I have found this vim tip for moving within CamelCaseWords that might be useful:

    " Use one of the following to define the camel characters.
    " Stop on capital letters.
    let g:camelchar = "A-Z"
    " Also stop on numbers.
    let g:camelchar = "A-Z0-9"
    " Include '.' for class member, ',' for separator, ';' end-statement,
    " and <[< bracket starts and "'` quotes.
    let g:camelchar = "A-Z0-9.,;:{([`'\""
    nnoremap  :call search('\C\<\\%(^\[^'.g:camelchar.']\@<=\)['.g:camelchar.']\['.g:camelchar.']\ze\%([^'.g:camelchar.']\&\>\@!\)\\%^','bW')
    nnoremap  :call search('\C\<\\%(^\[^'.g:camelchar.']\@<=\)['.g:camelchar.']\['.g:camelchar.']\ze\%([^'.g:camelchar.']\&\>\@!\)\\%$','W')
    inoremap  :call search('\C\<\\%(^\[^'.g:camelchar.']\@<=\)['.g:camelchar.']\['.g:camelchar.']\ze\%([^'.g:camelchar.']\&\>\@!\)\\%^','bW')
    inoremap  :call search('\C\<\\%(^\[^'.g:camelchar.']\@<=\)['.g:camelchar.']\['.g:camelchar.']\ze\%([^'.g:camelchar.']\&\>\@!\)\\%$','W')
    vnoremap  :call search('\C\<\\%(^\[^'.g:camelchar.']\@<=\)['.g:camelchar.']\['.g:camelchar.']\ze\%([^'.g:camelchar.']\&\>\@!\)\\%^','bW')v`>o
    vnoremap  `>:call search('\C\<\\%(^\[^'.g:camelchar.']\@<=\)['.g:camelchar.']\['.g:camelchar.']\ze\%([^'.g:camelchar.']\&\>\@!\)\\%$','W')v`

提交回复
热议问题