Skip to content

Instantly share code, notes, and snippets.

@orivee
Forked from keelii/vimrc
Created August 21, 2017 12:32
Show Gist options
  • Save orivee/8f201b10f8ae83c575ce5596718a692f to your computer and use it in GitHub Desktop.
Save orivee/8f201b10f8ae83c575ce5596718a692f to your computer and use it in GitHub Desktop.

Revisions

  1. @keelii keelii revised this gist Jun 12, 2016. 1 changed file with 66 additions and 35 deletions.
    101 changes: 66 additions & 35 deletions vimrc
    Original file line number Diff line number Diff line change
    @@ -12,18 +12,21 @@ au!

    autocmd FileType text setlocal textwidth=78

    autocmd BufReadPost *
    \ if line("'\"") >= 1 && line("'\"") <= line("$") |
    \ exe "normal! g`\"" |
    \ endif

    augroup END

    " vim 文件折叠方式为 marker
    augroup ft_vim
    au!

    au FileType vim setlocal foldmethod=marker
    autocmd FileType vim setlocal foldmethod=marker

    " 打开文件总是定位到上次编辑的位置
    autocmd BufReadPost *
    \ if line("'\"") > 1 && line("'\"") <= line("$") |
    \ exe "normal! g`\"" |
    \ endif

    augroup END
    augroup END
    " }}}

    @@ -71,31 +74,46 @@ set guioptions-=r
    set guioptions-=b
    " 使用内置 tab 样式而不是 gui
    set guioptions-=e
    set nolist
    " set listchars=tab:▶\ ,eol:¬,trail:·,extends:>,precedes:<
    " set nolist
    set listchars=trail:·,extends:>,precedes:<
    set guifont=Inconsolata:h12:cANSI

    set statusline=%f
    set statusline+=%m
    set statusline+=\ %{fugitive#head()}
    set statusline+=%=
    set statusline+=%{''.(&fenc!=''?&fenc:&enc).''}
    set statusline+=/
    set statusline +=%{&ff} "file format
    set statusline+=\ -\ " Separator
    set statusline+=%l/%L
    set statusline+=[%p%%]
    set statusline+=\ -\ " Separator
    set statusline +=%1*\ %y\ %*

    " }}}

    " Format {{{
    set autoindent
    set smartindent
    set tabstop=4
    set expandtab
    set shiftwidth=4
    set softtabstop=4
    set expandtab
    set foldmethod=indent
    syntax on
    " }}}

    " Keymap {{{
    let mapleader=","

    nmap <leader>s :source $VIM/_vimrc<cr>
    nmap <leader>e :e $VIM/_vimrc<cr>
    nmap <leader>s :source $MYVIMRC<cr>
    nmap <leader>e :e $MYVIMRC<cr>
    map <leader>tn :tabnew<cr>
    map <leader>tc :tabclose<cr>
    map <leader>th :tabp<cr>
    map <leader>tl :tabn<cr>
    nmap <leader>tn :tabnew<cr>
    nmap <leader>tc :tabclose<cr>
    nmap <leader>th :tabp<cr>
    nmap <leader>tl :tabn<cr>
    " 移动分割窗口
    nmap <C-j> <C-W>j
    @@ -142,12 +160,12 @@ exe 'inoremap <script> <C-V>' paste#paste_cmd['i']
    exe 'vnoremap <script> <C-V>' paste#paste_cmd['v']

    " 打开当前目录 windows
    map <leader>ex :!start explorer %:p:h<CR>
    nmap <silent> <leader>ex :!start explorer %:p:h<CR>
    " 打开当前目录CMD
    map <leader>cmd :!start<cr>
    nmap <silent> <leader>cmd :!start cmd /k cd %:p:h<cr>
    " 打印当前时间
    map <F3> a<C-R>=strftime("%Y-%m-%d %a %I:%M %p")<CR><Esc>
    nmap <F3> a<C-R>=strftime("%Y-%m-%d %a %I:%M %p")<CR><Esc>
    let NERDTreeBookmarksFile = $VIM . '/NERDTreeBookmarks'

    @@ -164,8 +182,8 @@ nnoremap <C-right> :bp<CR>
    " Plugin {{{
    filetype off

    set rtp+=$VIM/vimfiles/bundle/Vundle.vim/
    call vundle#begin('$VIM/vimfiles/bundle/')
    set rtp+=$VIM/vimfiles/bundle/Vundle.vim
    call vundle#begin('$VIM/vimfiles/bundle')

    " ----- Vundle ----- {{{
    Plugin 'VundleVim/Vundle.vim'
    @@ -176,36 +194,43 @@ Plugin 'scrooloose/nerdtree'
    let NERDTreeIgnore=['.idea', '.vscode', 'node_modules', '*.pyc']
    let NERDTreeBookmarksFile = $VIM . '/NERDTreeBookmarks'
    let NERDTreeMinimalUI = 1
    let NERDTreeBookmarksSort = 1
    let NERDTreeShowLineNumbers = 0
    let NERDTreeShowBookmarks = 1
    let g:NERDTreeWinPos = "right"
    let g:NERDTreeWinPos = 'right'
    let g:NERDTreeDirArrowExpandable = ''
    let g:NERDTreeDirArrowCollapsible = ''
    nmap <leader>n :NERDTreeToggle <cr>
    autocmd vimenter * NERDTree D:\repo
    if exists('g:NERDTreeWinPos')
    autocmd vimenter * NERDTree D:\repo
    endif
    " }}}
    " ----- Multiple-cursors ----- {{{
    Plugin 'terryma/vim-multiple-cursors'
    " }}}
    " ----- Tabular ----- {{{
    Plugin 'godlygeek/tabular'
    " }}}
    " ----- Markdown ----- {{{
    Plugin 'plasticboy/vim-markdown'
    " }}}
    " ----- Airline ----- {{{
    Plugin 'vim-airline/vim-airline'
    Plugin 'vim-airline/vim-airline-themes'
    set laststatus=2
    "Plugin 'vim-airline/vim-airline'
    "Plugin 'vim-airline/vim-airline-themes'
    "set laststatus=2

    if !exists('g:airline_symbols')
    let g:airline_symbols = {}
    endif
    let g:airline_theme="tomorrow"
    let g:airline_powerline_fonts = 1
    let g:Powerline_symbols="fancy"
    "if !exists('g:airline_symbols')
    "let g:airline_symbols = {}
    "endif
    "let g:airline_theme='tomorrow'
    "let g:airline_powerline_fonts = 1
    "let g:Powerline_symbols='fancy'

    " let g:airline_symbols.branch = ''
    " let g:airline_left_sep = '»'
    " let g:airline_right_sep = '«'
    let g:airline#extensions#branch#enabled = 1
    let g:airline#extensions#branch#vcs_priority = ["git", "mercurial"]
    "let g:airline#extensions#branch#enabled = 1
    "let g:airline#extensions#branch#vcs_priority = ["git", "mercurial"]
    " let g:airline_mode_map = {
    " \ 'n' : 'N',
    " \ 'i' : 'I',
    @@ -229,7 +254,10 @@ Plugin 'mattn/emmet-vim'
    Plugin 'MarcWeber/vim-addon-mw-utils'
    Plugin 'tomtom/tlib_vim'
    Plugin 'garbas/vim-snipmate'
    Plugin 'honza/vim-snippets'
    " Replace your repo
    Plugin 'keelii/vim-snippets'
    " Allow for vimrc re-sourcing
    let g:snipMate = get(g:, 'snipMate', {})
    " }}}
    " ----- Fugitive ----- {{{
    Plugin 'tpope/vim-fugitive'
    @@ -242,6 +270,10 @@ let g:neocomplete#enable_at_startup = 1
    " Use smartcase.
    let g:neocomplete#enable_smart_case = 1
    let g:neocomplete#enable_auto_select = 1
    " Enable snipMate compatibility feature.
    let g:neosnippet#enable_snipmate_compatibility = 1
    " Tell Neosnippet about the other snippets
    let g:neosnippet#snippets_directory=$VIM . '/vimfiles/bundle/vim-snippets/snippets'

    " Enable omni completion.
    autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
    @@ -252,7 +284,6 @@ autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
    if !exists('g:neocomplete#sources#omni#input_patterns')
    let g:neocomplete#sources#omni#input_patterns = {}
    endif

    " }}}

    filetype on
  2. @keelii keelii revised this gist Jun 9, 2016. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions vimrc
    Original file line number Diff line number Diff line change
    @@ -71,8 +71,8 @@ set guioptions-=r
    set guioptions-=b
    " 使用内置 tab 样式而不是 gui
    set guioptions-=e
    " set nolist
    set listchars=trail:·,extends:>,precedes:<
    set nolist
    " set listchars=tab:▶\ ,eol:¬,trail:·,extends:>,precedes:<
    set guifont=Inconsolata:h12:cANSI
    " }}}

  3. @keelii keelii renamed this gist Jun 9, 2016. 1 changed file with 47 additions and 27 deletions.
    74 changes: 47 additions & 27 deletions gistfile1.txt → vimrc
    Original file line number Diff line number Diff line change
    @@ -71,8 +71,8 @@ set guioptions-=r
    set guioptions-=b
    " 使用内置 tab 样式而不是 gui
    set guioptions-=e
    set nolist
    " set listchars=tab:▶\ ,eol:¬,trail:·,extends:>,precedes:<
    " set nolist
    set listchars=trail:·,extends:>,precedes:<
    set guifont=Inconsolata:h12:cANSI
    " }}}

    @@ -133,10 +133,10 @@ vmap <C-c> "+y
    vnoremap <BS> d
    vnoremap <C-C> "+y
    vnoremap <C-Insert> "+y
    imap <C-V> "+gP
    map <S-Insert> "+gP
    cmap <C-V> <C-R>+
    cmap <S-Insert> <C-R>+
    imap <C-V> "+gP
    map <S-Insert> "+gP
    cmap <C-V> <C-R>+
    cmap <S-Insert> <C-R>+
    exe 'inoremap <script> <C-V>' paste#paste_cmd['i']
    exe 'vnoremap <script> <C-V>' paste#paste_cmd['v']
    @@ -149,9 +149,6 @@ map <leader>cmd :!start<cr>
    " 打印当前时间
    map <F3> a<C-R>=strftime("%Y-%m-%d %a %I:%M %p")<CR><Esc>
    " 快捷键「,s」更新 vimrc 文件;「,e」打开 vimrc 文件
    nmap <leader>s :source $VIM/_vimrc<cr>
    nmap <leader>e :e $VIM/_vimrc<cr>
    let NERDTreeBookmarksFile = $VIM . '/NERDTreeBookmarks'

    " 复制当前文件/路径到剪贴板
    @@ -170,10 +167,10 @@ filetype off
    set rtp+=$VIM/vimfiles/bundle/Vundle.vim/
    call vundle#begin('$VIM/vimfiles/bundle/')

    " ----- Vundle -----
    " ----- Vundle ----- {{{
    Plugin 'VundleVim/Vundle.vim'

    " ----- NerdTree -----
    " }}}
    " ----- NerdTree ----- {{{
    Plugin 'scrooloose/nerdtree'

    let NERDTreeIgnore=['.idea', '.vscode', 'node_modules', '*.pyc']
    @@ -185,14 +182,14 @@ let g:NERDTreeDirArrowExpandable = '▸'
    let g:NERDTreeDirArrowCollapsible = ''
    nmap <leader>n :NERDTreeToggle <cr>
    autocmd vimenter * NERDTree D:\repo

    " ----- Multiple-cursors -----
    " }}}
    " ----- Multiple-cursors ----- {{{
    Plugin 'terryma/vim-multiple-cursors'

    " ----- Tabular -----
    " }}}
    " ----- Tabular ----- {{{
    Plugin 'godlygeek/tabular'

    " ----- Airline -----
    " }}}
    " ----- Airline ----- {{{
    Plugin 'vim-airline/vim-airline'
    Plugin 'vim-airline/vim-airline-themes'
    set laststatus=2
    @@ -216,24 +213,47 @@ let g:airline#extensions#branch#vcs_priority = ["git", "mercurial"]
    " \ }
    " let g:airline#extensions#tabline#enabled = 1

    " ----- Ctrlp -----
    " }}}
    " ----- Ctrlp ----- {{{
    Plugin 'kien/ctrlp.vim'
    let g:ctrlp_match_window = 'bottom,order:btt,min:1,max:10,results:10'
    set wildignore+=*\\.git\\*,*\\tmp\\*,*.swp,*.zip,*.exe,*.pyc

    " ----- Nerdcommenter -----
    " }}}
    " ----- Nerdcommenter ----- {{{
    Plugin 'scrooloose/nerdcommenter'

    " ----- Emmet -----
    " }}}
    " ----- Emmet ----- {{{
    Plugin 'mattn/emmet-vim'

    " ----- SnipMate -----
    " }}}
    " ----- SnipMate ----- {{{
    Plugin 'MarcWeber/vim-addon-mw-utils'
    Plugin 'tomtom/tlib_vim'
    Plugin 'garbas/vim-snipmate'

    " ----- Fugitive -----
    Plugin 'honza/vim-snippets'
    " }}}
    " ----- Fugitive ----- {{{
    Plugin 'tpope/vim-fugitive'
    " }}}
    " ----- Neocomplete ----- {{{
    Plugin 'Shougo/neocomplete.vim'
    let g:acp_enableAtStartup = 0
    " Use neocomplete.
    let g:neocomplete#enable_at_startup = 1
    " Use smartcase.
    let g:neocomplete#enable_smart_case = 1
    let g:neocomplete#enable_auto_select = 1

    " Enable omni completion.
    autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
    autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
    autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
    autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
    autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
    if !exists('g:neocomplete#sources#omni#input_patterns')
    let g:neocomplete#sources#omni#input_patterns = {}
    endif

    " }}}

    filetype on
    call vundle#end()
  4. @keelii keelii revised this gist Jun 7, 2016. 1 changed file with 22 additions and 4 deletions.
    26 changes: 22 additions & 4 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -4,9 +4,6 @@
    " Email: [email protected]
    " ------------------------------

    " Vundle {{{
    " }}}

    " Startup {{{
    filetype indent plugin on

    @@ -63,6 +60,9 @@ set hlsearch
    set number
    " 窗口大小
    set lines=35 columns=140
    " 分割出来的窗口位于当前窗口下边/右边
    set splitbelow
    set splitright
    "不显示工具/菜单栏
    set guioptions-=T
    set guioptions-=m
    @@ -177,10 +177,10 @@ Plugin 'VundleVim/Vundle.vim'
    Plugin 'scrooloose/nerdtree'

    let NERDTreeIgnore=['.idea', '.vscode', 'node_modules', '*.pyc']
    let g:NERDTreeWinPos = "right"
    let NERDTreeBookmarksFile = $VIM . '/NERDTreeBookmarks'
    let NERDTreeMinimalUI = 1
    let NERDTreeShowBookmarks = 1
    let g:NERDTreeWinPos = "right"
    let g:NERDTreeDirArrowExpandable = '▸'
    let g:NERDTreeDirArrowCollapsible = '▾'
    nmap <leader>n :NERDTreeToggle <cr>
    @@ -196,9 +196,24 @@ Plugin 'godlygeek/tabular'
    Plugin 'vim-airline/vim-airline'
    Plugin 'vim-airline/vim-airline-themes'
    set laststatus=2

    if !exists('g:airline_symbols')
    let g:airline_symbols = {}
    endif
    let g:airline_theme="tomorrow"
    let g:airline_powerline_fonts = 1
    let g:Powerline_symbols="fancy"

    " let g:airline_symbols.branch = ''
    " let g:airline_left_sep = '»'
    " let g:airline_right_sep = '«'
    let g:airline#extensions#branch#enabled = 1
    let g:airline#extensions#branch#vcs_priority = ["git", "mercurial"]
    " let g:airline_mode_map = {
    " \ 'n' : 'N',
    " \ 'i' : 'I',
    " \ 'v' : 'V',
    " \ }
    " let g:airline#extensions#tabline#enabled = 1

    " ----- Ctrlp -----
    @@ -217,6 +232,9 @@ Plugin 'MarcWeber/vim-addon-mw-utils'
    Plugin 'tomtom/tlib_vim'
    Plugin 'garbas/vim-snipmate'

    " ----- Fugitive -----
    Plugin 'tpope/vim-fugitive'

    filetype on
    call vundle#end()
    " }}}
  5. @keelii keelii created this gist Jun 6, 2016.
    238 changes: 238 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,238 @@
    " ------------------------------
    " Name: vimrc for windows
    " Author: keelii
    " Email: [email protected]
    " ------------------------------

    " Vundle {{{
    " }}}

    " Startup {{{
    filetype indent plugin on

    augroup vimrcEx
    au!

    autocmd FileType text setlocal textwidth=78

    autocmd BufReadPost *
    \ if line("'\"") >= 1 && line("'\"") <= line("$") |
    \ exe "normal! g`\"" |
    \ endif

    augroup END

    " vim 文件折叠方式为 marker
    augroup ft_vim
    au!

    au FileType vim setlocal foldmethod=marker
    augroup END
    " }}}

    " General {{{
    set nocompatible
    set nobackup
    set noswapfile
    set history=1024
    set autochdir
    set whichwrap=b,s,<,>,[,]
    set nobomb
    set backspace=indent,eol,start whichwrap+=<,>,[,]
    " Vim 的默认寄存器和系统剪贴板共享
    set clipboard+=unnamed
    " 设置 alt 键不映射到菜单栏
    set winaltkeys=no
    " }}}

    " Lang & Encoding {{{
    set fileencodings=utf-8,gbk2312,gbk,gb18030,cp936
    set encoding=utf-8
    set langmenu=zh_CN
    let $LANG = 'en_US.UTF-8'
    "language messages zh_CN.UTF-8
    " }}}

    " GUI {{{
    colorscheme Tomorrow-Night

    source $VIMRUNTIME/delmenu.vim
    source $VIMRUNTIME/menu.vim
    set cursorline
    set hlsearch
    set number
    " 窗口大小
    set lines=35 columns=140
    "不显示工具/菜单栏
    set guioptions-=T
    set guioptions-=m
    set guioptions-=L
    set guioptions-=r
    set guioptions-=b
    " 使用内置 tab 样式而不是 gui
    set guioptions-=e
    set nolist
    " set listchars=tab:▶\ ,eol:¬,trail:·,extends:>,precedes:<
    set guifont=Inconsolata:h12:cANSI
    " }}}

    " Format {{{
    set autoindent
    set smartindent
    set tabstop=4
    set expandtab
    set softtabstop=4
    set foldmethod=indent
    syntax on
    " }}}

    " Keymap {{{
    let mapleader=","

    nmap <leader>s :source $VIM/_vimrc<cr>
    nmap <leader>e :e $VIM/_vimrc<cr>

    map <leader>tn :tabnew<cr>
    map <leader>tc :tabclose<cr>
    map <leader>th :tabp<cr>
    map <leader>tl :tabn<cr>

    " 移动分割窗口
    nmap <C-j> <C-W>j
    nmap <C-k> <C-W>k
    nmap <C-h> <C-W>h
    nmap <C-l> <C-W>l

    " 正常模式下 alt+j,k,h,l 调整分割窗口大小
    nnoremap <M-j> :resize +5<cr>
    nnoremap <M-k> :resize -5<cr>
    nnoremap <M-h> :vertical resize -5<cr>
    nnoremap <M-l> :vertical resize +5<cr>

    " 插入模式移动光标 alt + 方向键
    inoremap <M-j> <Down>
    inoremap <M-k> <Up>
    inoremap <M-h> <left>
    inoremap <M-l> <Right>

    " IDE like delete
    inoremap <C-BS> <Esc>bdei

    nnoremap vv ^vg_
    " 转换当前行为大写
    inoremap <C-u> <esc>mzgUiw`za
    " 命令模式下的行首尾
    cnoremap <C-a> <home>
    cnoremap <C-e> <end>

    nnoremap <F2> :setlocal number!<cr>
    nnoremap <leader>w :set wrap!<cr>

    imap <C-v> "+gP
    vmap <C-c> "+y
    vnoremap <BS> d
    vnoremap <C-C> "+y
    vnoremap <C-Insert> "+y
    imap <C-V> "+gP
    map <S-Insert> "+gP
    cmap <C-V> <C-R>+
    cmap <S-Insert> <C-R>+

    exe 'inoremap <script> <C-V>' paste#paste_cmd['i']
    exe 'vnoremap <script> <C-V>' paste#paste_cmd['v']

    " 打开当前目录 windows
    map <leader>ex :!start explorer %:p:h<CR>

    " 打开当前目录CMD
    map <leader>cmd :!start<cr>
    " 打印当前时间
    map <F3> a<C-R>=strftime("%Y-%m-%d %a %I:%M %p")<CR><Esc>

    " 快捷键「,s」更新 vimrc 文件;「,e」打开 vimrc 文件
    nmap <leader>s :source $VIM/_vimrc<cr>
    nmap <leader>e :e $VIM/_vimrc<cr>
    let NERDTreeBookmarksFile = $VIM . '/NERDTreeBookmarks'

    " 复制当前文件/路径到剪贴板
    nmap ,fn :let @*=substitute(expand("%"), "/", "\\", "g")<CR>
    nmap ,fp :let @*=substitute(expand("%:p"), "/", "\\", "g")<CR>

    "设置切换Buffer快捷键"
    nnoremap <C-left> :bn<CR>
    nnoremap <C-right> :bp<CR>

    " }}}

    " Plugin {{{
    filetype off

    set rtp+=$VIM/vimfiles/bundle/Vundle.vim/
    call vundle#begin('$VIM/vimfiles/bundle/')

    " ----- Vundle -----
    Plugin 'VundleVim/Vundle.vim'

    " ----- NerdTree -----
    Plugin 'scrooloose/nerdtree'

    let NERDTreeIgnore=['.idea', '.vscode', 'node_modules', '*.pyc']
    let g:NERDTreeWinPos = "right"
    let NERDTreeBookmarksFile = $VIM . '/NERDTreeBookmarks'
    let NERDTreeMinimalUI = 1
    let NERDTreeShowBookmarks = 1
    let g:NERDTreeDirArrowExpandable = '▸'
    let g:NERDTreeDirArrowCollapsible = '▾'
    nmap <leader>n :NERDTreeToggle <cr>
    autocmd vimenter * NERDTree D:\repo

    " ----- Multiple-cursors -----
    Plugin 'terryma/vim-multiple-cursors'

    " ----- Tabular -----
    Plugin 'godlygeek/tabular'

    " ----- Airline -----
    Plugin 'vim-airline/vim-airline'
    Plugin 'vim-airline/vim-airline-themes'
    set laststatus=2
    let g:airline_theme="tomorrow"
    let g:airline_powerline_fonts = 1
    let g:Powerline_symbols="fancy"
    " let g:airline#extensions#tabline#enabled = 1

    " ----- Ctrlp -----
    Plugin 'kien/ctrlp.vim'
    let g:ctrlp_match_window = 'bottom,order:btt,min:1,max:10,results:10'
    set wildignore+=*\\.git\\*,*\\tmp\\*,*.swp,*.zip,*.exe,*.pyc

    " ----- Nerdcommenter -----
    Plugin 'scrooloose/nerdcommenter'

    " ----- Emmet -----
    Plugin 'mattn/emmet-vim'

    " ----- SnipMate -----
    Plugin 'MarcWeber/vim-addon-mw-utils'
    Plugin 'tomtom/tlib_vim'
    Plugin 'garbas/vim-snipmate'

    filetype on
    call vundle#end()
    " }}}

    " Function {{{
    " Remove trailing whitespace when writing a buffer, but not for diff files.
    " From: Vigil
    " @see http://blog.bs2.to/post/EdwardLee/17961
    function! RemoveTrailingWhitespace()
    if &ft != "diff"
    let b:curcol = col(".")
    let b:curline = line(".")
    silent! %s/\s\+$//
    silent! %s/\(\s*\n\)\+\%$//
    call cursor(b:curline, b:curcol)
    endif
    endfunction
    autocmd BufWritePre * call RemoveTrailingWhitespace()
    " }}}