Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim navigation for very long lines [duplicate]

Tags:

vim

I'm editing a text file with vim and I have wrap enabled using "set wrap". Suppose I have one very long line which has been wrapped to 10 lines. Lets say I'm on the 5th word(which is on the first line when wrapped) and I'd like to get to a word on the 7th line(when wrapped). Whats the fastest way I could get to that line. I'm not too keen on going w<a-number>l -- there is probably a better/easier way to do this, right?


2 Answers

  • gj to go to line below (same line, but wrapped)
  • gk to go to the above line.

I have a map in my .vimrc

map j gj
map k gk
like image 184
Paco Avatar answered Mar 16 '26 23:03

Paco


There are several motions that specifically deal with :set wrap; mostly they are variants of the "normal" motions with g prefixed.

So there's gj and gk to move across screen lines, as well as g0, g^, g$, etc. Look them up with :help for more details.

like image 31
Ingo Karkat Avatar answered Mar 16 '26 22:03

Ingo Karkat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!