Open one window only with `mvim`

103 views
Skip to first unread message

Normen Müller

unread,
Mar 4, 2014, 1:14:49 PM3/4/14
to vim...@googlegroups.com
Hi,

I am not sure if this belongs to this list but I'll give it try, maybe one here knows the solution.

I am using MacVim with one window only. Switching buffers with `:ls`, `:b <number>`, or just `:b#`.

But when opening MacVim from a Terminal, the command `mvim <file>` opens for each file a new window. But I want it to reuse the existing one and just to open a new buffer within this window.

Maybe it's just a minor modification to the `mvim` script, or a startup option of MacVim. Anyway, I couldn't find the solution. Any suggestion?

Best, /nm

P.S. My `mvim` script:

#----------------------------------------------------------------------------
#!/bin/sh

if [ -z "$VIM_APP_DIR" ]
then
myDir="`dirname "$0"`"
myAppDir="$myDir/../Applications"
for i in ~/Applications ~/Applications/vim $myDir $myDir/vim $myAppDir $myAppDir/vim /Applications /Applications/vim /Applications/Utilities /Applications/Utilities/vim; do
if [ -x "$i/MacVim.app" ]; then
VIM_APP_DIR="$i"
break
fi
done
fi
if [ -z "$VIM_APP_DIR" ]
then
echo "Sorry, cannot find MacVim.app. Try setting the VIM_APP_DIR environment variable to the directory containing MacVim.app."
exit 1
fi
binary="$VIM_APP_DIR/MacVim.app/Contents/MacOS/Vim"

# Next, peek at the name used to invoke this script, and set options
# accordingly.

name="`basename "$0"`"
gui=
opts=

# GUI mode, implies forking
case "$name" in m*|g*|rm*|rg*) gui=true ;; esac

# Restricted mode
case "$name" in r*) opts="$opts -Z";; esac

# vimdiff, view, and ex mode
case "$name" in
*vimdiff)
opts="$opts -dO"
;;
*view)
opts="$opts -R"
;;
*ex)
opts="$opts -e"
;;
esac

# Last step: fire up vim.
# The program should fork by default when started in GUI mode, but it does
# not; we work around this when this script is invoked as "gvim" or "rgview"
# etc., but not when it is invoked as "vim -g".
if [ "$gui" ]; then
# Note: this isn't perfect, because any error output goes to the
# terminal instead of the console log.
# But if you use open instead, you will need to fully qualify the
# path names for any filenames you specify, which is hard.
exec "$binary" -g $opts ${1:+"$@"}
else
exec "$binary" $opts ${1:+"$@"}
fi
#----------------------------------------------------------------------------

Normen Müller

unread,
Mar 4, 2014, 11:45:14 PM3/4/14
to vim...@googlegroups.com

Mohit Sharma

unread,
Mar 4, 2014, 6:31:22 PM3/4/14
to vim...@googlegroups.com
On Tue, Mar 4, 2014 at 10:14 AM, Normen Müller <normen....@gmail.com> wrote:
Hi,

I am not sure if this belongs to this list but I'll give it try, maybe one here knows the solution.

I am using MacVim with one window only. Switching buffers with `:ls`, `:b <number>`, or just `:b#`.

But when opening MacVim from a Terminal, the command `mvim <file>` opens  for each file a new window. But I want it to reuse the existing one  and just to open a new buffer within this window.

Maybe it's just a minor modification to the `mvim` script, or a startup option of MacVim. Anyway, I couldn't find the solution. Any suggestion?

I'm not sure if there is an option to open it up in a buffer but you can use the --remote-tab option to open the file in another tab of already opened MacVim application.
 

--
--
You received this message from the "vim_mac" 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_mac" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_mac+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages