is there a way to start MacVim from the command line? I usually start
gvim from Terminal.app; usually with several flags. Simplest use case
is `gvim filename` which works by symlinking gvim to MacVim.app/
Contents/MacOS/MacVim, but only if 'filename' already exists.
Furthermore, I often do `gvim -S session.vim` to launch vim with a
set of files. This doesn't seem to work at all.
It'd be great if there was some kind of shell script that opens a new
MacVim window and passes all parameters to the Vim instance that
belongs to that window. Is there something like that? If not, how
would I write something like that?
Thanks,
Nico
alias gvim= MacVim.app /Contents/MacOS/Vim -g
does that not work for you?
Bah, readme files :-P Kinda works (modulo whitespace escaping ("..Vim
\ -g"), but I have a session file that doesn't finish loading until I
hit some keys (doesn't work if I load the session with the toolbar
button or `:source`, but works fine in carbon vim). "Doesn't finish
loading" means that nothing is drawn and that only two tabs are
displayed although the session contains five tabs. After I hit 'j',
everything is fine though.
Another small (unrelated) bug: Toggle the toolbar off, maximize the
window, toggle toolbar back on -- now the first few lines are drawn
below the toolbar.
And a suggestion: Clicking the toolbar toggle button in the upper
right corner should update the 't' flag in guioptions (without that,
clicking the button to hide the toolbar and doing 'set guioptions+=t'
doesn't work for example).
Nico
> In the readme I suggest the following alias
> alias gvim=MacVim.app /Contents/MacOS/Vim -g
> does that not work for you?
Bah, readme files :-P Kinda works (modulo whitespace escaping ("..Vim
\ -g"), but I have a session file that doesn't finish loading until I
hit some keys (doesn't work if I load the session with the toolbar
button or `:source`, but works fine in carbon vim). "Doesn't finish
loading" means that nothing is drawn and that only two tabs are
displayed although the session contains five tabs. After I hit 'j',
everything is fine though.
Another small (unrelated) bug: Toggle the toolbar off, maximize the
window, toggle toolbar back on -- now the first few lines are drawn
below the toolbar.
And a suggestion: Clicking the toolbar toggle button in the upper
right corner should update the 't' flag in guioptions (without that,
clicking the button to hide the toolbar and doing 'set guioptions+=t'
doesn't work for example).
I think it's better to have a shell script file called 'gvim' or
'mvim' or whatever that contains the command above. That way, the vim
instance stays open if you close terminal.app. With the alias, macvim
closes when its parent shell is closed.
No, but bash needs it. If you do
alias bla=ls -l
you get
-bash: alias: -l: not found
You need
alias bla=ls\ -l
or
alias bla="ls -l"
Mac OS X has a well-documented command "open" that is specifically
designed for launching Mac OS X applications from the command line:
open -a /Applications/MacVim.app file.txt
The downside is that it doesn't allow you to specify vim command-line
options, so I don't use it. It's fine for opening files with the
default options (open one or more files into buffers, with the first
file's buffer active on open).
As a result, I use a variation on Björn's suggestion: In general, I
find that bash functions work better than aliases because they allow
you to use several distinct command-line parameters. Thus:
function gvim { /Applications/MacVim.app/Contents/MacOS/Vim -g $*; }
With that function, you can specify Vim command-line parameters as well
as any file(s) to be edited:
gvim -d firstfile.txt secondfile.txt
Also, I don't have any problem with vim quitting when I quit the
terminal session, but I also don't remember if I haven't done
something else to prevent that. YMMV.
Dave