How to configure vim to open the name of a file that contains a row and column number?

Useful when debugging 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: 
+8
vim
source share
3 answers

The file opens : line . It will open the file and set the cursor position in the specified row and column.

Works with trailing colon:

 vim file.cpp:10 vim file.cpp:10: vim file.cpp:10:4 vim file.cpp:10:4: 
+9
source share

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

You get documentation from

 :help quickfix 

for example

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

will analyze errors and warnings generated by g ++ and let you cycle through locations.

+4
source share

Take a look at the quickfix vim functions: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#quickfix

You can compile from vim (see vim makeprg and errorformat ) and then automatically jump to lines that generate errors with :cc :cp and :cn .

The same vimdoc shows you how to quickly jump to the beginning or end of the current function or block of code, and if you use ctags , you can also find definitions of functions and variables.

+3
source share

All Articles