---
title: "Vim Tips"
author: "wangxe"
date: "2009-11-06T12:01:15Z"
tags: []
slug: "vim-tips"
draft: false
lastmod: "2009-11-06T12:01:42Z"
id: 511262
url: "https://wangxe.iteye.com/blog/511262"
---

\* .vimrc example

    " Use Vim settings, rather then Vi settings (much better!).  
    " This must be first, because it changes other options as a side effect.  
    set nocompatible

    " set indent for c and cpp  
    set cindent   
    set shiftwidth=4  
     
    " set the space number of a tab  
    set tabstop=4  
     
    " make tab convert to space.  
    set expandtab  
     
    " enable syntax highlight  
    syntax on  
     
    " set the color scheme to 'sand'  
    colo sand  
     
    " increament search  
    set incsearch  
     
    " highlight search by manual  
    set hls   
    set hlsearch  
    nohls

    " allow backspacing over everything in insert mode  
    set backspace=indent,eol,start  
     
    " showing matches when type ')', ']', '}'  
    set showmatch  
    set matchtime=1

    " key maping  
    " keys in insert/command mode  
    "map! ^[[H &lt;Home&gt;  
     
    "To the first non-blank character of the line.  
    map! ^[[H ^[^i  
    map ^[[H ^  
    "map! ^[OH &lt;Home&gt;  
     
    map! &lt;Esc&gt;[F &lt;End&gt;  
    map &lt;Esc&gt;[F &lt;End&gt;  
    "map! &lt;Esc&gt;OF &lt;End&gt;  
     
    map! &lt;Esc&gt;[3~ &lt;Delete&gt;  
    "map! &lt;Esc&gt;OE &lt;Space&gt;  
     
    " set &lt;Delete&gt; to delete a char under the cursor.  
    imap ^? &lt;Del&gt;  
     
\* 更换color scheme  
    在/usr/local/share/vim/vim62/colors下，vim预设很多schemes。

    创建~/.vim/colors目录，  
    放入mycolor.vim，  
    在.vimrc中加入 colo mycolor

\* 更换syntax file  
    在/usr/local/share/vim/vim62/syntax下，vim预设很多schemes。

    创建~/.vim/syntax目录，  
    放入mysyntax.vim，  
    在.vimrc中加入 set syntax=mysyntax  
   

常用命令:

auto complete  
    &lt;C-p&gt; &lt;C-n&gt;

ma:      Make a bookmark named a at the current cursor position.  
        A bookmark can be named any lowercase letter.  
        You can't see the bookmark, but it's there!  
     
\`a:     Go to bookmark a. Important: that's a backtick, not a single quote.  
        The backtick is located to the left of the 1 on most keyboards.  
         
\`.:     Go to the line that you last edited. This is very useful!  
        If you need to scroll through the file to look something up,  
        you can go back to where you were without bookmarking it by using the \`. command.  
         
*      Read the string under the cursor and go to the next place it appears.  
    (For instance, if your cursor was somewhere on the word "bob," the cursor  
    would move to the next occurance of "bob" in your file.)  
     
\#     Same as above, except it moves the cursor to the previous occurance.