Pergunta

I've run into an odd problem in Vim. I would like to drag and drop a file from my desktop or file manager into Vim and edit it. Gvim handles this behavior correctly.

When I attempt to do the same thing in console Vim, the path to the file name is inserted instead. For example, if I drag and drop the file /home/myuser/foo.matic, it will apply the text string '/home/myuser/foo.matic' to the current buffer.

If I type :edit, then drag and drop the file name, Vim treats '/home/myuser/foo.matic' as a new directory.

I believe the problem here is the quotes before and after the file path. These appear to be inserted by both gnome-terminal and terminator. Is there a way to strip these quotes from the file name when dragging and dropping? Alternatively, is there a way for Vim to ignore the quotes?

Foi útil?

Solução

You can’t make vim own :e command to do what you need, but you can define your own one. Most straightforward solution - make shell parse what was intended to be parsed by the shell - is listed below:

command -nargs=? -bang -bar E :execute "e<bang> ".fnameescape(system("echo -n ".<q-args>))

. This command accepts only :e[!] {file} variant, no +cmd and ++opts are allowed.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top