How to enable syntax highlighting and other options in VIM

来源:互联网 发布:java ant zip 编辑:程序博客网 时间:2024/06/04 17:45

http://geekology.co.za/article/2009/03/how-to-enable-syntax-highlighting-and-other-options-in-vim


How to enable syntax highlighting and other options in vim

10 Mar 2009

Vim is a popular command line text editor with an interface that is based not on menus or icons but on commands given in a text user interface.

Unfortunately the vim that ships with Mac OS X 10.5.* (Leopard) doesn't have an optimized configuration file to allow forsyntax highlighting, auto indentation, etc.

To fix this, open a new Terminal window and enter these commands to openvim's configuration file:

cd /usr/share/vimsudo vim vimrc

Press the "i" key to switch vim to Insertion Mode, then enter these lines below the "set backspace=2" line:

set ai                  " auto indentingset history=100         " keep 100 lines of historyset ruler               " show the cursor positionsyntax on               " syntax highlightingset hlsearch            " highlight the last searched termfiletype plugin on      " use the file type plugins" When editing a file, always jump to the last cursor positionautocmd BufReadPost *\ if ! exists("g:leave_my_cursor_position_alone") |\ if line("'\"") > 0 && line ("'\"") <= line("$") |\ exe "normal g'\"" |\ endif |\ endif

Press the Escape key to take vim out of Insertion Mode, then press ":" (colon) followed by "x" to save the file and exit. Enter this command again:

sudo vim vimrc

... and you'll see that vim now automatically indents code, displays thecursor position, has syntax highlighting, etc.


0 0
原创粉丝点击