I don’t use vim very often, but when I do it would be handy to have some syntax highlighting. Over on Google+, Vincent Knight shared a link to a post on Geekology that describes how to turn on syntax highlighting and autoindenting for vim on a Mac. Here is a summary.

Open the Terminal and type the following commands.

cd /usr/share/vim
sudo vim vimrc

Press the i key and then paste the following lines of code just below the set backspace=2 line:

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

Lastly, type Esc followed by :x. That’s it!

Dana C. Ernst

Mathematics & Teaching

  Northern Arizona University
  Flagstaff, AZ
  Google Scholar
  Impact Story

Current Courses

  MAT 431: Intro to Analysis
  MAT 526: Combinatorics

About This Site

  This website was created using GitHub Pages and Jekyll together with Twitter Bootstrap.

  Unless stated otherwise, content on this site is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.

  The views expressed on this site are my own and are not necessarily shared by my employer Northern Arizona University.

  The source code is on GitHub.

Land Acknowledgement

  Flagstaff and NAU sit at the base of the San Francisco Peaks, on homelands sacred to Native Americans throughout the region. The Peaks, which includes Humphreys Peak (12,633 feet), the highest point in Arizona, have religious significance to several Native American tribes. In particular, the Peaks form the Diné (Navajo) sacred mountain of the west, called Dook'o'oosłííd, which means "the summit that never melts". The Hopi name for the Peaks is Nuva'tukya'ovi, which translates to "place-of-snow-on-the-very-top". The land in the the area surrounding Flagstaff is the ancestral homeland of the Hopi, Ndee/Nnēē (Western Apache), Yavapai, A:shiwi (Zuni Pueblo), and Diné (Navajo). We honor their past, present, and future generations, who have lived here for millennia and will forever call this place home.