From 5458844549f1507fe0d15f6186d1cd7cd5ada925 Mon Sep 17 00:00:00 2001 From: Thomas Ruoff Date: Thu, 24 Nov 2016 14:37:25 +0100 Subject: [PATCH] re-structure, clean vimrc --- .gitignore | 1 + vimrc | 336 +++++++++++++++++++++++++---------------------------- 2 files changed, 157 insertions(+), 180 deletions(-) diff --git a/.gitignore b/.gitignore index 795767c..3ac0238 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ irssi vim/plugged/* vim/undos/* +vim/backup/ vim/spell .netrwhist Xresources.compiled diff --git a/vimrc b/vimrc index cc743d9..595af84 100644 --- a/vimrc +++ b/vimrc @@ -1,6 +1,10 @@ -set encoding=utf-8 +" vim: set fenc=utf-8 nu et sts=4 sw=4 ft=vim fdm=marker fmr={{{,}}}: +" file: ~/.vimrc +" author: Thomas Ruoff (with the help of a myriad others) + scriptencoding utf-8 +" Plugins {{{ call plug#begin('~/.vim/plugged') Plug 'tpope/vim-sensible' @@ -47,117 +51,41 @@ Plug 'junegunn/fzf.vim' Plug 'sheerun/vim-polyglot' call plug#end() +" }}} -"" enable local .vimrc -set exrc " Enable use of directory-specific .vimrc -set secure " Only run autocommands owned by me - -"" Tabs. May be overriten by autocmd rules -set tabstop=4 -set softtabstop=0 -set shiftwidth=4 -set expandtab - -"" Enable hidden buffers -set hidden - -"" Searching -set hlsearch -set smartcase - -"" find -set path+=** - -"" Display all matching files when we tab complete -set wildmenu - -"set wildignorecase -set wildignore+=.git,.hg,.svn -set wildignore+=*.aux,*.out,*.toc -set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest,*.rbc,*.class -set wildignore+=*.ai,*.bmp,*.gif,*.ico,*.jpg,*.jpeg,*.png,*.psd,*.webp -set wildignore+=*.avi,*.m4a,*.mp3,*.oga,*.ogg,*.wav,*.webm -set wildignore+=*.eot,*.otf,*.ttf,*.woff -set wildignore+=*.doc,*.pdf -set wildignore+=*.zip,*.tar.gz,*.tar.bz2,*.rar,*.tar.xz -set wildignore+=*.swp,.lock,.DS_Store,._* - -"" saving -set fileformats=unix,dos,mac -set fileformat=unix - -"" backups - -" Use backup files when writing (create new file, replace old one with new -" one) -set writebackup -" but do not leave around backup.xyz~ files after that -set nobackup -" backupcopy=yes is the default, just be explicit. We need this for -" webpack-dev-server and hot module reloading -- preserves special file types -" like symlinks -set backupcopy=yes nobackup - -" swap files -set noswapfile - -" persistent undo -set undodir=~/.vim/undos -set undofile -set undolevels=1000 -set undoreload=10000 - -"" session management -let g:session_directory = "~/.vim/session" -let g:session_autoload = "no" -let g:session_autosave = "no" -let g:session_command_aliases = 1 - -"" Mouse -set mouse=a - -"" Use modeline overrides -set modeline -set modelines=10 - -"" Visual settings -syntax enable -set synmaxcol=512 - -set title - -set cursorline - -set number -if exists('+relativenumber') - set relativenumber -endif - +" Basics {{{ +set encoding=utf-8 +filetype plugin indent on " Load filetype plugin/indent files. +syntax on " Enable syntax highlighting. +set synmaxcol=512 " Limit syntax highlighting to 512 characters per line +set modeline " Use file-specific settings, if available. +"set autochdir " Always switch to current file directory. +set backup " Make backup files. +set backupdir=~/.vim/backup " Backup directory. +set directory=~/.vim/tmp " Directory for swap files. +set mouse=a " Mouse support everywhere. +set mousehide " Auto-hide cursor while typing. +set wildmode=list:longest,full " Make completion more like zsh. +set wildmenu " Turn on command-line completion wild style. +set wildignore+=*.swp,*.bak,*.jpg,*.gif,*.png,*.git, +set ignorecase " Ignore case, except... +set smartcase " ...when search string contains uppercase. +set incsearch " Highlight as you type search phrase. +" set hlserach +set number " Show line numbers. +set report=0 " Tell me when anything is changed via :... +set ruler " Show current positions along bottom. +set scrolloff=5 " Keep 5 lines (top/bottom) for scope. +set showcmd " Show command being typed. +set showmatch " Show matching brackets. +set spell " Highlight misspelled words. +set spellcapcheck= " Don't highlight uncapitalized first word. +set complete+=kspell " Use and to get suggested spelling completions. +set splitright " Split to the right when executing :vsplit. +let g:netrw_liststyle=3 " Use tree style directory listing. set background=dark -let base16colorspace=256 -colorscheme base16-solarized-dark - -if has("gui_running") - "disable menu, toolsbar, scrollbar - set guioptions -=m - set guioptions -=T - set guioptions -=r -endif - -" Display unprintable chars -set listchars=tab:▸\ ,extends:❯,precedes:❮,nbsp:␣,trail:· -set showbreak=↳ - -"" disable visual bell -set visualbell -set t_vb= - -"" spelling -set spelllang=en,de - -" Open all folds initially -set foldmethod=indent -set foldlevelstart=10 +set path+=** +"set title " Writes to the unnamed register also writes to the * and + registers. This " makes it easy to interact with the system clipboard @@ -166,86 +94,127 @@ if has ('unnamedplus') set clipboard^=unnamedplus endif -" diff +" }}} + +" local .vimrc {{{ +set exrc " Enable use of directory-specific .vimrc +set secure " Only run autocommands owned by me +" }}} + +" Text Formatting {{{ +set list " Show real tabs (so they can be removed). +set listchars=tab:▸\ ,extends:❯,precedes:❮,nbsp:␣,trail:- +set linebreak " Don't soft-wrap in the middle of a word. +set showbreak=↳ " Show `…' at the beginning of a soft-broken line. +set tabstop=8 " Real tabs are 8 columns long. +set expandtab " No real tabs (use spaces for tabs). +set softtabstop=2 " Set # of spaces when hitting tab/delete. +set shiftwidth=2 " Set # of softtabs when using cindent, <<, >>, ... +set textwidth=80 " Set max # of characters on each line. +set autoindent " Use indentation level of previous line. +set nojoinspaces " Don't add extra space after ., !, etc. when joining. +set formatoptions+=j " Delete comment character when joining commented lines. +" }}} + +" Folding {{{ +set foldmethod=indent +set foldlevelstart=3 +" }}} + +" diff settings {{{ set fillchars+=diff:⣿ set diffopt=vertical " Use in vertical diff mode set diffopt+=filler " blank lines to keep sides aligned set diffopt+=iwhite " Ignore whitespace changes +" }}} +" {{{ Undo +set undodir=~/.vim/undos +set undofile +set undolevels=1000 +set undoreload=10000 +" }}} -" -" KEY MAPPINGS -" +" Visual Setting {{{ +set cursorline +let base16colorspace=256 +colorscheme base16-solarized-dark -"" MAP LEADER -noremap , \ -let mapleader = "," +set number +if exists('+relativenumber') + set relativenumber +endif +" }}} + +" GUI Settings {{{ +if has("gui_running") + "disable menu, toolsbar, scrollbar + set guioptions -=m + set guioptions -=T + set guioptions -=r +endif +" }}} + +" Key mappings {{{ + +let mapleader=',' +let maplocalleader=',' set timeoutlen=400 -"" fast saving -nmap w :update "" fast escaping -imap jj +inoremap jj + +"" fast editing +nnoremap e :e + +"" fast saving +nnoremap w :update + "" clear highlight nnoremap :noh -"" ignore lines when going up or down -nnoremap j gj -nnoremap k gk - -"" open last buffer -nnoremap - -" Easier split navigation - -" Use ctrl-[hjkl] to select the active split! -nmap :wincmd k -nmap :wincmd j -nmap :wincmd h -nmap :wincmd l "" fast window switching -map , w +noremap , w -"" open next buffer -map . :bn - -"" cycle between buffers -map : :b# +"" open next,prev buffer, cycle +noremap . :bn +noremap m :bp +noremap : :b# "" delete buffer -map bd :bd +noremap bd :bd "" indent visual selected code without unselecting and going back to normal mode -vmap > >gv -vmap < >gv +vnoremap < r :%s#\<=expand("")\># "" fast editing of the .vimrc -nmap ev :e $MYVIMRC -nmap sv :so $MYVIMRC +nnoremap ev :e $MYVIMRC +nnoremap sv :so $MYVIMRC "" allow saving when you forgot sudo -cmap w!! w !sudo tee % >/dev/null +cnoremap w!! w !sudo tee % >/dev/null "" turn on spell checking -map spl :setlocal spell! +noremap spl :setlocal spell! "" spell checking shortcuts -map sn ]s -map sp [s -map sa zg -map s? z= +noremap sn ]s +noremap sp [s +noremap sa zg +noremap s? z= "" toggle states -nmap hh :set invhlsearch -nmap ll :set invlist -nmap pp :set invpaste +nnoremap hh :set invhlsearch +nnoremap ll :set invlist +nnoremap pp :set invpaste -nmap nn :set invnumber -nmap ii :set invrelativenumber +nnoremap nn :set invnumber +nnoremap ii :set invrelativenumber "" 0: Run the visually selected code in node and replace it with the output vnoremap 0 :!node @@ -268,10 +237,9 @@ cnoreabbrev Q q cnoreabbrev Qall qall iab xnow =strftime("%Y-%m-%d %H:%M") +" }}} -" -" Plugin Configuration -" +" Plugin Configuration {{{ "" gutentags @@ -283,15 +251,15 @@ let g:gutentags_file_list_command = { \ }, \ } -"" fzf -nmap b :Buffers -nmap f :GFiles -nmap F :Files -vmap f y:Files " -nmap a :Ag -vmap a y:Ag " -nmap A :Ag -nmap c :Commits +"" fzf +nnoremap b :Buffers +nnoremap f :GFiles +nnoremap F :Files +vnoremap f y:Files " +nnoremap a :Ag +vnoremap a y:Ag " +nnoremap A :Ag +nnoremap c :Commits "" syntastic let g:syntastic_always_populate_loc_list = 1 @@ -327,19 +295,16 @@ if filereadable(expand("~/.vim/lightline.vim")) source ~/.vim/lightline.vim endif -"" NERDTree configuration -nmap n :NERDTreeToggle - "" Unimpaired "" bubble single lines -nmap k [e -nmap j ]e +nnoremap k [e +nnoremap j ]e "" bubble multiple lines -vmap k [egv -vmap j ]egv +vnoremap k [egv +vnoremap j ]egv "" Indent Guides -nmap g :IndentGuidesToggle +nnoremap g :IndentGuidesToggle "" Ultisnips let g:UltiSnipsExpandTrigger="" @@ -356,10 +321,9 @@ let g:markdown_fenced_languages = [ \ 'html', \ 'javascript', 'js=javascript', 'json=javascript' \ ] +" }}} -" -" Autocmd Rules -" +" Autocmd Rules {{{ "" do syntax highlight syncing from start autocmd BufEnter * :syntax sync fromstart @@ -384,3 +348,15 @@ au BufRead,BufNewFile *.template set filetype=html.mustache syntax=mustache "" always open help in vertical split au FileType help wincmd L + +" }}} + +" probably not needed {{{ + +"" disable visual bell +"set visualbell +"set t_vb= + +"" spelling +"set spelllang=en,de +"}}}