Suppose I have the following buffer:
asdf
asdfotshne
asdfoensh
asdq
asdf
asdfothen
asdfghjkl;
qwertyuiop
zxcvbnm,.
Then I run :v/^asdf/norm 0
.
I expect to have the cursor go to Line 4. But it doesn't, it goes to the end of the file.
Why?
If your cursor is at first line of the file and you want to go to the first one that doesn't starts with asdf
, you can use following search
expression:
/\v^(asdf)@!
It does a negative look-ahead and stops in first match.
:v
is not used to move the cursor, but rather to perform an operation on all non-matching lines. As such, it scans every line of the file, and executes your norm 0
on each one that does not start with asdf. It thus jumps at the first character of qwertyuiop
, and then does the same thing at zxcvmnm,.
.
It is easier to find the last matching line using gg?
, then going one line down.
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