using vi, vim, gvim etc..

I’m pretty new to unity, and overall having a good deal of fun with it. As of now I have around ~100 hrs in it, and I thought since I’m enjoying it so much I’d see what other people are doing, if any, in reference to using vim in a windows setting with Unity.

For now I’m just housing my working copies on a samba share and just using SSH into a linux box that also has access to the share for all the console magic, this works well enough for me. Occasionally I’ll use mono with VI mode but I find it lacks a few things my finger-foo is accustomed to so anything beyond quick fixes is more tedious then just just using ssh.

I’m just curious if anyone has had any success using gvim, or cygwin. It’d be nice to be able to have all the cli goodies I like (vim, version control, grep, ftp etc…) and still be able to open a script from inside unity especially for the script debugging. Getting unity to open cygwin, and vim.nox might be pretty neat, that way bash shell could be available.

If anyone has any Ideas I’m all ears. (although a linux client would be great!! I haven’t had any luck with wine).

I’ve used vim on OSX to make quick fixes when I’m pushing out iOS builds, but otherwise I’m a bit too entrenched in Visual Studio to really want to use anything else

Mac’s look more and more viable everyday (I was actually blown away by how many I saw as OSCON this year).

I found this link and I have no idea if compiling something new and replacing UniSciTE.exe with it is still viable since it’s obviously not the packaged tool any longer (as far as I can tell). I’ll play with it and see if it works once I wrap up my current tutorials. If I figure something out I’ll contribute back here, and to the guys/gals from the old threads.

http://forum.unity3d.com/threads/37339-Howto-use-gVim-with-Unity

From my tests, which I’ve only taken about 10 minutes to experiment with, it seems you can either have a reusable vim window, or access to cli tools, but not both.

If you are fine with gVim on Windows, just do the following:

  • Edit->Preferences->External Tools
  • Browse for your gVim executable
  • External Script Editor Args: --remote-tab-silent +(Line) "(File)"

Alternatively, for cli tools, you can get it to work with cygwin, but it opens a new instance every time. So if you are ok with that, edit a file named unityVim.cmd with this code, taken from here

@echo off
setlocal
 
if not exist "%~dpn0.sh" echo Script "%~dpn0.sh" not found  exit 2
 
set _CYGBIN=C:\cygwin\bin
if not exist "%_CYGBIN%" echo Couldn't find Cygwin at "%_CYGBIN%"  exit 3
 
:: Resolve ___.sh to /cygdrive based *nix path and store in %_CYGSCRIPT%
for /f "delims=" %%A in ('%_CYGBIN%\cygpath.exe "%~dpn0.sh"') do set _CYGSCRIPT=%%A
 
:: Throw away temporary env vars and invoke script, passing any args that were passed to us
endlocal  %_CYGBIN%\bash --login "%_CYGSCRIPT%" %*

And then edit a file named unityVim.sh with this code

vim $1 $2 "$3"

The important part is that the .cmd and the .sh have the same name, and are in the same folder.

Finally

  • Edit->Preferences->External Tools
  • Browse for unityVim.cmd
  • External Script Editor Args: --remote-tab-silent +(Line) "(File)"

I hope this helps somebody someday :sunglasses:

1 Like

Just posted a new thread re: vim + Unity (with a link to info about my setup) here.