Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Install a more powerful 'vi' editor UNIX
VIM ('Vi IMproved') is a replacement for vi that features a ton of enhancements, including colored syntax highlighting for a number of languages (Java, C/C++, HTML, PHP, PERL, etc) and the ability to save edited files as HTML with syntax colors. If you like using vi, you'll love VIM. Thanks to macosxhints reader jpzr, a friend from Poland, for the information on how to get this working! I followed his tips, tweaked a couple of things, and installed it with no problems.

Read the rest of this article if you'd like the step-by-step instructions on installing VIM for OS X. NOTE: You need to have the developer tools installed to compile VIM, and you should be fairly comfortable in the terminal ... then again, if you're using vi, you're probably quite comfortable in the terminal!

To compile VIM for OS X, follow these steps:
  1. Head to vim.org and download the following two archives:
    • vim-5.7-rt.tar.gz
    • vim-5.7-src.tar.gz
    There are a number of download mirrors, so take your pick.

  2. Once downloaded, expand the archives as follows:
    [robg]% gzip -d vim-5.7-rt.tar.gz
    [robg]% tar xvf vim-5.7-rt.tar
    [robg]% gzip -d vim-5.7-src.tar.gz
    [robg]% tar xvf vim-5.7-src.tar
    This will insure that everything winds up in the proper directories for the next steps.

  3. We need to edit one of the header files before compiling. Navigate to vim-5.7/src/ and open feature.h in your favorite editor. Look for the line that reads #define SOME_BUILTIN_TCAPS and change it to read #define ALL_BUILTIN_TCAPS. Save your changes.

  4. Now it's time to finish, with the normal compilation trifecta. Make sure you're in /path/to/vim-5.7, and then:
    [robg]% ./configure
    [robg]% make
    [robg]% sudo make install
  5. When it's finished, type rehash and you should be able to launch VIM by typing vim at the terminal prompt. The application is installed in /usr/local/bin by default, with support files in /usr/local/share/vim/vim57.

  6. To get color-coded syntax highlighting, launch VIM and then type:
    :set term=builtin_beos-ansi
    :syntax on
    If you'd like VIM to launch in this mode all the time, you'll need a .vimrc file in your home directory which contains those two lines (without the colons, since they're the VIM command prompt). The .vimrc can be quite complex, of course. Here's jpzr's actual file:
    set nocompatible
    source $VIMRUNTIME/vimrc_example.vim
    source $VIMRUNTIME/macros/explorer.vimĀ 
    set selectmode=mouse
    set backupdir=/tmp
    set directory=/tmp
    set guifont=Lucida_Console:h8
    set guioptions-=T
    set errorfile=/tmp/rutkowsk.errors.log
    set ic
    set grepprg=grep -n
    set fileformats=dos,unix,mac
    highlight StatusLineNC guifg=#ff0000 guibg=#000000
    highlight StatusLine guifg=#00ff00 guibg=#000000
    set hls
    hi Normal guibg=black guifg=white
    hi Search guibg=white guifg=black
    hi IncSearch guibg=white guifg=black
    set tags=./tags
    set mousef
    set term=builtin_beos-ansi
    syntax on
That's all there is to it -- you now have a powerful replacement for vi. The syntax highlighting looks best if you have a dark-colored terminal background, so experiment with your color settings.

jpzr has also let me know that VIM will probably be available soon as a full graphic application for OS X. Keep checking vim.org for updates!
    •    
  • Currently 3.75 / 5
  You rated: 5 / 5 (4 votes cast)
 
[84,691 views]  

Install a more powerful 'vi' editor | 9 comments | Create New Account
Click here to return to the 'Install a more powerful 'vi' editor' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Better URL, please?
Authored by: babbage on Apr 30, '01 11:38:29AM

I can't find a suitable URL here, whether on the vim.org page or on the ones that it points
to as mirrors. The only Mac version I can spot is an OS9 binary, which I don't want to
bother with reinstalling under OSX. (I didn't much care for it on OS9, nevermind classic :)

Thanks...



[ Reply to This | # ]
Here's one
Authored by: robg on Apr 30, '01 03:00:14PM
It's a bit tough to find, since the vim.org mirrors list appears fairly out-of-date. I just kept trying them until I found one that works. The following FTP server (as of today, anyway!) works and has both files you need on it:

ftp://ftp.ny.us.vim.org/pub/editors/vim/unix/

Look for the last two in the list, vim-5.7-rt.tar.gz and vim-5.7-src.tar.gz

-rob.

[ Reply to This | # ]
Here's one
Authored by: babbage on Apr 30, '01 07:12:47PM

Splendid. Thanks :)



[ Reply to This | # ]
Better URL, please?
Authored by: benji on Apr 07, '02 03:35:10PM

The new home page for vim is

http://vim.sourceforge.net/

and you can find pre-compiled versions for OS X (Terminal,
XDarwin, and Carbon) at

http://vim.sourceforge.net/download.php

I maintain the binaries for the Carbon version, which is
still somewhat buggy.



[ Reply to This | # ]
Better URL, please?
Authored by: ibcomputergeek on Apr 11, '03 04:02:06PM

I used fink ( http://fink.sourceforge.net/ ) to install vim, also used it for clisp(worked great). Also if you want color coding just make a .vimrc file containing the line:

set term=builtin_beos-ansi

Thats it hope it works for you.


---
/****************
Richard Cook
CSUSM
****************/



[ Reply to This | # ]
vim now included in 10.3 (Panther)
Authored by: Anonymous on Nov 13, '03 10:54:21PM

This hint is mostly obsolete as vim is now the built-in replacement for vi in 10.3 (Panther).

Note that it does NOT support the GUI mode, so if you want that you'll have to build your own.

Also, in robg's hint he says you need to do a

:set term=

along with

:syntax on

to get color syntax highlighting. The term command is not needed if your haven't changed the new 10.3 default for Terminal (xterm-color).

Enjoy!



[ Reply to This | # ]
vi replacement?
Authored by: spottycat on Dec 01, '03 07:04:43PM

I'd much prefer the version of vi shipped before Panther. I've tried elvis, and still would rather use the stock vi. Does anyone have a source for <10.3's vi?



[ Reply to This | # ]
Install a more powerful 'vi' editor
Authored by: whallify on Jul 25, '07 06:48:11AM
And now you can run vim on your iPhone

http://developers.slashdot.org/developers/07/07/25/1225242.shtml

---
--
Wayne
http://whall.org

[ Reply to This | # ]

Install a more powerful 'vi' editor
Authored by: mjcohen on Jul 25, '07 03:02:44PM

Just install AquaEmacs!



[ Reply to This | # ]