My .vimrc
" Use Vim settings, rather then Vi settings. This setting must be as early as" possible, as it has side effects.set nocompatible
" Highlight current lineau WinLeave * set nocursorline nocursorcolumnau WinEnter * set cursorline cursorcolumnset cursorline cursorcolumn
" Leaderlet mapleader = ","
set backspace=2 " Backspace deletes like most programs in insert modeset nobackupset nowritebackupset noswapfile " http://robots.thoughtbot.com/post/18739402579/global-gitignore#comment-458413287set history=50set ruler " show the cursor position all the timeset showcmd " display incomplete commandsset incsearch " do incremental searchingset laststatus=2 " Always display the status lineset autowrite " Automatically :write before running commandsset confirm " Need confrimation while exitset fileencodings=utf-8,gb18030,gbk,big5
" 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")) && !exists("syntax_on") syntax onendif
if filereadable(expand("~/.vimrc.bundles")) source ~/.vimrc.bundlesendif
filetype plugin indent on
augroup vimrcEx autocmd!
" When editing a file, always jump to the last known cursor position. " Don't do it for commit messages, when the position is invalid, or when " inside an event handler (happens when dropping a file on gvim). autocmd BufReadPost * \ if &ft != 'gitcommit' && line("'\"") > 0 && line("'\"") <= line("$") | \ exe "normal g`\"" | \ endif
" Set syntax highlighting for specific file types autocmd BufRead,BufNewFile *.md set filetype=markdown
" Enable spellchecking for Markdown autocmd FileType markdown setlocal spell
" Automatically wrap at 80 characters for Markdown autocmd BufRead,BufNewFile *.md setlocal textwidth=80augroup END
" Softtabs, 2 spacesset tabstop=2set shiftwidth=2set shiftroundset expandtab
" Display extra whitespaceset list listchars=tab:»·,trail:·
" Use The Silver Searcher https://github.com/ggreer/the_silver_searcherif executable('ag') " Use Ag over Grep set grepprg=ag\ --nogroup\ --nocolor
endif
" Color schemecolorscheme molokaihighlight NonText guibg=#060606highlight Folded guibg=#0A0A0A guifg=#9090D0
" lightline statusline color themelet g:lightline = { \ 'colorscheme': 'wombat', \ }
" Make it obvious where 80 characters isset textwidth=80set colorcolumn=+1
" Numbersset numberset numberwidth=5
" Tab completion" will insert tab at beginning of line," will use completion if not at beginningset wildmode=list:longest,list:fullfunction! InsertTabWrapper() let col = col('.') - 1 if !col || getline('.')[col - 1] !~ '\k' return "\<tab>" else return "\<c-p>" endifendfunctioninoremap <Tab> <c-r>=InsertTabWrapper()<cr>inoremap <S-Tab> <c-n>
" Index ctags from any project, including those outside Railsmap <Leader>ct :!ctags -R .<CR>
" Switch between the last two filesnnoremap <leader><leader> <c-^>
" Get off my lawnnnoremap <Left> :echoe "Use h"<CR>nnoremap <Right> :echoe "Use l"<CR>nnoremap <Up> :echoe "Use k"<CR>nnoremap <Down> :echoe "Use j"<CR>
" Run commands that require an interactive shellnnoremap <Leader>r :RunInInteractiveShell<space>
" Open new split panes to right and bottom, which feels more naturalset splitbelowset splitright
" Quicker window movementnnoremap <C-j> <C-w>jnnoremap <C-k> <C-w>knnoremap <C-h> <C-w>hnnoremap <C-l> <C-w>l
" configure syntastic syntax checking to check on open as well as savelet g:syntastic_check_on_open=1let g:syntastic_html_tidy_ignore_errors=[" proprietary attribute \"ng-"]
" autocmd Syntax javascript set syntax=jquery " JQuery syntax support
set matchpairs+=<:>
" Nerd Treelet NERDChristmasTree=0let NERDTreeWinSize=40let NERDTreeChDirMode=2let NERDTreeIgnore=['\~$', '\.pyc$', '\.swp$']let NERDTreeShowBookmarks=1let NERDTreeWinPos="left"autocmd vimenter * if !argc() | NERDTree | endif " Automatically open a NERDTree if no files where specifiedautocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif " Close vim if the only window left open is a NERDTreenmap <F5> :NERDTreeToggle<cr>
" Search results high lightset hlsearch
" nohlsearch shortcutnmap -hl :nohlsearch<cr>nmap +hl :set hlsearch<cr>
" Javascript syntax hightlightsyntax enable
" CtrlPlet g:ctrlp_map = '<c-p>'let g:ctrlp_cmd = 'CtrlP'set wildignore+=*/tmp/*,*.so,*.swp,*.ziplet g:ctrlp_custom_ignore = '\v[\/](node_modules|DS_Store|target|dist)|(\.(swp|ico|git|svn))$'let g:ctrlp_working_path_mode=0
nnoremap <leader>w :w<CR>nnoremap <leader>q :q<CR>
" Vim-instant-markdown doesn't work in zshset shell=bash\ -i
let maplocalleader = "\\"autocmd FileType javascript nnoremap <buffer> <localleader>c I//<esc>autocmd FileType python nnoremap <buffer> <localleader>c I#<esc>
" Local configif filereadable($HOME . "/.vimrc.local") source ~/.vimrc.localendifMy .vimrc.bundles
$ git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vimif &compatible set nocompatibleend
filetype offset rtp+=~/.vim/bundle/Vundle.vimcall vundle#rc()
" Define bundles via Github reposBundle "VundleVim/Vundle.vim"Bundle "danro/rename.vim"Bundle "pbrisbin/vim-mkdir"Bundle "scrooloose/nerdtree"Bundle "pangloss/vim-javascript"Bundle "mxw/vim-jsx"Bundle "altercation/vim-colors-solarized"Bundle "othree/html5.vim"Bundle "tomasr/molokai"Bundle "ctrlpvim/ctrlp.vim"Bundle "leafgarland/typescript-vim"Bundle "itchyny/lightline.vim"
if filereadable(expand("~/.vimrc.bundles.local")) source ~/.vimrc.bundles.localendif
filetype onPure vimrc
set number " 显示行号set cursorline " 高亮当前行set autoindent " 自动缩进set smartindent " 智能缩进set tabstop=2 " 设置 Tab 宽度为2个空格set shiftwidth=2 " 每次自动缩进的宽度为2个空格set expandtab " 将 Tab 替换为空格
set ignorecase " 搜索时忽略大小写set smartcase " 智能区分大小写set hlsearch " 高亮搜索结果set incsearch " 搜索时逐字符高亮
syntax on " 启用语法高亮set background=dark " 适合深色背景的配色方案colorscheme desert " 使用 desert 配色(可替换为其他配色方案)
set timeoutlen=500 " 设置按键延迟时间为500msset updatetime=300 " 设置更新屏幕间隔时间为300ms
highlight EndOfBuffer ctermbg=NONE guibg=NONEhighlight Normal ctermbg=NONE guibg=NONE0 条评论
- 最新
- 最热
- 最早
- 作者
关闭评论
「此时无声胜有声」