" ================================================ " INITIALIZATION " ================================================ set nocompatible set nobackup set fileencoding=utf8 encoding=utf8 set history=50 " keep 40 lines of command line history set autoindent " always set autoindenting on set incsearch " do incremental searching set autoread " auto read changed files set showcmd " display incomplete commands set number " turn on lines number set ruler " turn on status line on bottom right corner " set nofixendofline " turn off end of line on every file " set cursorline " highlight current line " set cursorcolumn " highlight current column " set ff=unix " set linebreak to return " set ffs=unix,dos set backspace=indent,eol,start set shiftwidth=4 tabstop=4 softtabstop=4 expandtab let mapleader = "," " map to for convenience autocmd FileType help wincmd L " open help window vertically on the right filetype plugin indent on if has("win32") source $VIMRUNTIME/mswin.vim nnoremap :call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0) inoremap :call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0)a endif if has("win64") nnoremap :call libcallnr("gvimfullscreen_x64.dll", "ToggleFullScreen", 0) inoremap :call libcallnr("gvimfullscreen_x64.dll", "ToggleFullScreen", 0)a endif if has("gui_running") set guioptions='' " remove all extra GUI components set mouse=a set lines=36 columns=128 " consistent window size winpos 200 160 colorscheme solarized else color monokai endif " switch syntax highlighting on, when the terminal has colors " also switch on highlight the last used search pattern if &t_Co > 2 || has("gui_running") syntax on set hlsearch endif if has("autocmd") autocmd BufReadPost * \ if line("'\"") > 1 && line("'\"") <= line("$") | \ exe "normal! g`\"" | \ endif endif " ================================================ " KEY BINDINGS " ================================================ " for manipulating vimrc(valid when vimrc in $HOME dir) nnoremap ev :vsplit $MYVIMRC nmap sv :source $MYVIMRC " for managing tabs nmap :tabnew imap :tabnew nmap :tabclose imap :tabclose nmap :tabprevious imap :tabprevious nmap :tabnext imap :tabnext " toggle highlight search nmap th :set nohlsearch! " treat long lines as break lines nmap j gj nmap k gk " spell check nmap ts :setlocal spell! nmap sn ]s nmap sp [s nmap sa zg nmap ss z= " shortcuts for common tasks nmap :w imap :w nmap q :q " simulate emacs in insert mode inoremap inoremap inoremap inoremap inoremap inoremap " for jumping to specific window quickly noremap j noremap k noremap l noremap h " increase and decrease window size noremap :vertical resize -2 noremap :vertical resize +2 noremap :resize -2 noremap :resize +2 " ================================================ " ABBREVIATIONS " ================================================ iab xtime =strftime("%Y-%m-%d %H:%M:%S") iab xdate =strftime("%Y-%m-%d") " ================================================ " PLUGINS " ================================================ " pathogen execute pathogen#infect() " nerdtree let NERDTreeQuitOnOpen = 1 nmap :NERDTreeToggle " tagbar nmap :TagbarToggle " lightline let g:lightline = {'colorscheme': 'solarized'} " vim-markdown au FileType md set filetype=mkd let g:vim_markdown_folding_disabled=2 " calendar let g:calendar_monday = 1 if has("win32") let g:calendar_diary = "D:/Backup/Calendar" else let g:calendar_diary = "~/.calendar" endif " colorizer nmap ch :ColorHighlight nmap cc :ColorClear let g:colorizer_auto_filetype='css,html,vue' " nerdcommenter let g:NERDSpaceDelims = 1 " Add spaces after comment delimiters by default " let g:NERDCompactSexyComs = 1 " Use compact syntax for prettified multi-line comments " let g:NERDDefaultAlign = 'left' " Align line-wise comment delimiters flush left instead of following code indentation " let g:NERDAltDelims_java = 1 " Set a language to use its alternate delimiters by default " let g:NERDCustomDelimiters = { 'c': { 'left': '/**','right': '*/' } } " Add your own custom formats or override the defaults " let g:NERDCommentEmptyLines = 1 " Allow commenting and inverting empty lines (useful when commenting a region) let g:NERDTrimTrailingWhitespace = 1 " Enable trimming of trailing whitespace when uncommenting " vim-table-mode let g:table_mode_corner='|' nmap ttm :TableModeToggle " vim-gitgutter nmap :GitGutterToggle imap :GitGutterToggle let g:gitgutter_enabled = 0 let g:gitgutter_highlight_lines = 1 let g:UltiSnipsExpandTrigger="" let g:UltiSnipsJumpForwardTrigger="" let g:UltiSnipsJumpBackwardTrigger="" " git nmap :Gblame " switch tab width between 4(default) and 2 fun! SetTabWidth() if &shiftwidth == 4 let width = 2 else let width = 4 endif exe "set shiftwidth=" . width . " tabstop=" . width . " softtabstop=" . width . " expandtab" endfun " switch font between fixedsys and Consolas fun! SwitchFont() if &guifont == 'fixedsys' exec "set guifont=Consolas:h14:cANSI:qDRAFT" else exec "set guifont=fixedsys" endif endfun " toggle line/column highlight fun! SwitchCrossHighlight() if &cursorline == 0 exec "set cursorline" exec "set cursorcolumn" else exec "set nocursorline" exec "set nocursorcolumn" endif endfunc nmap :call SetTabWidth() nmap :call SwitchFont() nmap :call SwitchCrossHighlight() " ================================================ " FILE SPECIFIC CONFIGURATION " ================================================ " autocmd FileType vue syntax sync fromstart " vue " let g:html_indent_inctags = "html,head,body" " html nmap :silent ! compass compile %