You can lend your vi an extra sex appeal, just by tweaking some values in its configuration file, vimrc (usually located in /etc):
Syntax highlighting:
" enable syntax highlighting
so ${VIMRUNTIME}/syntax/syntax.vim
|
Having enabled syntax highlighting, you will often find yourself trying hard to find out what is written on your screen, unless you are working on the console, or the background colour of your X terminal is black. Mine is grey (or red, for root), which makes the colourful text hard to read. In this case, you need to start vi in an xterm with black as the background colour. Save the following one-liner in /usr/local/bin/bt (bt for Black Terminal...):
xterm -bg black -fg white -geometry 120x60 -e vi $1 & |
make it executable (chmod ugo+x /usr/local/bin/bt) and from now on, just do
bt filename |
Set multiple search: MultipleSearch allows you to have the results of multiple searches displayed on the screen at the same time. Each search highlights its results in a different color, and all searches are displayed at once. After the maximum number of colors is used, the script starts over with the first color. The command syntax is
:Search <pattern1> |
which will highlight all occurrences of <pattern1> in the current buffer. A subsequent
:Search <pattern2> |
will highlight all occurrences of <pattern2> in the current buffer, retaining the highlighting of <pattern1> as well. <pattern1> and <pattern2> are any search pattern like you would use in a normal /<pattern> search.
You enable Multiple Search with the following lines in the vimrc file:
" enable MultipleSearch functionality (extra module)
so ${VIMRUNTIME}/MultipleSearch.vim
|
Further, you will have to copy the MultipleSearch.vim file from the scripts collection at www.vim.org into your local plugins directory (/usr/share/vim/current on my system) and restart vi.
Set smartcase, incsearch, scrolloff, wildmode
![]() |
Be careful: |
|---|---|
|
No spaces between the options! See "longest,list" below - if you write "longest, list" you will get $ signs at the end of every line and the tabs will be shown as "^I "! |
set smartcase set incsearch set scrolloff=2 set wildmode=longest,list |
For those of you who are working in the SAP® field: there is an ABAP/4® syntax highlighting script fo vi available at vim's Sourceforge page. Copy the abap.vim file into your local syntax plugins directory (/usr/share/vim/current/syntax on my system) and restart vi. Happy ABAP/4® hacking!
For more vi tips see http://www.vim.org/tips/index.php.