]> Sergey Matveev's repositories - dotfiles.git/blob - vim/.vim/pack/stargrave/start/fileline/autoload/fileline.vim
Move to vim9script
[dotfiles.git] / vim / .vim / pack / stargrave / start / fileline / autoload / fileline.vim
1 vim9script
2
3 # Simplified version of http://www.vim.org/scripts/script.php?script_id=2184
4 # that does not replace current window
5
6 export def Goto()
7     var file = bufname("%")
8     if filereadable(file) | return | endif
9     var names = matchlist(file, '\(.\{-1,}\):\%(\(\d\+\)\%(:\(\d*\):\?\)\?\)\?$')
10     if empty(names) | return | endif
11     var fileName = names[1]
12     var lineNum = names[2] == "" ? "0" : names[2]
13     var colNum = names[3] == "" ? "0" : names[3]
14     if !filereadable(fileName) | return | endif
15     var nr = bufnr("%")
16     execute "keepalt edit +" .. lineNum .. " " .. fileName
17     execute "normal! " .. colNum .. "|"
18     execute "bdelete " .. nr
19 enddef