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.
If you press "F", Vim will move the cursor backwards instead of forward. Given the previous sentence, if pressed "Fq", and the cursor was at the end of the line, it would move to the "q" in "quick".
By default, all searches in vi are case-sensitive. To do a case-insensitive search, go into command mode (press Escape), and type :set ignorecase . You can also type :set ic as an abbreviation. To change back to case-sensitive mode, type :set noignorecase or :set noic in command mode.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With