idbrii
idbrii

Reputation: 11916

Switch from f to F in Vim without ,

After using the f{char} motion, is it possible to change directions so ; will go backwards (as if you used F{char})? (And vice-versa and with tT.)

I'm going to try using , as LocalLeader and I have this to let me access , again:

let maplocalleader = ','
nnoremap <LocalLeader><LocalLeader> <LocalLeader>

But I wonder if I can map <LocalLeader>; to make ; switch between acting like ; and ,. I don't see anywhere the character for f is stored, so can I do this?

Upvotes: 2

Views: 124

Answers (1)

Ingo Karkat
Ingo Karkat

Reputation: 172520

No, this cannot be done, unless you re-implement the f command yourself (which isn't so difficult as it sounds; there are actually plugins that enhance it to search in subsequent lines, too). It can be done for n / N (via v:searchforward), though.

In general, I would advise from employing such clever "tricks"; they retrain your muscle memory, and cause problems in other environments with vi-like keybindings (Pentadactyl, Bash, readline, some IDEs). Rather, rethink your approach to mappings.

Upvotes: 4

Related Questions