May 19, 2008

我的 Vim 环境设置

为了保证知识的连续性,所以我选择了vim。并且慢慢的开始习惯。。。但是这样也带来一个后果,就是总是在编辑的时候想按<esc>或者<i>来切换命令和编辑模式。:)

我的配置文件还是有一些个人特色的,毕竟被Windows侵蚀多年,有些习惯还不是一时半会能改过来的,所以就把Windows上的一些编辑快捷键也加入进来了。

    "
    " Simplify settings for VIM 7.x or later
    "
    " Copyright (c) 2008, 2009 Tairan Wang All Rights Reserved.
    "
    " Tairan Wang <tairan.wang(at)gmail.com>
    "
    " $Id: vimrc 38 2009-02-06 03:16:59Z Tairan.Wang $
    "

    """"""""""""""""""""""""""""""""""""""""""""""""""""""
    " General
    """"""""""""""""""""""""""""""""""""""""""""""""""""""
    " Get out of VI's compatibale mode.

    set nocompatible

    " Set how many lines of history VIM har to remember

    set history=400

    " Enable filetype plugin

    filetype plugin on

    filetype indent on

    " Set to auto read when a file is changed from the outside

    set autoread

    " Have the mouse enabled all the time:

    set mouse=a

    " Reset the menu languge.

    source $VIMRUNTIME/delmenu.vim

    set langmenu=none

    source $VIMRUNTIME/menu.vim

    """"""""""""""""""""""""""""""""""""""""""""""""""""""
    " Fileformats
    """"""""""""""""""""""""""""""""""""""""""""""""""""""

    set encoding=utf-8

    set fileencoding=utf-8
    " Favorite filetype
    " set fileencodings=ucs-bom,utf-8,gbk,big5

    set fileencodings=utf-8,gbk,big5

    " Compatible windows notepad mode

    source $VIMRUNTIME/mswin.vim

    behave mswin

    """"""""""""""""""""""""""""""""""""""""""""""""""""""
    " Color and Fonts
    """"""""""""""""""""""""""""""""""""""""""""""""""""""
    " Enable syntax heightlight

    syntax enable

    syntax on



    set cursorline

    """"""""""""""""""""""""""""""""""""""""""""""""""""""
    " Indent
    """"""""""""""""""""""""""""""""""""""""""""""""""""""
    " C-style indeting

    set cindent
    " Auto indent

    set autoindent
    " Smart indent

    set smartindent
    " Wrap lines

    set wrap



    set showmatch

    " Display line number

    set number

    set ruler



    set listchars=tab:>>,eol:$,trail:-

    set list

    " Setting the smart tab

    set shiftwidth=4

    set tabstop=4

    set sts=4

    set expandtab

    set smarttab

    """"""""""""""""""""""""""""""""""""""""""""""""""""""
    " Files and backups
    """"""""""""""""""""""""""""""""""""""""""""""""""""""

    set nobackup

    set nowritebackup

    set bsdir=buffer

    set autochdir



    set noar

    " Ignore case when searching

    set ignorecase

    set incsearch



    set ambiwidth=double

    """"""""""""""""""""""""""""""""""""""""""""""""""""""
    " Close pair automatic
    """"""""""""""""""""""""""""""""""""""""""""""""""""""

    :inoremap ( ()<ESC>i

    :inoremap ) <c-r>=ClosePair(')')<CR>

    :inoremap { {}<ESC>i

    :inoremap } <c-r>=ClosePair('}')<CR>

    :inoremap [ []<ESC>i

    :inoremap ] <c-r>=ClosePair(']')<CR>

    :inoremap " ""<ESC>i

    :inoremap ' ''<ESC>i





    function! ClosePair(char)

     if getline('.')[col('.') - 1] == a:char

         return "\<Right>"

     else

         return a:char

     endif

    endfunction





    if has("gui_running")

        map <C-Tab> :tabnext<CR>

        imap <C-Tab> <Esc>:tabnext<CR>



        colorscheme desert



        set columns=120

        set lines=50



        set guioptions-=T

        set guioptions+=m

    else

        map <C-K><C-T> :tabnext<CR>

        imap <C-K><C-T> <Esc>:tabnext<CR>



        colorscheme default

    endif



    if has("win32")

        au GUIEnter * simalt ~x

    endif



    au VimEnter * NERDTreeToggle

    " Open and close the NERD_tree.vim separately

    nmap <F7> <ESC>:NERDTreeToggle<RETURN>
comments powered by Disqus

© Copyright 2019 Tairan Wang