Case insensitive f key in vim?

Does anyone know of any way to get the 'f' key in vim normal command mode to operate case insensitive

Example

function! OpenCurrentFileInMarked()

In the above line, if I am at the start of the line I want to be able to type 'fi'and get the first 'i' and then ';' to toggle to the capital 'I' in the middle of the function name. I would prefer that the 'f' key is always bound to case insensitivity. Would work much better for me as a default.


The easy answer here is: use a plugin. Others have had the idea before.

  • Fanf,ingTastic; : Find a char across lines

    The main purpose of this plugin is to make f and t cross the line boundary.

    To make them ignore case you need to let g:fanfingtastic_ignorecase = 1 in your vimrc.

  • ft_improved : improved f/t command

    Same here.

    To make it ignore case you again need to set a variable in your vimrc, this time let g:ft_improved_ignorecase = 1 .


  • The first part of this (case insensitive f) is actually in the reference manual as an example of how to use the getchar() function:

    This example redefines "f" to ignore case:

    :nmap f :call FindChar()<CR>
    :function FindChar()
    :  let c = nr2char(getchar())
    :  while col('.') < col('$') - 1
    :    normal l
    :    if getline('.')[col('.') - 1] ==? c
    :      break
    :    endif
    :  endwhile
    :endfunction
    

    See :help getchar() .

    You'll need to save the character returned and write a similar map for ; if you want that to work too.


    You can't do this with regular vim commands. However, you can write your own function and bind the f key to it.

    链接地址: http://www.djcxy.com/p/72228.html

    上一篇: 如何测试nginx代理超时

    下一篇: vim中大小写不敏感的f键?