6 set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
7 set fileformats=unix,dos,mac
8 "set langmenu=zh_CN.UTF-8
11 " Create needed folder
12 silent !mkdir -p $HOME/.vim/.swap
14 " Be iMproved, required
20 if has("macunix") || has("unix")
25 " viminfo: remember certain things when we exit
26 set viminfo=%50,\"100,'20,/20,:50,h,f1,n$HOME/.vim/.swap/viminfo
27 " | | | | | | | + viminfo file path
28 " | | | | | | + file marks 0-9,A-Z. 0 = not storeed
29 " | | | | | + disable hlsearch loading viminfo
30 " | | | | + command line history saved
31 " | | | + search history saved
32 " | | + file marks saved
33 " | + lines saved each register (old name for <, vi6,2)
34 " + save/restore buffer list
44 set ruler " Always show current position
45 set virtualedit=onemore " block, insert, all, onemore
46 set list! " Display unprintable characters
47 set listchars=tab:▸\ ,trail:•,extends:»,precedes:«
49 " Formatting, indentation and tabbing
50 set autoindent smartindent shiftround
51 set smarttab " Make <tab> and <backspace> smarter
52 set expandtab " expand tabs to spaces
54 set tabstop=4 softtabstop=4 shiftwidth=4
55 set formatoptions-=t formatoptions+=croql
59 filetype plugin indent on
61 set wildmenu " Enhanced completion hints in command
62 set wildmode=list:longest,full
63 set backspace=eol,start,indent " Allow backspace
64 set complete=.,w,b,u,U,t,i,d " Do lots of scanning on tab completion
65 set updatecount=100 " Write swap file to disk every 100 chars
67 set directory=$HOME/.vim/.swap " Directory to use for the swap file
68 set diffopt=filler,iwhite
73 set visualbell t_vb= " Disable error bells
74 set shortmess+=A " Always edit file
75 set nobackup " close backup files
79 set mouse=a " Mouse wheel
80 let g:netrw_home=$HOME.'/.vim/.swap'
82 set magic " For regular expressions
86 if has("persistent_undo")
87 set undodir=$HOME/.vim/.swap
93 set ignorecase " ignore case buring search
94 set smartcase " ignore 'ignorecase' when UPPer in search
95 set hlsearch " highlight search
96 set incsearch " do incremental searching
97 set showmatch " show matching parenthese
101 autocmd FileType c,cmake,cpp,css,fortran,lisp,make,perl,scss,sh,vim
102 \ setlocal textwidth=78 colorcolumn=+1 wrap linebreak formatoptions+=t
103 autocmd FileType html setlocal shiftwidth=2 softtabstop=2 expandtab
105 " Auto reload when editing it
106 autocmd! bufwritepost .vimrc source %
108 " When opening a file, always jump to the last cursor position
109 autocmd BufReadPost *
110 \ if line("'\"") > 0 && line ("'\"") <= line("$") |
111 \ exe "normal g'\"zz" |
114 " After 4s of inactivity, check for file modifications on next keyrpress
115 autocmd CursorHold * checktime
121 if filereadable("cscope.out")
129 let localmapleader=","
131 " allow saving files as sudo
132 cmap w!! w !sudo tee > /dev/null %
136 " Copy, paste, undo, save, select all
140 nnoremap <C-s> :w!<cr>
142 set clipboard=unnamed " copy to the system clipboard
143 if has("unnamedplus") " X11 support
144 set clipboard+=unnamedplus
148 " Follow scroll wheel to cursor
149 noremap <ScrollWheelUp> 3k
150 noremap <ScrollWheelDown> 3j
152 nnoremap <Leader>s :%S/
153 vnoremap <Leader>s :S/
155 vnoremap . :normal .<cr>
156 vnoremap @ :normal! @
158 " up/down on displayed lines, not real lines. More useful than painful.
163 noremap <Leader>/ :nohlsearch<cr>
165 " tabprevious and tabnext
166 noremap <S-l> :tabprevious<cr>
167 noremap <S-h> :tabnext<cr>
169 " Do also cnext and cprev as a fallback
170 noremap <PageDown> :lnext<cr>
171 noremap <PageUp> :lprev<cr>
173 " Disable K for manpages - not used often and easy to accidentally hit
176 " Resize window splits
177 nnoremap <C-k> 3<C-w>-
178 nnoremap <C-j> 3<C-w>+
179 nnoremap <C-h> 3<C-w><
180 nnoremap <C-l> 3<C-w>>
183 nnoremap _ :split<cr>
184 nnoremap \| :vsplit<cr>
186 vnoremap s :!sort<cr>
187 vnoremap u :!sort -u<cr>
191 if empty(glob('~/.vim/colors/lucario.vim'))
192 silent !curl -fLo $HOME/.vim/colors/lucario.vim --create-dirs
193 \ https://raw.githubusercontent.com/raphamorim/lucario/master/colors/lucario.vim
196 hi CursorLineNr ctermfg=NONE ctermbg=236 cterm=bold guifg=NONE guibg=#405160 gui=NONE
197 hi SpecialKey ctermfg=NONE ctermbg=NONE cterm=NONE guifg=#61bbc8 guibg=NONE gui=NONE
198 hi Comment ctermfg=44 ctermbg=NONE cterm=italic guifg=#5c98cd guibg=NONE gui=italic
205 silent! so $HOME/.vim/plugrc.vim
207 " vim: set et fenc=utf-8 ff=unix sts=4 sw=4 ts=4 :