When I use vim newfilename
to open a file and this file does not exit, vim
will create a new file with the name newfilename
.
However, MacVim
does not work in this way --- i.e. mvim newfilename
(alias mvim="open -a macvim"
) will lead to an error: newfilename does not exist
Is there a way to configure MacVim
such that mvim newfilename
(alias mvim="open -a macvim"
) will create a new file and open it?
I'm guessing the error message comes from open
, not from vim
. You can replace your alias with a function;
mvim () {
local f
for f; do
test -e "$f" || touch "$f"
done
open -a macvim "$@"
}
This will create empty files if necessary before opening them.
edit Didn't see @Peter Lyons' comment about this; credit should go to him for first suggesting this solution. I'll be happy to remove this answer if Peter wants to submit his.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With