Updating VIM

Discussion in 'Mac Programming' started by Mac Player, Jun 6, 2007.

  1. Mac Player macrumors regular

    Joined:
    Jan 19, 2006
    #1
    Hi

    Is there a way to update VIM 6.2 that comes with Tiger?
     
  2. iMeowbot macrumors G3

    iMeowbot

    Joined:
    Aug 30, 2003
    #2
    It's probably a good idea to leave the stock vim alone, because OS X updates may want to overwrite it with the official Apple release.

    instead, make a /usr/local/bin or similar, prepend that to your path, and put your custom copy there.

    You can get a reasonably up-to-date vim from http://macvim.org/OSX

    Make a symlink or copy of the included gvim script to vim if you want it to work inside Terminal, see the script and the readme for other things you can do.
     
  3. Mac Player thread starter macrumors regular

    Joined:
    Jan 19, 2006
    #3
    Thanks.

    I compiled the latest source of VIM, moved it to the Applications folder and added gvim to the local path.

    However when i type gvim in the terminal it opens VIM instead of running in the terminal. :(
     
  4. plinden macrumors 68040

    plinden

    Joined:
    Apr 8, 2004
    #4
    I'm not quite sure what you want here. gvim won't run in the Terminal. It always opens a separate window (gvim is gui vim). vim is the non-gui terminal version.
     
  5. Mac Player thread starter macrumors regular

    Joined:
    Jan 19, 2006
    #5
    I just want the vim command to use an updated version of vim.
     
  6. plinden macrumors 68040

    plinden

    Joined:
    Apr 8, 2004
    #6
    Ok, so you type vim in Terminal, exactly what happens?

    You type gvim in Terminal, exactly what happens?

    What are the version strings displayed in each case?

    What's displayed when you type "which vim"?

    What's displayed when you type "which gvim"?

    Have you updated or replaced the gvim script to point to the new Vim.app?
     
  7. iMeowbot macrumors G3

    iMeowbot

    Joined:
    Aug 30, 2003
    #7
    that's expected. The gvim script included with the MacVIM (that's the one you're using, right?) does different things depending on what name you give it on the command line.

    So, you can copy or rename the gvim script to vim, or if you prefer, make a symlink named vim pointing to the gvim script, to get it to run inside the terminal.

    Also, make sure that the location of "your" vim shows up earlier in your path than the stock Apple build.
     
  8. Mac Player thread starter macrumors regular

    Joined:
    Jan 19, 2006
    #8
    Plidem:
    vim is on the glogal path.
    /usr/bin/vim
    gvim is on the local path.
    /usr/local/bin/gvim

    iMeowbot:
    I renamed the file and still no cookie :( i guess the global path takes priority over the local path...

    BTW: as you all guessed im an IDE noob.
     
  9. plinden macrumors 68040

    plinden

    Joined:
    Apr 8, 2004
    #9
    No, the one that comes first in the PATH takes precedence - there's no such thing as "global" or "local" path. What's the result of typing in Terminal:
    Code:
    echo $PATH
    But I still don't know if you want to use vim (ie. it loads in the Terminal you're currently using) or gvim (ie. it opens in a separate window). Which one do you want?

    Also, it doesn't really matter where the files are, as long as it loads the new Vim.app. So, please, when you type "gvim" in Terminal, what's the version? And when you type "vim" what's the version?

    "gvim" is a script that does some application lookups to find which vim to load. If you view /usr/local/bin/gvim, you should see a line like:
    Code:
    # First, check "All the Usual Suspects" for the location of the Vim.app
    # bundle.  You can short-circuit this by setting the VIM_APP_DIR environment
    # variable or by un-commenting and editing the following line:
    # VIM_APP_DIR=/Applications
    
    If you uncomment that last line, the gvim script will look inside /Applications for Vim.app so you'll get the latest version. But this loads gvim in a separate window. Which I don't know if you want.

    By the way, when I type vim in Terminal, I get version 6.2, but if I type gvim, I get version 7.0. I always use gvim so I didn't bother trying to set up vim.
     
  10. Mac Player thread starter macrumors regular

    Joined:
    Jan 19, 2006
    #10
    Thanks.

    I want to load Vim 7.1.2 in the terminal

    gvim points to the app folder where i have version 7.1.2 (but opens it on a new window) and vim goes to vim 6.2.
     
  11. davechen macrumors member

    Joined:
    Jul 19, 2002
    Location:
    Bethesda, MD
    #11
    I just aliased vim to /Applications/Vim.app/Contents/MacOS/Vim, which I compiled and installed from source. Because argv[0] is vim, it knows to run in the terminal instead of as a separate application.
     
  12. Mac Player thread starter macrumors regular

    Joined:
    Jan 19, 2006
    #12
    That means u replaced vim in the usr/bin folder?

    I tried to add an alias with a nome other than vim pointing to /Applications/Vim.app/Contents/MacOS/Vim but when i run the command terminal shows permission dennied.
     
  13. yellow Moderator emeritus

    yellow

    Joined:
    Oct 21, 2003
    Location:
    Portland, OR
    #13
    Make an alias in your profile that points at the vim you want to use. ;)

    Ooops, you already did that.

    Make sure it's executable?
     
  14. Mac Player thread starter macrumors regular

    Joined:
    Jan 19, 2006
    #14
    It is executable.

    If this is relevant: i created th alias with the finder.

    Im currently using iTerm bookmarks to open vim. But of course i can't open files from the terminal that way.
     
  15. iMeowbot macrumors G3

    iMeowbot

    Joined:
    Aug 30, 2003
    #15
    Yeah, that is relevant. While symbolic links look just like aliases when viewed in the Finder, aliases created through the Finder are not symlinks.

    To get what you need, delete that alias, then (from Terminal):

    Code:
    cd /wherever/the/gvim/script/lives
    ln -s gvim vim
    
    (may need sudo for that, depending on where you put stuff)
     
  16. davechen macrumors member

    Joined:
    Jul 19, 2002
    Location:
    Bethesda, MD
    #16
    No, I created a shell alias. I guess I wasn't specific enough. So in my .tcshrc files, there's a command "alias vim /Applications/Vim.app/Contents/MacOS/Vim". I'm not sure what the equivalent command would be in bash.
     
  17. yellow Moderator emeritus

    yellow

    Joined:
    Oct 21, 2003
    Location:
    Portland, OR
    #17
    Yes, that's the alias I was referring to as well. THough I finally extricatred myself from tcsh last month. My office Mac was the final bastion! :)
     
  18. Mac Player thread starter macrumors regular

    Joined:
    Jan 19, 2006
    #18
    I made the symlink placed it on usr/local/bin but the terminal still uses the original vim.
     
  19. davechen macrumors member

    Joined:
    Jul 19, 2002
    Location:
    Bethesda, MD
    #19
    What does your PATH environment variable look like? Type the command "printenv PATH"
     
  20. Mac Player thread starter macrumors regular

    Joined:
    Jan 19, 2006
    #20
    /sw/bin:/sw/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/teTeX/bin/powerpc-apple-darwin-current:/usr/X11R6/bin
     
  21. davechen macrumors member

    Joined:
    Jul 19, 2002
    Location:
    Bethesda, MD
    #21
    /usr/bin is ahead of /usr/local/bin, so it's finding the 6.3 version of vim before it finds your local one. you need to put /usr/local/bin ahead of /usr/bin. Or you can do the alias thing.
     
  22. Mac Player thread starter macrumors regular

    Joined:
    Jan 19, 2006
    #22
    How do i do that?
     
  23. davechen macrumors member

    Joined:
    Jul 19, 2002
    Location:
    Bethesda, MD
    #23
    Where is your PATH getting set? Do you have any files like .bashrc, .bash_profile or .profile in your home directory?

    By default, the file /etc/profile gets read and that sets up an initial path, but it looks like you have more than that in your path. The /sw stuff comes from fink, I think.

    Anyways you could create a simple .bash_profile in your home directory. It'd look like this:

    PATH="/sw/bin:/sw/sbin:/bin:/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/usr/local/teTeX/bin/powerpc-apple-darwin-current:/usr/X11R6/bin"
    export PATH
     
  24. mikelikespie macrumors newbie

    Joined:
    Jun 4, 2007
    #24
    MacPorts has it. It also has Vim.app (which is GVim). Both work really well. I highly recommend MacPorts. It's also great for other Unix utilities such as irssi, other versions of GCC, updated Ruby, etc, etc. It puts all the new binaries in /opt/local/bin so you just put that path in front of your standard one and it will use the new utilities.

    edit:
    And if you install the .app with ports, it will run the gui version with the command gvim from the terminal.
     

Share This Page