Re: Goto file under cursor with line number
Hello, On 6/1/06, Srinivas Rao. M <[EMAIL PROTECTED]> wrote: Hello vimmers, I want to know if there is a way i can use 'gf' command to goto the file under the cursor, which is having the I have a string under my cursor as : somefile.c:1022 Where the field after ':' is the line number. Can i use the 'gf' command to goto that line number of that file. Assume that somefile.c's folder is added to "path" variable. In Vim7, you can use the gF command to edit the file name under the cursor and if a number follows the file name, jump to that line number in the file. You can use F to open the file in a new window and jump to the line and gF to open the file in a new tab and jump to the line. - Yegappan
Re: Goto file under cursor with line number
Srinivas Rao. M wrote: > Hello vimmers, >I want to know if there is a way i can use 'gf' command to goto the > file under the cursor, which is having the > > I have a string under my cursor as : > > somefile.c:1022 > > Where the field after ':' is the line number. Can i use the 'gf' command > to goto that line number of that file. Assume that somefile.c's folder > is added to "path" variable. No need for plugins or functions, it's already there: :help gF HTH Niels
Re: Goto file under cursor with line number
On Fri, Jun 02, 2006 at 12:08:42PM +0530, Srinivas Rao. M wrote: > Hello vimmers, >I want to know if there is a way i can use 'gf' command to goto the > file under the cursor, which is having the > > I have a string under my cursor as : > > somefile.c:1022 > > Where the field after ':' is the line number. Can i use the 'gf' command > to goto that line number of that file. Assume that somefile.c's folder > is added to "path" variable. > > > Thanks, > srini... I posted a function to do this back in 2004. It respects the 'path' variable and overrides 'gf', '^Wf', '^W^F'. Here's an archive link: http://marc.theaimsgroup.com/?l=vim&m=108273507828349&w=2 -- + Gregory H. Margo gmargo at yahoo/com, gmail/com, pacbell/net; greg at margofamily/org
Re: Goto file under cursor with line number
Hi, I should probably add this to vim.org as a Plugin or something at some stage. Drop all this stuff in your .vimrc and then 'gf' will jump to the file + line number, and 'gsf' will split the window then jump to the file + line number. == function! GotoFileWithLineNum() " filename under the cursor let file_name = expand('') if !strlen(file_name) echo 'NO FILE UNDER CURSOR' return endif " look for a line number separated by a : if search('\%#\f*:\zs[0-9]\+') " change the 'iskeyword' option temporarily to pick up just numbers let temp = &iskeyword set iskeyword=48-57 let line_number = expand('') exe 'set iskeyword=' . temp endif " edit the file exe 'e '.file_name " if there is a line number, go to it if exists('line_number') exe line_number endif endfunction map gf :call GotoFileWithLineNum() map gsf :sp:call GotoFileWithLineNum() == regards, Peter Send instant messages to your online friends http://au.messenger.yahoo.com
Goto file under cursor with line number
Hello vimmers, I want to know if there is a way i can use 'gf' command to goto the file under the cursor, which is having the I have a string under my cursor as : somefile.c:1022 Where the field after ':' is the line number. Can i use the 'gf' command to goto that line number of that file. Assume that somefile.c's folder is added to "path" variable. Thanks, srini...