]> Sergey Matveev's repositories - dotfiles.git/blob - vim/.vim/plugin/file_line.vim
g:loaded_* stopper
[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 if exists("g:loaded_mein_file_line") | finish | endif
5 let g:loaded_mein_file_line = 1
6
7 function! s:gotoline()
8     let names = matchlist(bufname("%"), '\(.\{-1,}\):\%(\(\d\+\)\%(:\(\d*\):\?\)\?\)\?$')
9     if empty(names) | return | endif
10     let file_name = names[1]
11     let line_num = names[2] == "" ? "0" : names[2]
12     let col_num = names[3] == "" ? "0" : names[3]
13     if !filereadable(file_name) | return | endif
14     exec "keepalt edit +" . line_num . " " . file_name
15     exec "normal! " . col_num . "|"
16 endfunction
17
18 autocmd! BufNewFile *:* nested call s:gotoline()
19 autocmd! BufRead *:* nested call s:gotoline()