Let's say we're currently in this line of code:
readonly L|a|zy<ICountryRepository> countryRepo;
and the cursor is in the position of letter "a", as shown in the code between two "|"symbols.
Now I want to move my cursor to the letter y
of the word countryRepo
, how can I do that using the minimum key strokes?
(Currently I'm using the key sequence of fyfyfyfy
in normal mode ... Kind of stupid)
If you know that it's the 4th y
, you can do
4fy
If you know it's the last y
in the line, you can do
$Fy
If you don't know at which position it is, you can still do
fy;;;
In this case, I would use
W
to move to countryRepo
, followed by
fy
I can think of:
4fy
But you should only do this if you are some strange robot.
/co<cr>fy
Which is one character shorter than your solution, but more easy..
Wfy
Go one WORD forward and then find y.
f>fy
Something like this I would do. Depends on what popups in my mind.
You should look into the easymotion plugin, which helps with arbitrary movements.
EDIT:
easymotion is rather worthless here, it is more useful for jumping to targets further away.
If you have vim-easymotion
, https://github.com/Lokaltog/vim-easymotion
You can do <leader><leader>t
and then search for letter y
. It's not that fast for the letters on the same line though. The real advantage is when you jump in the entire file.
I would do
tR;
or
WtR
or maybe
Wfy
Use EasyMotion .
In your case, <Leader><Leader>e
then a corresponding keypress (in this case b
) will bring your cursor onto the second y. Personally I use <Leader>
as the easymotion trigger so it is only 3 keystrokes for me. The main advantage is you do not need to guess or calculate.
use / for search, then type your word and press Enter
however, if you want to jump to next word, just press n
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.