Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to jump directly to a column number in Vim

Tags:

vim

People also ask

How do I jump to a specific line in vim?

If we are in the vim editor, then simply do this, “Press the ENTER key, write the Line number, and press Shift+ g”: Again the output is the same.

How do I find column numbers in vim?

If you want to show the current column of cursor, then type :echo col('. ').

How do I go to a specific line number in vi editor?

If you're already in vi, you can use the goto command. To do this, press Esc , type the line number, and then press Shift-g . If you press Esc and then Shift-g without specifying a line number, it will take you to the last line in the file.


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


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


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

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'