Closed zimbatm closed 12 years ago
The problem is that vim is not invoking the "BufNewFile" auto command in certain situations, ":e" and the "gf" (go file) key combo. This is either a problem with the documentation or a bug in vim it self.
Thanks, I just added the following line and it seems to work. Not sure if it will have side-effects though
autocmd! BufRead *:* nested call s:gotoline()
The side effect is that if you actually have a file 'xxxx:20' and also a file 'xxxx' it would become impossible to edit the file 'xxxx:20' because the plugin would be called by the BufRead and would change automatically read the 'xxxx' file and jump into line 20.
Reply to this email directly or view it on GitHub: https://github.com/bogado/file-line/issues/1#issuecomment-2546192
Well I know it is a corner case of a corner case, but one must fix it anyway. :-)
Ok then, how about checking if the file exists before doing the changes?
diff --git a/plugin/file:line.vim b/plugin/file:line.vim
index b5a0856..acfe606 100644
--- a/plugin/file:line.vim
+++ b/plugin/file:line.vim
@@ -9,7 +9,7 @@ function! s:gotoline()
" Accept file:line:column: or file:line:column and file:line also
let names = matchlist( file, '\(.\{-1,}\):\(\d\+\)\(:\(\d*\):\?\)\?$')
- if len(names) != 0 && filereadable(names[1])
+ if !filereadable(name) && len(names) != 0 && filereadable(names[1])
let l:bufn = bufnr("%")
exec "keepalt edit " . names[1]
exec ":" . names[2]
@@ -26,3 +26,4 @@ function! s:gotoline()
endfunction
autocmd! BufNewFile *:* nested call s:gotoline()
+autocmd! BufRead *:* nested call s:gotoline()
I've done that, I already commited your change and a check to verifyu if the file exists. :-)
That's why I closed the issue. :-)
Alright :)
Awesome, I wanted this for long. Is it possible to also support that for the :e command ? Just give me some pointers and I'll send you a pull request