Sunday, December 29, 2013

A script to handle `Argument missing after: --remote-silent`

I wanted to set up Vim to run in `--remote-silent` by default (got the idea from Derek Wyatt's videos), and a simple `alias mvim='mvim --remote-silent'` in my bash_profile worked until I tried running `mvim` without any arguments.

I chased my tail on this for a while, but finally came up with a working solution. Thought I'd share, in case anyone else finds this useful or has suggestions/improvements. From my bash_profile:

function ivim {
if [ -n "$1" ] ; then
command mvim --remote-silent "$@"
elif [ -n "$( mvim --serverlist )" ] ; then
command mvim --remote-send ":call foreground()<CR>:enew<CR>:<BS>"
else
command mvim
fi
}

If an argument is passed, it calls remote-silent with the passed arguments. Otherwise, it checks for already running Vim servers and if any exist, calls remote-send. If none exist, it simply calls mvim.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment