效果如图:
实现方法:在当前用户的家目录下新建文件.vimrc
[root@nodchen-db01-test ~]# pwd
/root
[root@nodchen-db01-test ~]# file .vimrc
.vimrc: UTF-8 Unicode text
新建文件并放入以下内容。重新登录后生效
1 set nocompatible 2 set history=100 3 set lcs=tab:? 4 filetype on 5 filetype plugin on 6 filetype indent on 7 set autoread 8 set mouse=c 9 syntax enable 10 set cursorline 11 hi cursorline guibg=#00ff00 12 hi CursorColumn guibg=#00ff00 13 set foldenable 14 set foldmethod=manual 15 set foldcolumn=0 16 setlocal foldlevel=3 17 set foldclose=all 18 nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR> 19 set expandtab 20 set tabstop=4 21 set shiftwidth=4 22 set softtabstop=4 23 set smarttab 24 set ai 25 set si 26 set wrap 27 set sw=4 28 set wildmenu 29 set ruler 30 set cmdheight=1 31 set lz 32 set backspace=eol,start,indent 33 set whichwrap+=<,>,h,l 34 set magic 35 set noerrorbells 36 set novisualbell 37 set showmatch 38 set mat=4 39 set hlsearch 40 set ignorecase 41 set encoding=utf-8 42 set fileencodings=utf-8 43 set termencoding=utf-8 44 set smartindent 45 set cin 46 set showmatch 47 set guioptions-=T 48 set guioptions-=m 49 set vb t_vb= 50 set laststatus=4 51 set pastetoggle=<F9> 52 set background=dark 53 highlight Search ctermbg=black ctermfg=white guifg=white guibg=black 54 autocmd BufNewFile *.py,*.cc,*.sh,*.java exec ":call SetTitle()" 55 func SetTitle() 56 if expand("%:e") == 'sh' 57 call setline(1, "#!/bin/bash") 58 call setline(2, "##############################################################") 59 call setline(3, "# File Name: ".expand("%")) 60 call setline(4, "# Version: V1.0") 61 call setline(5, "# Author: nod") 62 call setline(6, "# Description:") 63 call setline(7, "##############################################################") 64 endif 65 endfunc
至此配置完成