Created
September 25, 2018 09:09
-
-
Save pekrockstar/85dad25d8a20cd9d463a723af657e633 to your computer and use it in GitHub Desktop.
vimrc
This file contains hidden or 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
"=================================================================================== | |
" FILE: .vimrc | |
" DESCRIPTION: suggestion for a personal configuration file ~/.vimrc | |
" AUTHOR: rockagen <[email protected]> | |
" CREATED: 2014 | |
"=================================================================================== | |
" | |
"=================================================================================== | |
" GENERAL SETTINGS | |
"=================================================================================== | |
"------------------------------------------------------------------------------- | |
" Use Vim settings, rather then Vi settings. | |
" This must be first, because it changes other options as a side effect. | |
"------------------------------------------------------------------------------- | |
set nocompatible | |
let mapleader="," | |
" | |
"------------------------------------------------------------------------------- | |
" Switch syntax highlighting on. | |
"------------------------------------------------------------------------------- | |
syntax on | |
colorscheme cobalt | |
" | |
"------------------------------------------------------------------------------- | |
" Various settings | |
"------------------------------------------------------------------------------- | |
set autoindent " copy indent from current line | |
set autoread " read open files again when changed outside Vim | |
set autowrite " write a modified buffer on each :next , ... | |
set backspace=indent,eol,start " backspacing over everything in insert mode | |
set backup " keep a backup file | |
set browsedir=current " which directory to use for the file browser | |
set complete+=k " scan the files given with the 'dictionary' option | |
set history=50 " keep 50 lines of command line history | |
set hlsearch " highlight the last used search pattern | |
set incsearch " do incremental searching | |
set listchars=tab:>.,eol:\$ " strings to use in 'list' mode | |
set mouse=a " enable the use of the mouse | |
set nowrap " do not wrap lines | |
set popt=left:8pc,right:3pc " print options | |
set ruler " show the cursor position all the time | |
set showcmd " display incomplete commands | |
set smartindent " smart autoindenting when starting a new line | |
set shiftwidth=4 " number of spaces to use for each step of indent | |
set tabstop=4 " number of spaces that a <Tab> counts for | |
set expandtab " expand tab to space characters | |
set visualbell " visual bell instead of beeping | |
set wildignore=*.bak,*.o,*.e,*~ " wildmenu: ignore these extensions | |
set wildmenu " command-line completion in an enhanced mode | |
" | |
"=================================================================================== | |
" BUFFERS, WINDOWS | |
"=================================================================================== | |
" | |
"------------------------------------------------------------------------------- | |
" The current directory is the directory of the file in the current window. | |
"------------------------------------------------------------------------------- | |
if has("autocmd") | |
autocmd BufEnter * :lchdir %:p:h | |
endif | |
" | |
"------------------------------------------------------------------------------- | |
map <silent> <leader>q :q!<CR> | |
map <silent> <leader>w :w<CR> | |
map <silent> <leader>x :x<CR> | |
map <silent> <leader>t :tabnew<CR> | |
nnoremap <silent> <C-l> :nohl<CR><C-l> | |
" | |
"------------------------------------------------------------------------------- | |
" Fast switching between buffers | |
" The current buffer will be saved before switching to the next one. | |
" Choose :bprevious or :bnext | |
"------------------------------------------------------------------------------- | |
noremap <silent> <s-tab> :if &modifiable && !&readonly && | |
\ &modified <CR> :write<CR> :endif<CR>:bprevious<CR> | |
inoremap <silent> <s-tab> <C-C>:if &modifiable && !&readonly && | |
\ &modified <CR> :write<CR> :endif<CR>:bprevious<CR> | |
" | |
"------------------------------------------------------------------------------- | |
" When editing a file, always jump to the last known cursor position. | |
" Don't do it when the position is invalid or when inside an event handler | |
" (happens when dropping a file on gvim). | |
"------------------------------------------------------------------------------- | |
if has("autocmd") | |
autocmd BufReadPost * | |
\ if line("'\"") > 0 && line("'\"") <= line("$") | | |
\ exe "normal! g`\"" | | |
\ endif | |
endif " has("autocmd") | |
" | |
"-------------------------------------------------------------------------------z | |
" some additional hot keys | |
"------------------------------------------------------------------------------- | |
" F2 - write file without confirmation | |
" F3 - call file explorer Ex | |
" F4 - paster mode | |
" F5 - open quickfix error window | |
" F6 - close quickfix error window | |
" F7 - display previous error | |
" F8 - fold creation bracket | |
" F9 - fold creation bracket | |
"------------------------------------------------------------------------------- | |
" | |
map <silent> <F2> :w !sudo tee % <CR> | |
set pastetoggle=<F4> | |
" nerdtree instead. | |
" map <silent> <F3> :Explore<CR> | |
map <silent> <F5> :e!<CR> | |
nnoremap <F10> zf% | |
nnoremap <F9> zi | |
" | |
" | |
"------------------------------------------------------------------------------- | |
" Fast switching between buffers | |
" The current buffer will be saved before switching to the next one. | |
" Choose :bprevious or :bnext | |
"------------------------------------------------------------------------------- | |
" | |
map <silent> <s-tab> <Esc>:if &modifiable && !&readonly && | |
\ &modified <CR> :write<CR> :endif<CR>:bprevious<CR> | |
imap <silent> <s-tab> <Esc>:if &modifiable && !&readonly && | |
\ &modified <CR> :write<CR> :endif<CR>:bprevious<CR> | |
" | |
"------------------------------------------------------------------------------- | |
" comma always followed by a space | |
"------------------------------------------------------------------------------- | |
inoremap , ,<Space> | |
" | |
"------------------------------------------------------------------------------- | |
" autocomplete parenthesis, brackets and braces | |
"------------------------------------------------------------------------------- | |
inoremap ( ()<Left> | |
inoremap [ []<Left> | |
inoremap { {}<Left> | |
" | |
vnoremap ( s()<Esc>P<Right>% | |
vnoremap [ s[]<Esc>P<Right>% | |
vnoremap { s{}<Esc>P<Right>% | |
" | |
"------------------------------------------------------------------------------- | |
" autocomplete quotes (visual and select mode) | |
"------------------------------------------------------------------------------- | |
xnoremap ' s''<Esc>P<Right> | |
xnoremap " s""<Esc>P<Right> | |
xnoremap ` s``<Esc>P<Right> | |
" | |
"------------------------------------------------------------------------------- | |
" Change the working directory to the directory containing the current file | |
"------------------------------------------------------------------------------- | |
if has("autocmd") | |
autocmd BufEnter * :lchdir %:p:h | |
endif " has("autocmd") | |
" | |
" | |
"------------------------------------------------------------------------------- | |
" tool map | |
"------------------------------------------------------------------------------- | |
noremap <silent> <leader>j :%! python -m json.tool<CR> | |
vnoremap <leader>y "+y<CR> | |
" | |
"------------------------------------------------------------------------------- | |
" normal theme config | |
"------------------------------------------------------------------------------- | |
" theme | |
set laststatus=2 | |
set t_Co=256 | |
set encoding=utf8 | |
set nu | |
" set window size | |
set lines=32 columns=104 | |
" set encoding | |
set fileencodings=utf-8,gbk,gb2312,cp936,ucs-bom,gb18030 | |
" set cursorline | |
set cursorline | |
" hi CursorLine ctermfg=NONE ctermbg=0B649F | |
" set cursorcolumn | |
" set backup dir | |
let s:vimbd='/tmp/vimbd/'.$LOGNAME | |
if !isdirectory(s:vimbd) | |
call mkdir(s:vimbd,'p') | |
endif | |
let &backupdir=escape(s:vimbd,' ') | |
unlet! s:vimbd | |
" set coomment color | |
hi Comment ctermfg=blue | |
hi Directory ctermfg=blue cterm=bold | |
" | |
"===========================DEIN-VIM===================================== | |
" | |
if &compatible | |
set nocompatible " Be iMproved | |
endif | |
" Required: | |
set runtimepath+=~/.cache/dein/repos/github.com/Shougo/dein.vim | |
" Required: | |
if dein#load_state('~/.cache/dein') | |
call dein#begin('~/.cache/dein') | |
" Let dein manage dein | |
" Required: | |
call dein#add('Shougo/dein.vim') | |
" Add or remove your plugins here: | |
" plugin | |
call dein#add('elzr/vim-json', {'on_ft': 'json'}) | |
call dein#add('Shougo/neosnippet.vim') | |
call dein#add('Shougo/neosnippet-snippets') | |
call dein#add('Shougo/vimproc.vim', {'build' : 'make'}) | |
call dein#add('Shougo/deoplete.nvim') | |
if !has('nvim') | |
call dein#add('roxma/nvim-yarp') | |
call dein#add('roxma/vim-hug-neovim-rpc') | |
endif | |
call dein#add('vim-airline/vim-airline') | |
call dein#add('vim-airline/vim-airline-themes') | |
call dein#add('vim-syntastic/syntastic') | |
call dein#add('scrooloose/nerdtree') | |
call dein#add('scrooloose/nerdcommenter') | |
call dein#add('SirVer/ultisnips') | |
call dein#add('honza/vim-snippets') | |
call dein#add('majutsushi/tagbar') | |
call dein#add('mattn/emmet-vim') | |
call dein#add('~/.local/lib/fzf') | |
call dein#add('junegunn/fzf.vim') | |
" language | |
" You can specify revision/branch/tag. | |
call dein#add('Shougo/deol.nvim') | |
" Required: | |
call dein#end() | |
call dein#save_state() | |
endif | |
" Required: | |
filetype plugin indent on | |
" If you want to install not installed plugins on startup. | |
"if dein#check_install() | |
" call dein#install() | |
"endif | |
"End dein Scripts------------------------- | |
" | |
"===========================PLUGIN SETTINGS===================================== | |
" | |
" load from vimrc files | |
for s:path in split(glob('~/.vim/vimrc/*.vim'), "\n") | |
exe 'source ' . s:path | |
endfor |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment