sponsor Vim development Vim logo Vim Book Ad

basic Tip #487: jump to a file to a certain line number

 tip karma   Rating 3/3, Viewed by 1175 

created:   June 16, 2003 10:09      complexity:   basic
author:   yijun      as of Vim:   5.7

Dear VIMMERS:

It is useful to have cn, cl for locating errors. however, when the compilation was done off-line,
gcc  ... >& compile.log
how to use the compile.log to locate the errors? for example,
     vim.h:1506
if i use "gf" when the cursor is over "vim.h", it just jumps to the begining of the file.
here may be one solution by combining several steps:
      nmap gt mAT f:l"aywbbgf:^Ra^M
"mA"   --- marks the current position to global register A so that i can return the log file by 'A
"T "     --- goes to the begining of the tag, so in any characters of "vim.h:1506", it first places the cursor to "v".
"f:"      --- goes to the ":" separator
"l"       --- goes to the starting of line number
"ayw   --- try to use register a to remember the line number
"bb"    --- move cursor back to the filename
"gf"     --- now jump to the file
":^Ra^M"
          --- jump to the line number remembered in register a

nmap gt ... place the above steps into key combinations "g" "t" so next time use "gt" instead of "gf" on the error tag!

 rate this tip  Life Changing Helpful Unfulfilling 

<<Search for word under cursor, but don't move. | vimrc setting for wider vim diff window (gVim) >>

Additional Notes

gpwen, June 16, 2003 21:48
You can try the :cfile command:
:help cfile
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to [email protected] after searching the archive. Help Bram help Uganda.
Sponsored by Web Concept Group Inc. SourceForge Logo