(drag-n-drop modifications) |
|||
(2 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
+ | {{TipNew |
||
− | {{TipProposed |
||
− | |id= |
+ | |id=1600 |
− | |previous= |
+ | |previous=1599 |
− | |next= |
+ | |next=1601 |
− | |created= |
+ | |created=2008 |
|complexity=basic |
|complexity=basic |
||
|author=Fritzophrenic |
|author=Fritzophrenic |
||
Line 15: | Line 15: | ||
It turns out, Vim ''does'' have this functionality, but it is hard to find. |
It turns out, Vim ''does'' have this functionality, but it is hard to find. |
||
− | The < |
+ | The <code>:drop</code> command will edit a new file, or jump to the window containing it if it already exists. Using <code>:tab</code> with it (i.e. <code>:tab drop {file}</code>) will open the file in a new tab if it isn't already open. |
− | Dragging and dropping a file into gvim automatically invokes the < |
+ | Dragging and dropping a file into gvim automatically invokes the <code>:drop</code> command. If you hold down the CTRL key while doing this, it will force a window to split (there isn't a way to force a tab, but CTRL-W T right afterwards will do that for you easily). If you hold down SHIFT, it will set Vim's working directory to that of the file. |
==References== |
==References== |
||
Line 24: | Line 24: | ||
==Comments== |
==Comments== |
||
+ | |||
+ | You can use <code>:command! -nargs=1 -complete=file O tab drop <args></code> to open the file or jump to it using <code>:O FILENAME</code>. |
Revision as of 11:14, 25 September 2013
created 2008 · complexity basic · author Fritzophrenic · version 7.0
When using most tabbed editors, if you open a file for editing, and the file is already open in another tab, the editor will simply jump to that tab. There are very good reasons that Vim does not act this way, which are too numerous to go into detail about here – suffice it to say that there are many excellent features in Vim that would not be possible if it acted like "most tabbed editors". Nevertheless, it would be nice if Vim had this functionality when the user wishes to use it.
It turns out, Vim does have this functionality, but it is hard to find.
The :drop
command will edit a new file, or jump to the window containing it if it already exists. Using :tab
with it (i.e. :tab drop {file}
) will open the file in a new tab if it isn't already open.
Dragging and dropping a file into gvim automatically invokes the :drop
command. If you hold down the CTRL key while doing this, it will force a window to split (there isn't a way to force a tab, but CTRL-W T right afterwards will do that for you easily). If you hold down SHIFT, it will set Vim's working directory to that of the file.
References
Comments
You can use :command! -nargs=1 -complete=file O tab drop <args>
to open the file or jump to it using :O FILENAME
.