Changeset 14691


Ignore:
Timestamp:
04/22/13 10:34:44 (12 years ago)
Author:
Mathieu Morlighem
Message:

CHG: updated file_line.vim

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/externalpackages/vim/addons/vim/plugin/file_line.vim

    r4230 r14691  
     1" Avoid installing twice or when in unsupported Vim version.
     2if exists('g:loaded_file_line') || (v:version < 700)
     3        finish
     4endif
     5let g:loaded_file_line = 1
     6
    17function! s:gotoline()
    28        let file = bufname("%")
    3         let names =  matchlist( file, '\(.*\):\(\d\+\)')
    49
    5         if len(names) != 0 && filereadable(names[1])
     10        " :e command calls BufRead even though the file is a new one.
     11        " As a workarround Jonas Pfenniger<jonas@pfenniger.name> added an
     12        " AutoCmd BufRead, this will test if this file actually exists before
     13        " searching for a file and line to goto.
     14        if (filereadable(file))
     15                return
     16        endif
     17
     18        " Accept file:line:column: or file:line:column and file:line also
     19        let names =  matchlist( file, '\(.\{-1,}\):\%(\(\d\+\)\%(:\(\d*\):\?\)\?\)\?$')
     20
     21        if empty(names)
     22                return
     23        endif
     24
     25        let file_name = names[1]
     26        let line_num  = names[2] == ''? '0' : names[2]
     27        let  col_num  = names[3] == ''? '0' : names[3]
     28
     29        if filereadable(file_name)
    630                let l:bufn = bufnr("%")
    7                 exec ":e " . names[1]
    8                 exec ":" . names[2]
    9                 exec ":bdelete " . l:bufn
    10                 if foldlevel(names[2]) > 0
    11                         exec ":foldopen!"
     31                exec ":bwipeout " l:bufn
     32
     33                exec "keepalt edit " . file_name
     34                exec ":" . line_num
     35                exec "normal! " . col_num . '|'
     36                if foldlevel(line_num) > 0
     37                        exec "normal! zv"
    1238                endif
     39
     40
     41                exec "normal! zz"
    1342        endif
     43
    1444endfunction
    1545
    1646autocmd! BufNewFile *:* nested call s:gotoline()
     47autocmd! BufRead *:* nested call s:gotoline()
Note: See TracChangeset for help on using the changeset viewer.