您的位置:首页 > 其它

打造自己的vim配置

2017-03-26 23:14 253 查看
如果我们安装了vim这个编辑器,那么会在/etc下面有一个vimrc的配置



我们可以看一下这个vimrc的配置信息

[root@localhost etc]# cat vimrc
if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
set fileencodings=ucs-bom,utf-8,latin1
endif

set nocompatible    " Use Vim defaults (much better!)
set bs=indent,eol,start     " allow backspacing over everything in insert mode
"set ai         " always set autoindenting on
"set backup     " keep a backup file
set viminfo='20,\"50    " read/write a .viminfo file, don't store more
" than 50 lines of registers
set history=50      " keep 50 lines of command line history
set ruler       " show the cursor position all the time

" Only do this part when compiled with support for autocommands
if has("autocmd")
augroup redhat
autocmd!
" In text files, always limit the width of text to 78 characters
" autocmd BufRead *.txt set tw=78
" When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\   exe "normal! g'\"" |
\ endif
" don't write swapfile on most commonly used directories for NFS mounts or USB sticks
autocmd BufNewFile,BufReadPre /media/*,/run/media/*,/mnt/* set directory=~/tmp,/var/tmp,/tmp
" start with spec file template
autocmd BufNewFile *.spec 0r /usr/share/vim/vimfiles/template.spec
augroup END
endif

if has("cscope") && filereadable("/usr/bin/cscope")
set csprg=/usr/bin/cscope
set csto=0
set cst
set nocsverb
" add any database in current directory
if filereadable("cscope.out")
cs add $PWD/cscope.out
" else add database pointed to by environment
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif
set csverb
endif

" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif

filetype plugin on

if &term=="xterm"
set t_Co=8
set t_Sb=[4%dm
set t_Sf=[3%dm
endif

" Don't wake up system with blinking cursor:
" http://www.linuxpowertop.org/known.php let &guicursor = &guicursor . ",a:blinkon0"


首先查看你的系统中自带的配色方案有哪些? 执行命令 ls -l /usr/share/vim/vim74/colors/

[root@localhost colors]# ll -a
total 80
drwxr-xr-x.  2 root root 4096 Mar  6 20:58 .
drwxr-xr-x. 16 root root 4096 Mar  6 20:58 ..
-rw-r--r--.  1 root root 2476 Dec 21 09:06 blue.vim
-rw-r--r--.  1 root root 2990 Dec 21 09:06 darkblue.vim
-rw-r--r--.  1 root root  548 Dec 21 09:06 default.vim
-rw-r--r--.  1 root root 2399 Dec 21 09:06 delek.vim
-rw-r--r--.  1 root root 2812 Dec 21 09:06 desert.vim
-rw-r--r--.  1 root root 1666 Dec 21 09:06 elflord.vim
-rw-r--r--.  1 root root 2476 Dec 21 09:06 evening.vim
-rw-r--r--.  1 root root 3476 Dec 21 09:06 koehler.vim
-rw-r--r--.  1 root root 2460 Dec 21 09:06 morning.vim
-rw-r--r--.  1 root root 2006 Dec 21 09:06 murphy.vim
-rw-r--r--.  1 root root 1037 Dec 21 09:06 pablo.vim
-rw-r--r--.  1 root root 2673 Dec 21 09:06 peachpuff.vim
-rw-r--r--.  1 root root 2311 Dec 21 09:06 README.txt
-rw-r--r--.  1 root root 1393 Dec 21 09:06 ron.vim
-rw-r--r--.  1 root root 2720 Dec 21 09:06 shine.vim
-rw-r--r--.  1 root root 2445 Dec 21 09:06 slate.vim
-rw-r--r--.  1 root root 1629 Dec 21 09:06 torte.vim
-rw-r--r--.  1 root root 1840 Dec 21 09:06 zellner.vim


那么我们如何打造自己的vim配置呢

在当前用户的主工作目录下(~)创建一个.vimrc的文件,然后在.vimrc里面编辑配置方案。

1 "syntax high light
2 "syntax on
3 ""show the line number
4 set nu
5 "let the tabstop equal 4
6 "set tabstop=4
7 ""set the autoindent on
8 set autoindent
9 "set the match time is one tenth second
10 "set matchtime=1
11 ""high light the search
12 set hlsearch
13 "set the c language indent format
14 "set cindent
15 ""set the indent width
16 set shiftwidth=4
17 "set show status on
18 "set ruler
19 ""set show mode on
20 set showmode
21 syntax enable
22 syntax on
23 set history=1000
24 colorscheme  evening


配色方案可以选上面的/usr/share/vim/vim74/colors/里的 任意一种,看你自己的喜好。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: