简体   繁体   English

如何配置vim打开包含行号和列号的文件名?

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

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:

Check out file:line plugin also. 查看文件:line plugin。 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:

vim actually has a whole set of built-in commands and options for this. vim实际上有一整套内置命令和选项。

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. 将解析g ++输出的错误和警告,让您循环遍历这些位置。

Look at the "quickfix" features of vim: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#quickfix 看看vim的“quickfix”功能: http//vimdoc.sourceforge.net/htmldoc/quickfix.html#quickfix

You can compile from within vim (see vim's makeprg and errorformat variables), and then automatically jump to the lines that generate errors using :cc , :cp , and :cn . 您可以在vim中编译(请参阅vim的makeprgerrorformat变量),然后使用以下命令自动跳转到生成错误的行:cc:cp:cn

The same vimdoc shows you how to jump quickly to the beginning or end of the current function or block of code, and if you use ctags you can also locate the definitions of functions and variables. 同一个vimdoc向您展示如何快速跳转到当前函数或代码块的开头或结尾,如果使用ctags您还可以找到函数和变量的定义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM