Skip to content

Instantly share code, notes, and snippets.

@dahu
Created October 20, 2012 09:14
Show Gist options
  • Select an option

  • Save dahu/3922742 to your computer and use it in GitHub Desktop.

Select an option

Save dahu/3922742 to your computer and use it in GitHub Desktop.
Edit File WORD
" Edit file under cursor (not matching :help 'isfname) (:help gf)
" Deliberately left off terminating <cr> if filename can't be found
" to allow user to modify before execution.
" (:help cWORD)
function! EditFileWORD()
let file = expand('<cWORD>')
if findfile(file, &path) != ''
let file .= "\<cr>"
endif
return ":edit " . file
endfunction
" Demonstration of a (:help <expr>) map
nnoremap <expr> <leader>gf EditFileWORD()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment