Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
amix
committed
May 29, 2012
0 parents
commit 248da77
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
" ----- Emulate 'gf' but recognize :line format ----- | ||
function! GotoFile(w) | ||
let curword = expand("<cfile>") | ||
if (strlen(curword) == 0) | ||
return | ||
endif | ||
let matchstart = match(curword, ':\d\+$') | ||
if matchstart > 0 | ||
let pos = '+' . strpart(curword, matchstart+1) | ||
let fname = strpart(curword, 0, matchstart) | ||
else | ||
let pos = "" | ||
let fname = curword | ||
endif | ||
" Open new window if requested | ||
if a:w == "new" | ||
new | ||
endif | ||
" Use 'find' so path is searched like 'gf' would | ||
execute 'find ' . pos . ' ' . fname | ||
endfunction | ||
|
||
set isfname+=: " include colon in filenames | ||
|
||
" Override vim commands 'gf', '^Wf', '^W^F' | ||
nnoremap gf :call GotoFile("")<CR> | ||
nnoremap <C-W>f :call GotoFile("new")<CR> | ||
nnoremap <C-W><C-F> :call GotoFile("new")<CR> |