Reputation: 13417
When I run mvim .
it opens NERDTree but doesnt open a new file/buffer.
How might I accomplish this? Ideally when you type mvim .
from terminal it would open MacVim, close NERDtree, and open a new buffer
I'm not sure if this is possible but is there a way that if I run mvim .
from the command line multiple times it wouldn't open vim in a new window each time?
Upvotes: 0
Views: 214
Reputation: 59287
1.You are asking it to open your directory viewer, right? If not, why do you start vim passing the current directory (.
) as argument? Leave it off and it will start with an empty buffer.
$ mvim
2.Take a look in the vim manual (man vim
). You probably want the --remote-silent
option.
$ mvim --remote-silent file
I personally use this so often that I've created an alias for it in my .profile:
alias v='mvim --remote-silent'
Upvotes: 1
Reputation: 59617
As for your second question, vim allows you to send a file to an already running instance with --remote
arguments, if vim is compiled with +clientserver
. MacVim should be - if :echo has("clientserver")
prints 1
in the command-line, then this should work. This will work for any vim compiled with +clientserver
, including vim running within a terminal window.
When vim is using clientserver
you can run mvim so that it sends the new file(s) to an already-running instance of vim, e.g.:
$ mvim --remote-silent file2.txt
Make an alias for mvim
that always passes --remote-silent
.
See :help remote
for more details.
Upvotes: 2