Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

When editing files in vim, it is a small annoyance that when I move lines with j and k, it moves by file lines, rather than screen lines like other editors. With my own files, I can deal with this by automatically wrapping to a certain length in the vim options, but this is no good for files from others. Is there a vim command to either temporarily toggle the treatment of lines to screen lines, or alternate commands for moving that use screen lines?

share|improve this question
add comment

1 Answer

up vote 14 down vote accepted

You can move around the screen lines by using g in front of the commands:

gj
gk
g$
g0
g^

You can also map the original commands to the g commands like this:

:map j gj

j moves by screen lines now.

share|improve this answer
    
+1 for the map suggestion. Although I personally dont want to do it all the time, I'd like to use it when I want it. –  jeffjose Jan 9 '11 at 19:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.