Skip to content

@balinterdi /mvim_patch_tabs
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
diff --git a/src/MacVim/mvim b/src/MacVim/mvim
index 653cf78..5e6b0d7 100755
--- a/src/MacVim/mvim
+++ b/src/MacVim/mvim
@@ -13,6 +13,11 @@
# or by un-commenting and editing the following line:
# VIM_APP_DIR=/Applications
+tabs=true
+if [ "$1" = "-f" ]; then
+ tabs=false
+fi
+
if [ -z "$VIM_APP_DIR" ]
then
myDir="`dirname "$0"`"
@@ -36,7 +41,7 @@ binary="$VIM_APP_DIR/MacVim.app/Contents/MacOS/Vim"
name="`basename "$0"`"
gui=
-opts=
+opts="-n"
# GUI mode, implies forking
case "$name" in m*|g*|rm*|rg*) gui=true ;; esac
@@ -62,11 +67,23 @@ esac
# 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:+"$@"}
+ if $tabs && [[ `$binary --serverlist` = "VIM" ]]; then
+ if [ $# -eq 0 ]; then
+ exec "$binary" -g $opts --remote-tab-silent +edit .
+ else
+ exec "$binary" -g $opts --remote-tab-silent ${1:+"$@"}
+ fi
+ else
+ # 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.
+ if [ $# -eq 0 ]; then
+ exec "$binary" -g $opts .
+ else
+ exec "$binary" -g $opts ${1:+"$@"}
+ fi
+ fi
else
exec "$binary" $opts ${1:+"$@"}
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.