Created
May 28, 2013 11:10
-
-
Save noscripter/5662016 to your computer and use it in GitHub Desktop.
vimrc based on ivim and spf13 for windows and chinese users.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set nocompatible " be iMproved | |
filetype off " required! | |
set rtp+=~/.vim/bundle/vundle/ | |
call vundle#rc() | |
set nocompatible " must be first line | |
set background=dark " Assume a dark background | |
filetype off | |
set rtp+=~/.vim/bundle/vundle | |
call vundle#rc() | |
Bundle 'gmarik/vundle' | |
""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" added from http://beiyuu.com/git-vim-tutorial/ | |
"相较于Command-T等查找文件的插件,ctrlp.vim最大的好处在于没有依赖,干净利落 | |
Bundle 'ctrlp.vim' | |
"在输入(),""等需要配对的符号时,自动帮你补全剩余半个 | |
Bundle 'AutoClose' | |
"神级插件,ZenCoding可以让你以一种神奇而无比爽快的感觉写HTML、CSS | |
Bundle 'ZenCoding.vim' | |
"在()、""、甚至HTML标签之间快速跳转; | |
Bundle 'matchit.zip' | |
"显示行末的空格; | |
Bundle 'ShowTrailingWhitespace' | |
"JS代码格式化插件; | |
Bundle '_jsbeautify' | |
"用全新的方式在文档中高效的移动光标,革命性的突破 | |
Bundle 'EasyMotion' | |
"自动识别文件编码; | |
Bundle 'FencView.vim' | |
"必不可少,在VIM的编辑窗口树状显示文件目录 | |
Bundle 'The-NERD-tree' | |
"NERD出品的快速给代码加注释插件,选中,`ctrl+h`即可注释多种语言代码; | |
Bundle 'The-NERD-Commenter' | |
"解放生产力的神器,简单配置,就可以按照自己的风格快速输入大段代码。 | |
Bundle 'UltiSnips' | |
"让代码更加易于纵向排版,以=或,符号对齐 | |
Bundle 'Tabular' | |
""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
Bundle 'scrooloose/nerdtree' | |
" Bundle 'altercation/vim-colors-solarized' | |
" Bundle 'spf13/vim-colors' | |
" Bundle 'tpope/vim-surround' | |
" Bundle 'spf13/vim-autoclose' | |
" Bundle 'kien/ctrlp.vim' | |
"Bundle 'vim-scripts/sessionman.vim' | |
" Bundle 'matchit.zip' | |
Bundle 'Lokaltog/vim-powerline' | |
" Bundle 'Lokaltog/vim-easymotion' | |
" Bundle 'jistr/vim-nerdtree-tabs' | |
" Bundle 'flazz/vim-colorschemes' | |
" Bundle 'mbbill/undotree' | |
" Bundle 'myusuf3/numbers.vim' | |
" Bundle 'nathanaelkane/vim-indent-guides' | |
" if !exists('g:spf13_no_views') | |
" Bundle 'vim-scripts/restore_view.vim' | |
" endif | |
" Bundle 'tpope/vim-abolish.git' | |
" General Programming | |
" Pick one of the checksyntax, jslint, or syntastic | |
"Bundle 'scrooloose/syntastic' | |
"Bundle 'tpope/vim-fugitive' | |
"Bundle 'mattn/webapi-vim' | |
"Bundle 'mattn/gist-vim' | |
"Bundle 'scrooloose/nerdcommenter' | |
"Bundle 'godlygeek/tabular' | |
"if executable('ctags') | |
" Bundle 'majutsushi/tagbar' | |
"endif | |
Bundle 'mattn/zencoding-vim' | |
"source $VIMRUNTIME/vimrc_example.vim | |
"source $VIMRUNTIME/mswin.vim | |
behave mswin | |
" colorscheme solarized | |
" colorscheme molokai | |
" set syntax | |
if has("syntax") | |
syntax on | |
endif | |
" if using a dark background within the editing area and syntax highlighting | |
" turn on this option as well | |
set background=dark | |
set encoding=UTF-8 | |
set termencoding=UTF-8,cp936,GBK | |
" set file encoding supports Chinese | |
set fileencodings=UTF-8,GB2312,GBK,GB18030,cp936,ucs-bom | |
" let &termencoding=&encoding | |
" set auto indent | |
set autoindent | |
" set indent of c style | |
set cindent | |
" tab spacing | |
set tabstop=4 | |
" backspace could delete 4 spaces | |
set softtabstop=4 | |
" unify it | |
set shiftwidth=4 | |
set expandtab | |
" turn on folding | |
set foldenable | |
" make folding indent sensitive | |
set foldmethod=indent | |
" don't autofold anything, but can still fold manually | |
set foldlevel=100 | |
" display brackets matches | |
set showmatch | |
" display time of brackets matches( 1 to 5, unit is 1/10 of 1 second) | |
set matchtime=1 | |
" set guioptions for gvim | |
" set go=m "show menu for guioptions | |
" set go=e | |
set go= | |
" raise a confirm dialog about whether to save changed buffers | |
set confirm | |
" favor unix, which behaves good under Linux/windows | |
set ffs=unix,dos,mac | |
" enable file type detection | |
filetype on | |
" enable loading the plugin for appropriate filetype | |
filetype indent on | |
" the vertical completion tip list after hitting tab in cmd mode | |
set wildmenu | |
" use 2 screen lines for command-line | |
set cmdheight=1 | |
" do not redraw while executing macros (much faster) | |
set lazyredraw | |
" make backspace works normally | |
" set backspace=2 | |
set backspace=indent,eol,start | |
" Show (partial) command in the last line of the screen. | |
" Set this option off if your terminal is slow. | |
"set showcmd | |
" set nosc | |
" smartindent | |
set smartindent | |
" hight where the typed pattern matches | |
set incsearch | |
" set a red ruler for vim | |
set colorcolumn=121 | |
"hi colorcolumn guibg=red | |
hi colorcolumn guibg=gray | |
" highlight the current line | |
set cursorline | |
" set autochange dir to current dir | |
set autochdir | |
" set highligt the search result | |
set hlsearch | |
" se ignorecase " ignore case when searching | |
set ignorecase | |
set smartcase | |
set noerrorbells " set no error bells | |
" set the highlight pattern for the matched parenthesis | |
hi MatchParen ctermbg=blue ctermfg=white | |
" set the guifont to Consolas and font size is h11 | |
set gfn=Consolas:h12 | |
" highlight the current column | |
set cuc " cuc equals cursorcolumn | |
" disable autowrap | |
se nowrap | |
" set this to enable powerline plugin functions | |
" set this to reset ruler to prevent 'press enter' tips | |
se ruler | |
" set rulerformat=%20(%2*%<%f%=\ %m%r\ %3l\ %c\ %p%%%) | |
" start vim maximized | |
au GUIEnter * simalt ~x | |
" so pastings to windows apps doesn't require prefixing "*: | |
set clipboard=unnamed | |
" let vim share clipboard with windows | |
" set clipboard+=unnamed | |
" have the Visual selection automatically copied to the clipboard | |
" set guioptions+=a | |
" if the file type is c/c++ | |
":autocmd FileType c,cpp :set foldmethod=syntax | |
":autocmd FileType c,cpp :set number | |
":autocmd FileType c,cpp :set cindent | |
" if the file type is python | |
":autocmd FileType python :set number | |
":autocmd FileType python :set foldmethod=syntax | |
":autocmd FileType python :set smartindent | |
" gnu's coding style | |
" cinoptions=>4,n-2,{2,^-2,:2,=2,g0,h2,p5,t0,+2,(0,u0,w1,m1 shiftwidth=2 tabstop=8 | |
" map F2 to cancel search highlight | |
nmap <F2> :nohlsearch<CR> | |
nmap <F10> :e $MYVIMRC<CR> | |
nmap <F9> :so $MYVIMRC<CR> | |
nmap <F3> :NERDTreeToggle<CR> | |
" use visual bell instead of beeping | |
set novisualbell | |
" do not make noise | |
set noerrorbells | |
" if the characters are Chinese, then the following line is applied | |
" set fo+=m | |
"""""""""""""""""""""""""""""" | |
" showmarks setting | |
"""""""""""""""""""""""""""""" | |
" Enable ShowMarks | |
" let showmarks_enable = 1 | |
" Show which marks | |
" let showmarks_include = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
" Ignore help, quickfix, non-modifiable buffers | |
" let showmarks_ignore_type = "hqm" | |
" Hilight lower & upper marks | |
" let showmarks_hlline_lower = 1 | |
" let showmarks_hlline_upper = 1 | |
" For showmarks plugin | |
" hi ShowMarksHLl ctermbg=Yellow ctermfg=Black guibg=#FFDB72 guifg=Black | |
" hi ShowMarksHLu ctermbg=Magenta ctermfg=Black guibg=#FFB3FF guifg=Black | |
" set fold method for c and cpp syntax | |
autocmd FileType c,cpp setl fdm=syntax | setl fen | |
" To have the browser window not close itself after you jump to a mark | |
let marksCloseWhenSelected=0 | |
"""""""""""""""""""""""""""""" | |
" minibufexpl: | |
" Elegant buffer explorer - takes very little screen space | |
"""""""""""""""""""""""""""""" | |
"let g:miniBufExplMapWindowNavVim = 1 | |
"let g:miniBufExplMapWindowNavArrows = 1 | |
"let g:miniBufExplMapCTabSwitchBufs = 1 | |
"let g:miniBufExplModSelTarget = 1 | |
" turn on omnicompletion | |
filetype plugin on | |
set ofu=syntaxcomplete#Complete | |
"-----ctags + taglist settings--------- | |
" let taglist find ctags | |
"let Tlist_Ctags_Cmd="D:/program Files/vim/ctags58" | |
"let Tlist_Show_Menu = 1 | |
" ctags set | |
"set tags=tags; | |
"set autochdir | |
"使用F8打开Taglist | |
"nnoremap <silent> <F8> :TlistToggle<CR> | |
"生成一个tags文件 | |
"nmap <F9> <Esc>:!ctags -R *<CR> | |
" configure snipMate | |
" let g:acp_behaviorSnipmateLength=1 | |
"设置Taglist | |
"自动打开taglist | |
"autocmd VimEnter * TlistToggle | |
"let Tlist_Show_One_File=1 | |
"let Tlist_Exit_OnlyWindow=1 | |
" set syntax highlighting for smarty php template | |
" au BufRead,BufNewFile *.tpl set filetype=smarty | |
" set powerline | |
" let g:Powerline_symbols = 'fancy' | |
" set fillchars+=stl:\ ,stlnc:\ " show empty lines in split windows for convenience of reading | |
set fillchars=vert:\ ,stl:\ ,stlnc:\ | |
source $VIMRUNTIME/delmenu.vim | |
source $VIMRUNTIME/menu.vim | |
set nu " show number | |
set history=1000 " set the number of lines in the vim history file | |
" save global variable | |
" set viminfo+=! | |
" don't split a whole word into two lines if it contains the following keywords | |
set iskeyword+=_,$,@,%,#,- | |
" highlight characters as well as disable the constraints of 100 columns | |
" :highlight OverLength ctermbg=red ctermfg=white guibg=red guifg=white | |
" :match OverLength '\%101v.*' | |
" set color for statusline | |
highlight StatusLine guifg=SlateBlue guibg=Yellow | |
highlight StatusLineNC guifg=Gray guibg=White | |
" allow backspace and cursor key across line border | |
se whichwrap+=<,>,h,l | |
" allow mouse in any place in buffers(like positioning your mouse in office by | |
" double clicking) | |
se mouse=a | |
se selection=exclusive | |
se selectmode=mouse,key | |
" enable :commands which can show the lines in the file that have been changed | |
set report=0 | |
" 输入:set list命令是应该显示些啥? show invisible chars | |
" set list | |
" set listchars=tab:\|\ ,trail:.,extends:>,precedes:<,eol:$ | |
" set listchars=tab:?\ ,eol:? | |
" Shortcut to rapidly toggle `set list` | |
nmap <leader>l :set list!<CR> | |
" 光标移动到buffer的顶部和底部时保持3行距离 | |
" set scrolloff=3 | |
" 我的状态行显示的内容(包括文件类型和解码) | |
set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")} | |
" 能够漂亮地显示.NFO文件 | |
set encoding=UTF-8 | |
function! SetFileEncodings(encodings) | |
let b:myfileencodingsbak=&fileencodings | |
let &fileencodings=a:encodings | |
endfunction | |
function! RestoreFileEncodings() | |
let &fileencodings=b:myfileencodingsbakendfunctionau | |
unlet b:myfileencodingsbak | |
endfunction | |
au BufReadPre *.nfo call SetFileEncodings('cp437')|set ambiwidth=single | |
au BufReadPost *.nfo call RestoreFileEncodings() | |
" 高亮显示普通txt文件(需要txt.vim脚本) | |
"au BufRead,BufNewFile * setfiletype txt | |
" 用空格键来开关折叠 | |
" set foldenable | |
" set foldmethod=manual | |
" nnoremap @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo') | |
" enable zencoding.vim for the edited file's language | |
let g:user_zen_settings = { | |
\ 'php' : { | |
\ 'extends' : 'html', | |
\ 'filters' : 'c', | |
\ }, | |
\ 'xml' : { | |
\ 'extends' : 'html', | |
\ }, | |
\ 'haml' : { | |
\ 'extends' : 'html', | |
\ }, | |
\} | |
set showmode | |
" set F9 for editing vimrc | |
map <F9> :e $MYVIMRC<CR> | |
" set F6 for source vimrc modifications | |
map <F6> :so $MYVIM<CR> | |
call pathogen#infect() | |
set statusline+=%#warningmsg# | |
" set statusline+=%{SyntasticStatusLineFlag()} | |
set statusline+=%* | |
" map tab switching operations with meta key(in windows alt) + num | |
" map <M-1> 1gt | |
" map <M-2> 2gt | |
" map <M-3> 3gt | |
" map <M-4> 4gt | |
" map <M-5> 5gt | |
" map <M-6> 6gt | |
" map <M-7> 7gt | |
" map <M-8> 8gt | |
" map <M-9> 9gt | |
" map <M-t> :tabnew<CR> | |
" map <C-w> :tabclose<CR> | |
" " no remap of the above operations | |
" map! <M-1> <esc>1gt | |
" map! <M-2> <esc>2gt | |
" map! <M-3> <esc>3gt | |
" map! <M-4> <esc>4gt | |
" map! <M-5> <esc>5gt | |
" map! <M-6> <esc>6gt | |
" map! <M-7> <esc>7gt | |
" map! <M-8> <esc>8gt | |
" map! <M-9> <esc>9gt | |
" map! <M-t> <esc>:tabnew<CR> | |
" map! <C-w> <esc>:tabclose<CR> | |
" configuration of the taglist plugin | |
" put the method list on the right of the screen | |
" let Tlist_Use_Right_Window=1 | |
" fold methods which are not being edited by default | |
" let Tlist_File_Fold_Auto_Close=1 | |
" The following configurations are for vim-latex | |
" IMPORTANT: win32 users will need to have 'shellslash' set so that latex | |
" can be called correctly | |
" set shellslash | |
" IMPORTANT: grep will sometimes skip displaying the file name if your | |
" search in a single file. This will confuse Latex-Suite. Set your grep | |
" program to always generate a file-name. | |
set grepprg=grep\ -nh\ $* | |
" OPTIONAL: This enables automatic indentation as you type. | |
" filetype indent on | |
" OPTIONAL: Starting with Vim 7, the filetype of empty .tex files defaults to | |
" 'plaintex' instead of 'tex', which results in vim-latex not being loaded. | |
" The following changes the default filetype back to 'tex': | |
let g:tex_flavor='latex' | |
" TIP: if you write your \label's as \label{fig:something}, then if you | |
" type in \ref{fig: and press <C-n> you will automatically cycle through | |
" all the figure labels. Very useful! | |
set iskeyword+=: | |
" set backup | |
language messages en_US.utf-8 | |
" call pathogen | |
call pathogen#infect() | |
syntax on | |
filetype plugin indent on | |
set autoread | |
set nobackup | |
" imported from linux_vimrc | |
" Sets how many lines of history VIM has to remember | |
set history=1000 | |
" Enable filetype plugins | |
filetype plugin on | |
filetype indent on | |
" Set to auto read when a file is changed from the outside | |
set autoread | |
" With a map leader it's possible to do extra key combinations | |
" like <leader>w saves the current file | |
let mapleader = "," | |
let g:mapleader = "," | |
" Fast saving | |
"nmap <leader>w :w!<cr> | |
" raise a confirm dialog about whether to save changed buffers | |
set confirm | |
" allow mouse in buffers(eg. positioning mouse in office by double clicking) | |
se mouse=a | |
se selection=exclusive | |
se selectmode=mouse,key | |
" 带有如下符号的单词不要被换行分割 | |
set iskeyword+=_,$,@,%,#,- | |
" 通过使用: commands命令,告诉我们文件的哪一行被改变过 | |
set report=0 | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Colors and Fonts | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Enable syntax highlighting | |
" syntax enable | |
" Same as above, but allow vim to overrule your settings with the defaults | |
syntax on | |
colorscheme desert | |
set background=dark | |
" Set extra options when running in GUI mode | |
if has("gui_running") | |
set guioptions-=T | |
set guioptions+=e | |
set t_Co=256 | |
set guitablabel=%M\ %t | |
endif | |
" Set utf8 as standard encoding and en_US as the standard language | |
set encoding=utf8 | |
" set file encoding supports Chinese | |
set fileencodings=utf8,gb2312,gbk,gb18030,cp936,ucs-bom | |
" Use Unix as the standard file type | |
set ffs=unix,dos,mac | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => VIM user interface | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Set 7 lines to the cursor - when moving vertically using j/k | |
set so=7 | |
" Turn on the WiLd menu | |
set wildmenu | |
" Ignore compiled files | |
set wildignore=*.o,*~,*.pyc | |
" show number | |
set number | |
"Always show current position | |
set ruler | |
" Height of the command bar | |
set cmdheight=1 | |
" A buffer becomes hidden when it is abandoned | |
set hid | |
" Configure backspace so it acts as it should act | |
set backspace=eol,start,indent | |
set whichwrap+=<,>,h,l | |
" Ignore case when searching | |
set ignorecase | |
" When searching try to be smart about cases | |
set smartcase | |
" Highlight search results | |
set hlsearch | |
" Makes search act like search in modern browsers | |
set incsearch | |
" Don't redraw while executing macros (good performance config) | |
set lazyredraw | |
" For regular expressions turn magic on | |
set magic | |
" Show matching brackets when text indicator is over them | |
set showmatch | |
" How many tenths of a second to blink when matching brackets | |
set mat=2 | |
" No annoying sound on errors | |
set noerrorbells | |
" 不要闪烁 | |
set novisualbell | |
set t_vb= | |
set tm=500 | |
" highlight current column to help vertical alignment | |
set cursorcolumn | |
" hi CursorColumn cterm=bold ctermbg=darkred ctermfg=white guibg=darkred guifg=white | |
" highlight current line | |
set cursorline | |
" highlight current line shadow instead of underline | |
" hi CursorLine term=bold cterm=bold guibg=Grey40 | |
" hi CursorLine cterm=bold ctermbg=darkred ctermfg=white guibg=darkred guifg=white | |
hi CursorLine ctermbg=darkred ctermfg=white guibg=darkred guifg=white | |
" set a ruler | |
set colorcolumn=121 | |
" hi colorcolumn guibg=bold | |
" start vim maximized | |
au GUIEnter * simalt ~x | |
" share default buffer with pastboard | |
set clipboard=unnamed | |
" 高亮字符,让其不受100列限制 | |
:highlight OverLength ctermbg=red ctermfg=white guibg=red guifg=white | |
:match OverLength '\%101v.*' | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Files, backups and undo | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Turn backup off, since most stuff is in SVN, git et.c anyway... | |
set nobackup | |
set nowb | |
set noswapfile | |
" set autochange to current dir | |
set autochdir | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Text, tab and indent related | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Use spaces instead of tabs | |
set expandtab | |
" Be smart when using tabs ;) | |
set smarttab | |
" 1 tab == 4 spaces | |
set shiftwidth=4 | |
set tabstop=4 | |
" backspace to delete a tab | |
set softtabstop=4 | |
" Linebreak on 500 characters | |
set linebreak | |
set tw=500 | |
set autoindent "Auto indent | |
set smartindent "Smart indent | |
set nowrap "Wrap lines | |
" turn on folding | |
set foldenable | |
" make folding indent sensitive | |
set foldmethod=indent | |
" don't autofold anything, but can still fold manually | |
set foldlevel=100 | |
" auto indent | |
set autoindent | |
" set c style indent | |
set cindent | |
set cinoptions={0,1s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" 文本格式和排版 | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" 自动格式化 | |
set formatoptions=tcrqn | |
"""""""""""""""""""""""""""""" | |
" => Visual mode related | |
"""""""""""""""""""""""""""""" | |
" Visual mode pressing * or # searches for the current selection | |
" Super useful! From an idea by Michael Naumann | |
"vnoremap <silent> * :call VisualSelection('f')<CR> | |
"vnoremap <silent> # :call VisualSelection('b')<CR> | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Moving around, tabs, windows and buffers | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Treat long lines as break lines (useful when moving around in them) | |
"map j gj | |
"map k gk | |
" set F10 for editing vimrc | |
map <F10> :e $MYVIMRC<CR> | |
" set F9 for source vimrc modifications | |
map <F9> :so $MYVIMRC<CR> | |
" Smart way to move between windows | |
map <C-j> <C-W>j | |
map <C-k> <C-W>k | |
map <C-h> <C-W>h | |
map <C-l> <C-W>l | |
map <C-o> <C-W>o | |
" Close the current buffer | |
"map <leader>bd :Bclose<cr> | |
" Close all the buffers | |
"map <leader>ba :1,1000 bd!<cr> | |
" Useful mappings for managing tabs | |
"map <leader>tn :tabnew<cr> | |
"map <leader>to :tabonly<cr> | |
"map <leader>tc :tabclose<cr> | |
"map <leader>tm :tabmove | |
" Opens a new tab with the current buffer's path | |
" Super useful when editing files in the same directory | |
"map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/ | |
" Switch CWD to the directory of the open buffer | |
"map <leader>cd :cd %:p:h<cr>:pwd<cr> | |
" Specify the behavior when switching between buffers | |
try | |
set switchbuf=useopen,usetab,newtab | |
set stal=2 | |
catch | |
endtry | |
" Return to last edit position when opening files (You want this!) | |
autocmd BufReadPost * | |
\ if line("'\"") > 0 && line("'\"") <= line("$") | | |
\ exe "normal! g`\"" | | |
\ endif | |
" Remember info about open buffers on close | |
set viminfo^=% | |
"""""""""""""""""""""""""""""" | |
" => Status line | |
"""""""""""""""""""""""""""""" | |
" Always show the status line | |
set laststatus=2 | |
" set color for statusline | |
highlight StatusLine guifg=SlateBlue guibg=Yellow | |
highlight StatusLineNC guifg=Gray guibg=White | |
" Format the status line | |
" set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l | |
" 我的状态行显示的内容(包括文件类型和解码) | |
" set statusline=%F%m%r%h%w\[POS=%l,%v][%p%%]\%{strftime(\"%d/%m/%y\ -\ %H:%M\")} | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Editing mappings | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Remap VIM 0 to first non-blank character | |
"map 0 ^ | |
" Move a line of text using ALT+[jk] or Comamnd+[jk] on mac | |
"nmap <M-j> mz:m+<cr>`z | |
"nmap <M-k> mz:m-2<cr>`z | |
"vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z | |
"vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z | |
"if has("mac") || has("macunix") | |
" nmap <D-j> <M-j> | |
" nmap <D-k> <M-k> | |
" vmap <D-j> <M-j> | |
" vmap <D-k> <M-k> | |
"endif | |
" Delete trailing white space on save, useful for Python and CoffeeScript ;) | |
func! DeleteTrailingWS() | |
exe "normal mz" | |
%s/\s\+$//ge | |
exe "normal `z" | |
endfunc | |
autocmd BufWrite *.py :call DeleteTrailingWS() | |
autocmd BufWrite *.coffee :call DeleteTrailingWS() | |
" map F2 to cancel search highlight | |
nmap <F2> :nohlsearch<CR> | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => vimgrep searching and cope displaying | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" When you press gv you vimgrep after the selected text | |
"vnoremap <silent> gv :call VisualSelection('gv')<CR> | |
" Open vimgrep and put the cursor in the right position | |
"map <leader>g :vimgrep // **/*.<left><left><left><left><left><left><left> | |
" Vimgreps in the current file | |
"map <leader><space> :vimgrep // <C-R>%<C-A><right><right><right><right><right><right><right><right><right> | |
" When you press <leader>r you can search and replace the selected text | |
"vnoremap <silent> <leader>r :call VisualSelection('replace')<CR> | |
" Do :help cope if you are unsure what cope is. It's super useful! | |
" | |
" When you search with vimgrep, display your results in cope by doing: | |
" <leader>cc | |
" | |
" To go to the next search result do: | |
" <leader>n | |
" | |
" To go to the previous search results do: | |
" <leader>p | |
" | |
"map <leader>cc :botright cope<cr> | |
"map <leader>co ggVGy:tabnew<cr>:set syntax=qf<cr>pgg | |
"map <leader>n :cn<cr> | |
"map <leader>p :cp<cr> | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Spell checking | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Pressing ,ss will toggle and untoggle spell checking | |
"map <leader>ss :setlocal spell!<cr> | |
" Shortcuts using <leader> | |
"map <leader>sn ]s | |
"map <leader>sp [s | |
"map <leader>sa zg | |
"map <leader>s? z= | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Misc | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Remove the Windows ^M - when the encodings gets messed up | |
"noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm | |
" Quickly open a buffer for scripbble | |
"map <leader>q :e ~/buffer<cr> | |
" Toggle paste mode on and off | |
"map <leader>pp :setlocal paste!<cr> | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Helper functions | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
function! CmdLine(str) | |
exe "menu Foo.Bar :" . a:str | |
emenu Foo.Bar | |
unmenu Foo | |
endfunction | |
function! VisualSelection(direction) range | |
let l:saved_reg = @" | |
execute "normal! vgvy" | |
let l:pattern = escape(@", '\\/.*$^~[]') | |
let l:pattern = substitute(l:pattern, "\n$", "", "") | |
if a:direction == 'b' | |
execute "normal ?" . l:pattern . "^M" | |
elseif a:direction == 'gv' | |
call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.') | |
elseif a:direction == 'replace' | |
call CmdLine("%s" . '/'. l:pattern . '/') | |
elseif a:direction == 'f' | |
execute "normal /" . l:pattern . "^M" | |
endif | |
let @/ = l:pattern | |
let @" = l:saved_reg | |
endfunction | |
" Returns true if paste mode is enabled | |
function! HasPaste() | |
if &paste | |
return 'PASTE MODE ' | |
en | |
return '' | |
endfunction | |
" Don't close window, when deleting a buffer | |
command! Bclose call <SID>BufcloseCloseIt() | |
function! <SID>BufcloseCloseIt() | |
let l:currentBufNum = bufnr("%") | |
let l:alternateBufNum = bufnr("#") | |
if buflisted(l:alternateBufNum) | |
buffer # | |
else | |
bnext | |
endif | |
if bufnr("%") == l:currentBufNum | |
new | |
endif | |
if buflisted(l:currentBufNum) | |
execute("bdelete! ".l:currentBufNum) | |
endif | |
endfunction | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Plugin settings | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Powerline settings | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" 总是显示状态行 | |
set laststatus=2 | |
" Powerline_symbols | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" TYPE DESCRIPTION ~ | |
" compatible Doesn't use any special characters. | |
" unicode Simulates icons and arrows using similar Unicode glyphs. | |
" fancy Custom icons and arrows. Requires a patched font. | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
let g:Powerline_symbols = 'compatible' | |
" let g:Powerline_symbols = 'unicode' | |
" let g:Powerline_symbols = 'fancy' | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => NERDTree settings | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" map F3 to open NERDTree | |
nmap <F3> :NERDTreeToggle<CR> | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Syntastics settings | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"在打开文件的时候检查 | |
"let g:syntastic_check_on_open=1 | |
""phpcs,tab 4个空格,编码参考使用CodeIgniter风格 | |
"let g:syntastic_phpcs_conf = "--tab-width=4 --standard=CodeIgniter" | |
set shortmess=a " abbrev. of messages (avoids 'hit enter') | |
set wrap | |
" Make j and k work the way you expect | |
nnoremap j gj | |
nnoremap k gk | |
vnoremap j gj | |
vnoremap k gk |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment