Cato Johnston
Cato Johnston

Reputation: 45659

How to go to a specified file/character/byte position in vim?

I'm getting an error message from a python script at position 21490.

How can I go to this position in Vim?

Upvotes: 314

Views: 169027

Answers (2)

ljs.dev
ljs.dev

Reputation: 4483

vim +21490go script.py

From the command line will open the file and take you to position 21490 in the buffer.

Triggering it from the command line like this allows you to automate a script to parse the exception message and open the file to the problem position.


Excerpt from man vim:

+{command}

-c {command}

{command} will be executed after the first file has been read. {command} is interpreted as an Ex command. If the {command} contains spaces it must be enclosed in double quotes (this depends on the shell that is used).

Upvotes: 71

Brian Carper
Brian Carper

Reputation: 72926

:goto 21490 will take you to the 21490th byte in the buffer.

Upvotes: 502

Related Questions