Last active
September 15, 2017 04:14
-
-
Save silvercircle/c86efd6ce26025faa0b95cb5ea316240 to your computer and use it in GitHub Desktop.
my .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
" .vimrc | |
" | |
" vim: fdm=indent: | |
" Only tested with vim 8.0 or later on Windows (native + Cygwin) and FreeBSD | |
" | |
" The following plugins are required (if any of them is not installed, errors on | |
" startup may occur) | |
" * pathogen (plugin manager) | |
" * neoComplete | |
" * BufExplorer | |
" * NERDTree | |
" * Vim-airline | |
" * vim-nerdtree-tabs (allow one unique NERDTree on all tab pages) | |
" * vim-airline-themes | |
" * Kwdb (close buffer) | |
" * Tagbar | |
" * Polyglot syntax package. | |
set nocompatible | |
" the plugin manager | |
execute pathogen#infect() | |
" set a cool color scheme | |
colorscheme base16-myown | |
" This implements the Justify command to justify a line of text | |
" I need this rarely, so no keyboard shortcut defined. The command | |
" it implements is Justify | |
run macros/justify.vim | |
" this might help with vim running in terminals and Windows console | |
" a bit faster. Does not hurt when using gvim. | |
set ttyfast | |
set lazyredraw | |
"mswin behavior (CUA mapping, not advisable, you lose the "vim way" and quite | |
"some features. | |
"source $VIMRUNTIME/mswin.vim | |
"behave mswin | |
"vnoremap <Tab> >gV | |
"vnoremap <S-Tab> <gV | |
"make < > shifts keep selection | |
vnoremap < <gv | |
vnoremap > >gv | |
" Ctrl-A selects all text. | |
map <C-a> <esc>ggVG<CR> | |
" The following once belonged to .gvimrc, but vim is smart enough to | |
" not disintegrate when you put this in .vimrc | |
" First, set a nice looking font | |
" make sure, the font is available, otherwise you get a default (fugly) | |
set guifont=Iosevka:h12:cANSI:qDRAFT | |
" window geometry | |
set lines=52 columns=200 | |
" no toolbar | |
set guioptions-=T | |
" no scrollbar on the left side. Ever. Because it's stupid :) | |
set guioptions-=L | |
" this would add GUI tabs, but since we use Airline and its enhanced tab line | |
" there is no need for it. | |
" set guioptions+=e | |
" The initial window position | |
winpos 160 15 | |
" --------- end former .gvimrc stuff ----------- | |
let mapleader = ',' | |
" allow the cursor to move beyond line endings and be placed | |
" everywhere in the text in all modes. | |
set virtualedit=all | |
" allow different colors for insert/visual/normal cursors. | |
set guicursor+=i:block-iCursor | |
set guicursor+=v:block-vCursor | |
set guicursor+=n:block-nCursor | |
" insert mode cursor should not blink | |
set guicursor+=i:blinkon0 | |
" allow long lines, no forced soft-wrap at the right window border | |
" this enables horizontal scrolling | |
set nowrap | |
" set some seinsible defaults for indentation, tabs and other basic parameters | |
set autoindent | |
set copyindent | |
set shiftwidth=4 | |
set backspace=indent,eol,start | |
set tabstop=4 | |
set textwidth=78 | |
set expandtab | |
" allow using the clipboard as default register. With this, you can use | |
" the windows clipboard like with any other application (copy and paste | |
" between vim and anything else) | |
set clipboard=unnamed | |
" a poor man's signature randomizer. Useful for posting in news groups | |
command F . !e:/cygwin64/bin/fortune -n240 -s science wisdom politics | |
" which keys allow the cursor to wrap at the begin or ending of a line. | |
set whichwrap+=<,>,[,],b | |
setlocal fo-=t | |
set langmenu=en_US.UTF-8 " sets the language of the menu (gvim) | |
" enable plugin-based filetyp identification, syntax highlighting | |
filetype off | |
syntax on | |
filetype plugin indent on | |
" make sure, we always encode in UTF-8 | |
set enc=utf-8 | |
set ff=unix | |
set fileencoding=utf-8 | |
set fileencodings=ucs-bom,utf8,prc | |
set fileformats=unix,dos | |
" show white spaces, but only trailing spaces, newlines and tabs | |
set list listchars=tab:·\ ,trail:·,extends:>,precedes:<,eol:¬ | |
" set the highlight color for these white spaces | |
highlight SpecialKey guifg=#00ff00 ctermfg=48 | |
" This is necessary for gvim on Windows to make the delete behave like | |
" a delete key actually *should* behave. | |
set backspace=2 | |
" search is case-insensitive by default... | |
set ignorecase | |
" ...but if the search term contains upper case letters it becomes case | |
" sensitive. makes sense? yeah, i think so. lots of. | |
set smartcase | |
" incremental search cannot hurt | |
set incsearch | |
set smarttab | |
set hlsearch | |
set noswapfile | |
set nobackup | |
set scrolloff=3 | |
set showmode | |
set showcmd | |
set hidden | |
set wildmenu | |
set wildmode=list:longest | |
" cursorline can be a performance killer, not recommended | |
" set cursorline | |
set ruler | |
" stop blinking, flashing, beeping, exploding... whatever. | |
set noerrorbells | |
set novisualbell | |
set t_vb= | |
set tm=500 | |
" This prevents the "2-spaces after end of sentence" rule. Basically, vim | |
" would normally set 2 spaces after a period or question mark when | |
" reformatting / joining lines. | |
set nojoinspaces | |
" customize the airline plugin a bit | |
" first, let it display the current formatoptions next to the file name | |
let g:airline_section_b='[%{&fo}]' | |
" We only want this extension | |
let g:airline_extensions = ['tabline'] | |
" select a theme... | |
let g:airline_theme='badwolf' | |
" use the enhanced tab bar | |
let g:airline#extensions#tabline#enabled = 1 | |
let g:airline#extensions#tabline#show_tabs = 1 | |
let g:airline#extensions#tabline#show_tab_nr = 1 | |
let g:airline#extensions#tabline#show_close_button = 1 | |
let g:airline#extensions#tabline#fnamecollapse = 0 | |
let g:airline#extensions#tabline#fnamemod = ':t' | |
let g:airline#extensions#tabline#excludes = ['NERD_tree_1'] | |
let g:airline#extensions#tabline#show_splits = 0 | |
" and make use of special symbols in the tab- and status line. | |
" This requires a patched font | |
let g:airline_powerline_fonts = 1 | |
" Buffers - explore/next/previous: Alt-F12, F12, Shift-F12. (buffer explorer | |
" plugin) | |
nnoremap <silent> <M-F12> :BufExplorer<CR> | |
nnoremap <silent> <F12> :bn<CR> | |
nnoremap <silent> <S-F12> :bp<CR> | |
set number | |
set numberwidth=5 | |
" relativenumber is a performancekiller, so don't use it. | |
" set relativenumber | |
" execute 'sign place 9999 line=1 name=dummy buffer=' . bufnr('') | |
set foldcolumn=6 | |
set foldmethod=indent | |
set foldlevelstart=20 | |
" this prevents vim from saving all global options in views | |
" normally not needed. | |
set viewoptions-=options | |
" Auto commands when starting Vim: | |
" open a NERDTree by default (we are nerds, ain't we, otherwise we wouldn't use vim :) ) | |
" also, change some colors for the tabline (airline extension) | |
augroup enter | |
autocmd vimenter * NERDTree | wincmd p | |
autocmd VimEnter * | |
\ let g:airline#themes#badwolf#palette.tabline = { | |
\ 'airline_tabhid': ['#f8f8f8','#a0a0a0',231,88,''], | |
\ 'airline_tabfill': ['#ffffff','#606080',231,88,''], | |
\ 'airline_tabmod_unsel': ['#f8f8f8','#a0a0a0',231,52,''], | |
\ 'airline_tab_right': ['#f8f8f8','#a0a0a0',231,52,''], | |
\ 'airline_tab': ['#f8f8f8','#a0a0a0',231,52,''], | |
\ } | :AirlineRefresh | |
augroup end | |
" filetype related autocmds | |
augroup filetypes | |
autocmd FileType mail setlocal fo-=c | |
autocmd FileType html,liquid setlocal fo-=t | |
autocmd FileType cpp,js,python,html,vim,java,cs,rust syn match Braces display '[{}()\[\]\.\:\;\=\>\<\,\!\~]' | |
autocmd FileType pascal,lua syn match Braces display '[()\[\]\.\:\;\=\>\<\,\!\~]' | |
autocmd FileType mail,text,markdown setlocal fo+=nawqt | |
autocmd FileType mail,text,markdown setlocal spell spelllang=en_us,de_de | |
autocmd FileType markdown setlocal tw=100 | |
autocmd BufNewFile,BufRead *.script,*.ltx setlocal ft=lua | |
" syntax folding for these filtypes | |
"autocmd FileType cpp,pascal,js,python,html,vim,java setlocal foldmethod=syntax foldlevelstart=20 | |
augroup end | |
augroup folds | |
"autocmd BufReadPre * setlocal foldmethod=indent | |
"autocmd BufWinEnter * if &fdm == 'indent' | setlocal foldmethod=manual | endif | |
" store views for these filetypes (main reason is to save folds) | |
" Save view when saving file *and* whenever the window is closed | |
autocmd BufWritePost,BufWinLeave *.c,*.php,*.py,*.pas,*.cpp,*.java,*.js,*.html,*.css | |
\ if expand('%') != '' && &buftype !~ 'nofile' | |
\| mkview | |
\| endif | |
autocmd BufRead * | |
\ if expand('%') != '' && &buftype !~ 'nofile' | |
\| silent loadview | |
\| endif | |
augroup end | |
" let javaScript_fold=1 " JavaScript | |
let perl_fold=1 " Perl | |
" let php_folding=1 " PHP | |
let r_syntax_folding=1 " R | |
let ruby_fold=1 " Ruby | |
let sh_fold_enabled=1 " sh | |
let vimsyn_folding='af' " Vim script | |
" let xml_syntax_folding=1 " XML | |
" key mappings for folding | |
" F2 toggles a fold's state and can additionally be used to create | |
" a new fold in manual mode. | |
" toggle this fold | |
inoremap <F2> <C-O>za | |
nnoremap <F2> za | |
onoremap <F2> <C-C>za | |
vnoremap <F2> zf | |
" close current level | |
inoremap <S-F2> <C-O>zc | |
nnoremap <S-F2> zc | |
onoremap <S-F2> <C-C>zc | |
vnoremap <S-F2> zf | |
" open current level | |
inoremap <C-F2> <C-O>zo | |
nnoremap <C-F2> zo | |
onoremap <C-F2> <C-C>zo | |
vnoremap <C-F2> zf | |
" toggle all levels of current fold | |
inoremap <F3> <C-O>zA | |
nnoremap <F3> zA | |
onoremap <F3> <C-C>zA | |
vnoremap <F3> zf | |
" close all current levels | |
inoremap <S-F3> <C-O>zA | |
nnoremap <S-F3> zA | |
onoremap <S-F3> <C-C>zA | |
vnoremap <S-F3> zf | |
" open all current levels | |
inoremap <C-F3> <C-O>zO | |
nnoremap <C-F3> zO | |
onoremap <C-F3> <C-C>zO | |
vnoremap <C-F3> zf | |
" A quick hotkey to toggle the tagbar | |
nnoremap <F4> :TagbarToggle<CR> | |
" we want the header of a folded region to stick out a bit more | |
highlight Folded guibg='#602020' guifg='#eeeeee' | |
" don't let the nerd tree take over the last frame. Close vim when nothing but | |
" the nerd tree is left. | |
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif | |
" a key mapping for the kwbd macro to close a buffer | |
command C Kwbd | |
" toggle formatting options (a = auto, w = hard/soft wrap, t = use textwidth for wrapping) | |
command AFToggle if &fo =~ 'a' | setlocal fo-=a | else | setlocal fo+=a | endif | |
command HWToggle if &fo =~ 'w' | setlocal fo-=w | else | setlocal fo+=w | endif | |
command HTToggle if &fo =~ 't' | setlocal fo-=t | else | setlocal fo+=t | endif | |
command Itime pu=strftime('%FT%T%z') | |
" map some keys for these commands | |
map <leader>a :AFToggle<CR> | |
map <leader>w :HWToggle<CR> | |
map <leader>t :HTToggle<CR> | |
map <leader>i :Itime<CR> | |
" quickly enable/disable automatic formatting modes. | |
command AFManual setlocal fo-=awcqtl | |
command AFAuto setlocal fo+=awcqtl | |
map <leader>fm :AFManual<CR> | |
map <leader>fa :AFAuto<CR> | |
highlight iCursor guifg=black guibg=#ffff00 | |
highlight nCursor guifg=black guibg=#ffffff | |
highlight vCursor guifg=black guibg=#00ffff | |
"NERDTree stuff | |
let NERDTreeMinimalUI = 1 | |
let NERDTreeDirArrows = 1 | |
let NERDTreeShowHidden = 1 | |
let NERDTreeWinSize=40 | |
" set highlight color for braces and simple operators (see above) | |
hi Braces guifg='#ff2020' | |
" autocomplete stuff | |
set completeopt=longest,menuone | |
set omnifunc=syntaxcomplete#Complete | |
set pumheight=15 | |
" color for the autocomplete popup | |
highlight Pmenu guibg='#202079' | |
" Disable AutoComplPop - we use neocomplete | |
let g:acp_enableAtStartup = -1 | |
" allow neoComplete to work with special non-ascii characters like german | |
" umlauts and cyrillic | |
" utf-8 encoding is *required* otherwise, it won't work. | |
let g:neocomplete#enable_multibyte_completion = 1 | |
if !exists('g:neocomplete#keyword_patterns') | |
let g:neocomplete#keyword_patterns = {} | |
endif | |
let g:neocomplete#keyword_patterns._ = '[A-Za-zа-яА-ЯÄ-Üä-ü_ß][0-9A-Za-zа-яА-ЯÄ-Üä-ü_ß]*' | |
" Use neocomplete. | |
let g:neocomplete#enable_at_startup = 1 | |
" Use smartcase. | |
let g:neocomplete#enable_smart_case = 1 | |
" Set minimum syntax keyword length. | |
let g:neocomplete#sources#syntax#min_keyword_length = 3 | |
let g:neocomplete#enable_auto_select = 1 | |
" Define dictionary. | |
let g:neocomplete#sources#dictionary#dictionaries = { | |
\ 'default' : '', | |
\ 'vimshell' : $HOME.'/.vimshell_hist', | |
\ 'scheme' : $HOME.'/.gosh_completions' | |
\ } | |
" Tagbar plugin | |
let g:tagbar_width = 32 | |
" polyglot | |
" | |
"let g:polyglot_disabled = ['markdown'] | |
" vim-markdown | |
let g:vim_markdown_folding_disabled = 1 | |
"let g:vim_markdown_frontmatter = 1" | |
let g:vim_markdown_new_list_item_indent = 2 | |
" this is necessary to solve a conflict between multiple cursors and the | |
" neocomplete plugin. Disable neocomplete while multiple cursors are active | |
function! Multiple_cursors_before() | |
exe 'NeoCompleteLock' | |
echo 'Disabled autocomplete' | |
endfunction | |
function! Multiple_cursors_after() | |
exe 'NeoCompleteUnlock' | |
echo 'Enabled autocomplete' | |
endfunction | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment