vim setting

/etc/vim/vimrc

set nocompatible    " use vim defaults
set backspace=2    "make backspace like most other apps
set ls=2            " allways show status line
set tabstop=5       " numbers of spaces of tab character
set shiftwidth=5    " numbers of spaces to (auto)indent
set scrolloff=5     " keep 3 lines when scrolling
set showcmd         " display incomplete commands
set hlsearch        " highlight searches
set incsearch       " do incremental searching
set ruler           " show the cursor position all the time
set visualbell t_vb=    " turn off error beep/flash
set novisualbell    " turn off visual bell
set nobackup        " do not keep a backup file
set number          " show line numbers
set ignorecase      " ignore case when searching
"set noignorecase   " don't ignore case
set title           " show title in console title bar
set ttyfast         " smoother changes
"set ttyscroll=0        " turn off scrolling, didn't work well with PuTTY
set modeline        " last lines in document sets vim mode
set modelines=3     " number lines checked for modelines
set shortmess=atI   " Abbreviate messages
set nostartofline   " don't jump to first character when paging
set whichwrap=b,s,h,l,<,>,[,]   " move freely between files
"set viminfo='20,<50,s10,h
set mouse=a

set fileencodings=utf-8,gb2312,gbk,gb18030
set termencoding=utf-8
set encoding=prc

colorscheme desert

set autoindent     " always set autoindenting on
set smartindent        " smart indent
set cindent            " cindent
"set noautoindent
"set nosmartindent
"set nocindent  

"set autowrite      " auto saves changes when quitting and swiching buffer
"set expandtab      " tabs are converted to spaces, use only when required
"set sm             " show matching braces, somewhat annoying...
"set nowrap         " don't wrap lines

highlight Normal guibg=grey90
highlight Cursor guibg=Green guifg=NONE
highlight NonText guibg=grey80
highlight Constant gui=NONE guibg=grey95
highlight Special gui=NONE guibg=grey95

" Color settings for the cursor (different colors for insert mode)
" Modified for black
"highlight Cursor   guifg=white  guibg=black
"highlight Cursor   guifg=red  guibg=lightgreen
highlight Cursor   guifg=white  guibg=black
highlight iCursor  guifg=white  guibg=black

" Cursor shape (insert => vertical line)
set guicursor=n-v-c:block-Cursor
"set guicursor+=i:ver30-iCursor

" Gui background color
"	 highlight Normal guibg=lightblue
"	highlight Normal guibg=lightyellow
"	highlight Normal guibg=#fffddd
"	highlight Normal guibg=#99cccc
"	 highlight Normal guibg=lightmagenta
"	 highlight Normal guibg=lightgreen
" Modified for black
	highlight Normal guibg=#eeeeee
	highlight Normal guibg=white guifg=darkblue
	highlight Normal guibg=black guifg=white

   highlight Visual guibg=black 
"   highlight Visual guibg=lightmagenta

:highlight Normal ctermfg=grey ctermbg=black

syntax on           " syntax highlighing
if has("gui_running")
    " See ~/.gvimrc
    set guifont=Monospace\ 10  " use this font
    set lines=50       " height = 50 lines
    set columns=100        " width = 100 columns
    set background=light   " adapt colors for background
    set selectmode=mouse,key,cmd
"    set keymodel=
else
"    colorscheme elflord    " use this color scheme
    set background=dark        " adapt colors for background
endif

if has("autocmd")
    " Restore cursor position
    au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif

    " Filetypes (au = autocmd)
    au FileType helpfile set nonumber      " no line numbers when viewing help
    au FileType helpfile nnoremap <buffer><cr> <c-]>   " Enter selects subject
    au FileType helpfile nnoremap <buffer><bs> <c-T>   " Backspace to go back
    
    " When using mutt, text width=72
    au FileType mail,tex set textwidth=72
    au FileType cpp,c,java,sh,pl,php,asp  set autoindent
    au FileType cpp,c,java,sh,pl,php,asp  set smartindent
    au FileType cpp,c,java,sh,pl,php,asp  set cindent
    "au BufRead mutt*[0-9] set tw=72
    
    " Automatically chmod +x Shell and Perl scripts
    "au BufWritePost   *.sh             !chmod +x %
    "au BufWritePost   *.pl             !chmod +x %

    " File formats
    au BufNewFile,BufRead  *.pls    set syntax=dosini
    au BufNewFile,BufRead  modprobe.conf    set syntax=modconf
endif
 

others

" use extended function of vim (no compatible with vi)

set nocompatible

" specify encoding

set encoding=euc-jp

" specify file encoding

set fileencodings=iso-2022-jp,sjis

" specify file formats

set fileformats=unix,dos

" take backup

" if not, specify [ set nobackup ]

set backup

" specify backup directory

set backupdir=~/backup

" take 50 search histories

set history=50

" ignore Case

set ignorecase

" distinct Capital if you mix it in search words

set smartcase

" highlights matched words

" if not, specify [ set nohlsearch ]

set hlsearch

" use incremental search

" if not, specify [ set noincsearch ]

set incsearch

" show line number

" if not, specify [ set nonumber ]

set number

" Visualize break ( $ ) or tab ( ^I )

set list

" highlights parentheses

set showmatch

" show color display

" if not, specify [ syntax off ]

syntax on

" change colors for comments if it's set [ syntax on ]

highlight Comment ctermfg=LightCyan

" wrap lines

" if not, specify [ set nowrap ]

set wrap
 

vim

相关推荐