For some text formats, line breaks matter.

For example, I often use Vim to write MediaWiki documents, where you can't just put a linebreak anywhere (unlike Markdown). So I'm forced to write lines with a lot of characters.

This can lead to long (200+ chars) or even very long (1000+ chars) lines. I find this very awkward to use in Vim. One example is if I want to edit something in the middle of the 1000 character-line, I need to move my cursor 500 times.

This can be made a bit faster with w or /, but it's still awkward.

Are there better ways to deal with this? Better movement keys? Some sort of "fake wrapping" (text behaves as if tw=80, but no \n in the file), or something else?

  • 2
    You may also want to also set display=lastline to avoid blank @ lines at the end of the screen.
    – Random832
    Commented Feb 27, 2015 at 22:07

4 Answers 4


You can use g series of commands to move to the boundaries of the visible screen area. For example, g$ moves to the right edge of the screen (which is not necessarily the end of the line). gj moves the cursor down one line as it appears on your screen (which is not necessarily one logical line down).

Perhaps you could rebind the arrow keys:

nnoremap <Up> gk
nnoremap <Down> gj

Or some people also directly rebind k and j:

nnoremap k gk
nnoremap j gj

For insert mode, you could use:

inoremap <C-k> <C-o>gk
inoremap <C-j> <C-o>gj


inoremap <Up> <C-o>gk
inoremap <Down> <C-o>gj

In addition, if you use :set wrap, Vim will wrap the lines, so you can see all of the line. You can also use set showbreak=+ to show a + to indicate that Vim is doing wrapping.

To jump to specific column positions, you can use the | command. For example, 200| will go to column position 200.

  • 1
    ... and g5j to jump 5 down, as usual.
    – yo'
    Commented Feb 3, 2015 at 18:53
  • 1
    @yo' I think you mean 5gj Commented Feb 5, 2015 at 17:23
  • 1
    @Carpetsmoker Strange; with most commands it doesn't matter in which order you give the prefixes and the numbers, as long as the command itself is last. Here it does not :-/
    – yo'
    Commented Feb 6, 2015 at 9:50
  • 2
    @200-success: Isn't "set showsbreak=+" supposed to be "set showbreak=+"? Commented Dec 6, 2021 at 0:57
  • 2
    Indeed; I edited the answer to fix it. Commented Dec 6, 2021 at 1:28

When I'm dealing with very long lines, the biggest pain point has to do with differing line lengths. That is, moving up or down near the ends of the lines scrolls the window very far left or right.

This can be avoided by setting virtualedit=all, which allows you to move the cursor into the space long after the line endings.


Vim has support for soft wrapping, just set wrap to enable it and it will wrap long lines going beyond the visible screen. You can use gj & gk to move up/down respectively over such wrapped lines.


As others have said, you can use g + something to move around. However, when you have extremely long lines, pressing gj multiple times to move downward is not ergonomic. I have the following in my .vimrc to make that much easier:

vmap <D-j> gj
vmap <D-k> gk
vmap <D-4> g$
vmap <D-6> g^
vmap <D-0> g^
nmap <D-j> gj
nmap <D-k> gk
nmap <D-4> g$
nmap <D-6> g^
nmap <D-0> g^

On a Mac, this allows me to use j, k, $, 0 and ^ on display lines by holding down the command key. On other systems, instead of D you could try M or A for Alt, or C for Control.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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