X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=vim%2F.vim%2Fplugin%2Ffile_line.vim;h=45e250ea59db2839658a25f59c126eb3dd5dd1c3;hb=efb6ca8ae3033cca0e89b989cc60c855d11a5131;hp=e5a6a927eae606c528b73434f8364f9dd22bbc6f;hpb=47f7d2b5f4a10a65950b0e3d5b07694bb2ce5dfa;p=dotfiles.git diff --git a/vim/.vim/plugin/file_line.vim b/vim/.vim/plugin/file_line.vim index e5a6a92..45e250e 100644 --- a/vim/.vim/plugin/file_line.vim +++ b/vim/.vim/plugin/file_line.vim @@ -1,15 +1,22 @@ " Simplified version of http://www.vim.org/scripts/script.php?script_id=2184 " that does not replace current window +if exists("g:loaded_mein_file_line") | finish | endif +let g:loaded_mein_file_line = 1 + function! s:gotoline() - let names = matchlist(bufname("%"), '\(.\{-1,}\):\%(\(\d\+\)\%(:\(\d*\):\?\)\?\)\?$') + let file = bufname("%") + if filereadable(file) | return | endif + let names = matchlist(file, '\(.\{-1,}\):\%(\(\d\+\)\%(:\(\d*\):\?\)\?\)\?$') if empty(names) | return | endif let file_name = names[1] let line_num = names[2] == "" ? "0" : names[2] let col_num = names[3] == "" ? "0" : names[3] if !filereadable(file_name) | return | endif + let nr = bufnr("%") exec "keepalt edit +" . line_num . " " . file_name exec "normal! " . col_num . "|" + exec "bdelete " . nr endfunction autocmd! BufNewFile *:* nested call s:gotoline()