使用Vim经常希望能够配置成自己喜欢的风格,比如C/C++风格缩进、tabl换成空格,中文乱码问题等等,所有这些都可以通过配置完成。
/etc/vimrc是Vim的配置文件,可以直接在这里面修改,但为了方便,可以在~/目录下创建一个.vimrc文件,里面记录自己要修改的配置内容,可移植性和修改都方便。
下面是我自己的一个配置
syntax on
set tabstop=4
set softtabstop=4
set shiftwidth=4
"set expandtab
set autoindent
set cindent
set cinoptions={0,1s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s
"set nu
set encoding=utf-8
set termencoding=utf-8
set fileencodings=gbk,utf-8,ucs-bom,cp936
"set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
"set ignorecase " Do case insensitive matching
"set smartcase " Do smart case matching
"set incsearch " Incremental search
"set autowrite " Automatically save before commands like :next and :make
"set hidden " Hide buffers when they are abandoned
"set mouse=a " Enable mouse usage (all modes) in terminals
"run macros/gdb_mappings.vim
set paste
具体含义自己看吧,应该能看懂。
同时习惯了vi,如何把vi替换成vim,其实可以把/bin/vi备份一下 mv /bin/vi /bin/vi.bak
然后把vim连接到vi: ln -s /usr/bin/vim /bin/vi