Skip to content

Instantly share code, notes, and snippets.

@pocke
Created June 11, 2024 02:33
Show Gist options
  • Save pocke/44cc6efcbb5621f1b6f2303ba18adb20 to your computer and use it in GitHub Desktop.
Save pocke/44cc6efcbb5621f1b6f2303ba18adb20 to your computer and use it in GitHub Desktop.
.vimrc example to open file on specified line with `fname:lineno` format
autocmd BufReadCmd *:[0-9]\+ ++nested call s:edit_with_lnum(expand('<afile>'))
function! s:edit_with_lnum(path_with_lnum) abort
let lnum = matchstr(a:path_with_lnum, '\v[0-9]+$')
let path = matchstr(a:path_with_lnum, '\v^.+\ze:[0-9]+$')
exec 'e' path
exec lnum
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment