0

When I run mvim . it opens NERDTree but doesnt open a new file/buffer.

  1. How might I accomplish this? Ideally when you type mvim . from terminal it would open MacVim, close NERDtree, and open a new buffer

  2. 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?

pb2q
  • 58,613
  • 19
  • 146
  • 147
Tallboy
  • 12,847
  • 13
  • 82
  • 173

2 Answers2

2

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.

pb2q
  • 58,613
  • 19
  • 146
  • 147
1

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'
sidyll
  • 57,726
  • 14
  • 108
  • 151
  • mainly so that when i open nerdtree its already in the correct project folder – Tallboy Aug 09 '12 at 15:26
  • @Tallboy, but when you start vim, it inherits the current directory, right? So you wouldn't need to give that argument – sidyll Aug 09 '12 at 15:37