]> Sergey Matveev's repositories - dotfiles.git/blob - vim/.vim/plugin/file_line.vim
e5a6a927eae606c528b73434f8364f9dd22bbc6f
[dotfiles.git] / vim / .vim / plugin / file_line.vim
1 " Simplified version of http://www.vim.org/scripts/script.php?script_id=2184
2 " that does not replace current window
3
4 function! s:gotoline()
5     let names = matchlist(bufname("%"), '\(.\{-1,}\):\%(\(\d\+\)\%(:\(\d*\):\?\)\?\)\?$')
6     if empty(names) | return | endif
7     let file_name = names[1]
8     let line_num = names[2] == "" ? "0" : names[2]
9     let col_num = names[3] == "" ? "0" : names[3]
10     if !filereadable(file_name) | return | endif
11     exec "keepalt edit +" . line_num . " " . file_name
12     exec "normal! " . col_num . "|"
13 endfunction
14
15 autocmd! BufNewFile *:* nested call s:gotoline()
16 autocmd! BufRead *:* nested call s:gotoline()