7
Vim :set ignorecase
command do not affect "f" and "t" motion commands in my vim config.
Is there any option or hack that makes this commands to ignore case?
7
Vim :set ignorecase
command do not affect "f" and "t" motion commands in my vim config.
Is there any option or hack that makes this commands to ignore case?
1
I would suggest something like:
function! ForwardLookup()
" get next key pressed
let c = nr2char(getchar())
let old_search_pattern = @/
" Use of \V enables very-nonmagic pattern
exec 'normal /\c\V' . escape(c, '\/') . nr2char(0x0d)
let @/ = old_search_pattern
endfunction
nnoremap f :call ForwardLookup()<CR>
This also doesn't support repeat f command by ;
– Thomson – 2014-07-30T02:00:51.927
1Not strong enough: don't support numeric prefix, goes over line break, no visual mode support. – Bogdan Gusiev – 2011-06-29T19:47:59.683
0
A basic version of this 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, and write code to handle v:count1
if you want it to work with counts.
See also the Q/A on vi.SE: https://vi.stackexchange.com/questions/15382/how-to-make-fchar-case-insensitive
– Luc Hermitte – 2018-04-09T14:03:27.503