Nov 24 2008

Making Vim Suck Less on Mac OSX

I have been a 1/2 time Ubuntu, 1/2 time OS X user for about a year.  While I generally liked Ubuntu, it was a drag not to be able to use my favorite programs such as TextMate and Adobe CS3.  So, I’ve made the jump to being a full-time Mac fan-boy. 

I’m still irritated that I can’t scroll my mouse up and down in the document, however I find that dumping the Mac Terminal for iTerm is a good start.

Now, the syntax highlighting is a pain.  I typically use:

mate 

To open my files in Textmate, but sometimes it’s just quicker to edit in VIM.  To turn syntax highlighting on, open Terminal or iTerm, and type:

vim .bash_profile 

and add:

alias ll='ls -lha'

source ~/.bashrc 

then press “esc” then “:wq”.

I’m lazy, and I like “ll” in terminal to be the same as ls -lha, which the alias above accomplishes. 

now:

$vim .bashrc 

And add:

export TERM=xterm-color
export GREP_OPTIONS
='--color=auto' GREP_COLOR='1;32'
export CLICOLOR=1
alias ls
='ls -G'
export COLOR_NC='\e[0m' # No Color
export COLOR_WHITE='\e[1;37m'
export COLOR_BLACK='\e[0;30m'
export COLOR_BLUE='\e[0;34m'
export COLOR_LIGHT_BLUE='\e[1;34m'
export COLOR_GREEN='\e[0;32m'
export COLOR_LIGHT_GREEN='\e[1;32m'
export COLOR_CYAN='\e[0;36m'
export COLOR_LIGHT_CYAN='\e[1;36m'
export COLOR_RED='\e[0;31m'
export COLOR_LIGHT_RED='\e[1;31m'
export COLOR_PURPLE='\e[0;35m'
export COLOR_LIGHT_PURPLE='\e[1;35m'
export COLOR_BROWN='\e[0;33m'
export COLOR_YELLOW='\e[1;33m'
export COLOR_GRAY='\e[1;30m'
export COLOR_LIGHT_GRAY='\e[0;37m'
alias colorslist="set | egrep 'COLOR_\w*'" 

then press “esc” then “:wq”.

then

vim .vimrc 

In that new file, add:

if has("terminfo")
  
set t_Co=16
  set t_AB
=^[[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{92}%+%;%dm
  set t_AF
=^[[%?%p1%{8}%<%t%p1%{30}%+%e%p1%{82}%+%;%dm
else
  
set t_Co=16
  set t_Sf
=^[[3%dm
  set t_Sb
=^[[4%dm
endif

syntax on 

then press “esc” then “:wq”.

Close your terminal window, and now you will have pretty syntax highlighting.  grin


Post a Comment





Submit the word you see below: