Tip #299: Open file under cursor.
tip karma |
Rating -2/20, Viewed by 2378
|
Read and edit this tip on the
Vim tip wiki.
The wiki may have a more recent version of this tip.
created: |
|
August 6, 2002 4:23 |
|
complexity: |
|
intermediate |
author: |
|
Little Dragon |
|
as of Vim: |
|
5.7 |
A little thing that I did and found quite useful:
function! OpenFileUnderCursor()
let FileName = expand("<cfile>")
let OldPath = getcwd()
silent cd %:p:h
execute "silent sp +e " . FileName
execute "silent cd " . OldPath
endfunction
map! silent <M-e> :call OpenFileUnderCursor()<CR>
Then use Alt+E on a filename to open it (relative to the directory the current file resides in).
<< Changing case with regular expressions |
Making a tags file for IDL (Interactive Data Language) >>
Additional Notes
[email protected],
August 6, 2002 4:47
|
Did you ever try gf? ;-)
|
[email protected],
August 6, 2002 5:53
|
Not to mention ctrl-w f (for another window).
|
[email protected],
August 6, 2002 7:33
|
Hrm... Never tried gf or C-w f before :)
Cool :)
|
[email protected],
September 2, 2002 23:42
|
Hmm, ok, but is there a way to open the file in a NEW vim?
|
|