Is there a way of disabling NERDTree when opening a file? When I open a file in mvim (using --remote-silent
) and a NERDtree window is currently active, the file will open in that (narrow) window. How can I configure Vim to select another window if available and to open one if not?
Asked
Active
Viewed 550 times
0

Ingo Karkat
- 167,457
- 16
- 250
- 324

chopper
- 6,649
- 7
- 36
- 53
1 Answers
0
There's no way to intercept the --remote-silent
; you have to send explict commands to open the file with --remote-send
instead. There, you can encode logic to deal with the NERDTree window, e.g. to move to the previous one if it is active:
$ gvim --remote-send "<C-\><C-n>:if &ft == 'nerdtree'|wincmd p|endif|edit filename<CR>"

Ingo Karkat
- 167,457
- 16
- 250
- 324
-
Is there no way of configuring vim itself (i.e. put this logic in an 'on open' callback)? – chopper Dec 05 '13 at 18:40
-
I don't think there's a proper event, or you aren't allowed to switch windows in there, so that would only leave you to retroactively restore / shuffle the windows around. – Ingo Karkat Dec 05 '13 at 19:50
-
Hm I see. Out of interest - how come --remote-silent doesn't take commands? The help said it did, but I tried it out and it seems like you're right. – chopper Dec 05 '13 at 21:36
-
The command(s) you can pass with --remote-silent are applied _after_ the file has been opened (e.g. to change an option); that doesn't help here. – Ingo Karkat Dec 06 '13 at 07:33
-
On Windows, if gvim is not running, I get the "no server found message". Any way to avoid this? – dwo Aug 17 '15 at 14:31