bogado / file-line

Plugin for vim to enabling opening a file in a given line
http://www.vim.org/scripts/script.php?script_id=2184
299 stars 61 forks source link

Breaks swapchoice setting? #73

Open nfischer opened 6 years ago

nfischer commented 6 years ago

Not sure why this is happening, but I'm pretty sure this plugin breaks the v:swapchoice varaible.

I have a section of code in my vimrc like:

augroup NoSimultaneousEdits
  autocmd!
  autocmd SwapExists * let v:swapchoice = 'o'
augroup END

Here's some online explanation.

It looks like vim (and nvim) no longer respect the swapchoice setting when this plugin is loaded. It works for 'q' and 'a' (I didn't try others), but not 'o' (probably the most common choice). Any idea what's going on here?

bogado commented 6 years ago

The plug-in is trying to rewrite the file you're opening. When you do "vim file.txt:20" vim tries to open a file with that exact name.

This plug-in will capture those and if a file named "file.txt" exists it will replace the new file that was just created with the previously existent file and jump to line 20.

The problem is that those manipulations confuse vim events and some weird things happen.

I've tried two different strategies for the substitution to happen, but both have some weird side effect.

nfischer commented 6 years ago

Any way to fix this?

At the very least, it might be good to add a warning in documentation. The SwapExists thing is relatively common.


Also, thanks for the awesome plugin!