Vim: move around quickly inside of long line

  • You can use $, 0, and ^ to move to line endpoints and then use w and b. Also, adding a numeric argument to w and b can accelerate the process, so using 6w instead of just w can put you about to where ou need to be.
  • Using f and t to move to individual characters will help also. (I use this typically with punctuation. If, for example, I have four sentences on one long line 2f. will go to the end of the second sentence)
  • Using the ( and ) keys are an alternative way to navigate entire sentences.
  • Splitting out long lines into multiple lines (manually, or with set tw=72 [or 80]) can make editing them simpler. You can always join them later with J.
  • Something I just discovered, you can move up and down one displayed line by using gj and gk. That way, you can treat your one wrapped line as multiple lines.

If you comment on the type of data you're editing, it might make it easier for us to make suggestions.


I think you can benefit from gk and gj instead of just k and j.

Also look at 'virtualedit' for some options that allow you to cursor through 'void' areas without flicking the cursor to the next best physical character.

You might want to (temporarily)

nnoremap <buffer> k gk
nnoremap <buffer> j gj

Leave out the <buffer> part to apply this globally.


You can use ( and ) to navigate by sentence; it just looks for ., but that can be immensely helpful, especially if you don't like the sentence and want to change it: (c) will jump to the beginning of the current sentence, then change the entire sentence.

You can also use w and e, with count modifiers, to move words. 3w will move three words at a time.

You can also use f and F to search forward and backwards for a specific character. This is much more useful if you're looking for the word quite or syzygy than the. :)


My preferred strategy while jumping around long lines is to use f F and t T to zero in on the character. What makes this family of motions supercharged is that you can utilize the ; and , motions, so you don't have to count the position of character relative to cursor, but just step through them (extremely useful with ' " . etc)

Let's say we have a line:

reallyLongObjectName.longMethod().prettyPrettyLongMethod().burp();

If we need to jump to, say, the third dot from the beginning of the line, we can use either 3f. or f.;; visiting two dots and landing on third.

While the ; , style can use more keystrokes, I found it more agile and fun overall.