Enable syntax highlighting in Vim or Vi on Mac
I rarely have to use mac OSX Vim for file editing, I usually ssh into remote machines which run ubuntu server or CentOS and there I’ve vim configured for syntax highlighting and other goodies.
But few times that I use Vim on mac, it makes my head hurt, no syntax highlighting by default? really?
To fix this you can do this:
1 |
sudo vi /usr/share/vim/vimrc |
Press the “i” key to switch vim to Insertion Mode, then enter these lines below the “set backspace=2” line:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
set ai " auto indenting set history=100 " keep 100 lines of history set ruler " show the cursor position syntax on " syntax highlighting set hlsearch " highlight the last searched term filetype plugin on " use the file type plugins " When editing a file, always jump to the last cursor position autocmd BufReadPost * \ if ! exists("g:leave_my_cursor_position_alone") | \ if line("'\"") > 0 && line ("'\"") <= line("$") | \ exe "normal g'\"" | \ endif | \ endif |
Than press ESC, :x. And try sudo vi /usr/share/vim/vimrc again. You will see colors and your eyes will thank you.
Leave a Reply