Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

While editing a simple text file where every line is nearly to the end of screen, I was expecting vim to retain the column position as I used j and k to move up and down.

Surprisingly, it does not happen. I am using a default install of vim on ubuntu 12.10 and a few plugins (unicycle, speeddating, tex, Align, Alignmaps, genutils, html, foldutil, scratch, surround).

The behaviour I am referring to is: I am in C57-L5. Line 6 is 80 characters long. I hit j, cursor jumps to C1-L6 instead of C57-L6.

What could be wrong? How can I set it right?

share|improve this question

1 Answer 1

open ~/.vimrc and add these 2 lines

nnoremap j gj
nnoremap k gk

close and restart vim.

ps: it will still go to the first column on empty lines, and you might want to set nowrap.

share|improve this answer

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.