Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to config vim to open a filename which contains line and column number?

Tags:

vim

It's usefull, when debug a program.

# compile file
$ g++ -Wall main.cpp
main.cpp:42:7: warning: backslash and newline separated by space

# I do this to locate
$ vim main.cpp +42 +'normal 7|'

# how to do this?
$ vim main.cpp:42:7:
like image 816
kev Avatar asked Feb 29 '12 02:02

kev


People also ask

How do I open a line number in vim?

Vim can display line numbers in the left margin: Press ESC key. At the : prompt type the following command to run on line numbers: set number. To turn off line numbering, type the following command at the : prompt set nonumber.

How do I show column numbers in vim?

Press the Esc key if you are currently in insert or append mode. Press : (the colon). The cursor should reappear at the lower left corner of the screen next to a : prompt. A column of sequential line numbers will then appear at the left side of the screen.


2 Answers

Check out file:line plugin also. It will open file and set cursor position to specified line and column.

Works with trailing colon:

vim file.cpp:10
vim file.cpp:10:
vim file.cpp:10:4
vim file.cpp:10:4:
like image 115
cutalion Avatar answered Sep 20 '22 07:09

cutalion


vim actually has a whole set of built-in commands and options for this.

You get the documentation with

:help quickfix

For example

:set makeprg=g++\ -Wall\ main.cc " the default is make
:make

will parse the errors and warnings output by g++ and let you cycle through the locations.

like image 39
strcat Avatar answered Sep 21 '22 07:09

strcat