Skip to content

Instantly share code, notes, and snippets.

@trappist
Created December 25, 2013 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trappist/8120624 to your computer and use it in GitHub Desktop.
Save trappist/8120624 to your computer and use it in GitHub Desktop.
Open the file with the cursor on lineno given /path/to/file:linono on the command line
function! s:gotoline()
let file = bufname("%")
let names = matchlist( file, '\(.*\):\(\d\+\)')
if len(names) != 0 && filereadable(names[1])
exec ":e " . names[1]
exec ":" . names[2]
if foldlevel(names[2]) > 0
exec ":foldopen!"
endif
endif
endfunction
autocmd! BufNewFile *:* nested call s:gotoline()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment