Created
October 16, 2014 12:56
-
-
Save leafgarland/f7a869091567aa08efc2 to your computer and use it in GitHub Desktop.
Powershell function to start GVim, making use of Vim's server features.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Start-Vim { | |
if (!$global:VimServerName) { | |
$global:VimServerName = 'GVIM' | |
} | |
if ($args) { | |
gvim.exe --servername $global:VimServerName --remote-silent $args | |
} else { | |
$servers = (vim.exe --noplugin -u NORC --serverlist) | ? { $_ -eq $global:VimServerName } | |
if ($servers) { | |
vim.exe --noplugin -u NORC -c "call remote_foreground('$global:VimServerName')" -c 'quit' | |
} else { | |
gvim.exe --servername $global:VimServerName | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This allows you to keep using the same instance of GVim from the command line. If you call it with no arguments it will either start a new instance of GVim or bring a running instance to the foreground.
Make sure to set a more convenient alias, e.g.
Set-Alias vi Start-Vim
.