How to jump directly to a column number in Vim

Vim

Vim Problem Overview


Sometimes for debugging purposes I have to do the exciting job of wading through minified javascript code. The lines are upto 600 columns wide. The exception reporting library is kind enough to provide me the exact crash coordinates in the form of line number and column number. However I can't find a way to directly jump to the column number, even though I can jump to the line so easily.

How can I do it?

Vim Solutions


Solution 1 - Vim

The | command does what you want, as in 30| will take you to column 30.

                                                        bar
|                       To screen column [count] in the current line.
                        exclusive motion.  Ceci n'est pas une pipe.

http://vimdoc.sourceforge.net/htmldoc/motion.html#bar

Solution 2 - Vim

You can use the cursor function. For example, to jump to column 25 of line 15, you can use :call cursor(15,25).

Solution 3 - Vim

An alternative answer that works for me on Mac OS is to use the command that moves the cursor to the right (i.e. l). So if your cursor is on the first column, and you want to put the cursor at column 50 of your current line, use the command:

49l

Solution 4 - Vim

80| takes you to the 80th column - if your line has that many columns, that is, and from anywhere in the current line.

also: this is a pipe sign, not the lowercase letter 'L'

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJayeshView Question on Stackoverflow
Solution 1 - VimA BView Answer on Stackoverflow
Solution 2 - VimRavikant ManeView Answer on Stackoverflow
Solution 3 - VimentpnerdView Answer on Stackoverflow
Solution 4 - VimsjasView Answer on Stackoverflow