" Set up vim " Basic configuration set nocompatible set encoding=utf-8 set binary " Presentation settings set number " Precede each line with its line number set numberwidth=3 " Number of culumns for line numbers set textwidth=0 " Do not wrap words (insert) set wrap " Wrap words (view) set showcmd " Show (partial) command in status line. set showmatch " Show matching brackets. set ruler " Line and column number of the cursor position set wildmenu " Enhanced command completion set visualbell " Use visual bell instead of beeping set noerrorbells " Disable error bells" set laststatus=2 " Always show the status lines set cursorline " Highligh the cursor line set t_Co=256 " Use 256 colors set background=dark " Use a dark background " Highlight spell errors hi SpellErrors guibg=red guifg=black ctermbg=red ctermfg=black " Toggle spell check with F7 map :setlocal spell! spell? " Behavior " Ignore these files when completing names and in explorer set wildignore=.svn,CVS,.git,.hg,*.o,*.a,*.class,*.mo,*.la,*.so,*.obj,*.swp,*.jpg,*.png,*.xpm,*.gif set shell=$SHELL " Use current shell for shell commands set hidden " Enable multiple modified buffers set history=1000 " History size set autoread " Automatically read feil that has been changed on disk and doesn't have changes in vim set backspace=indent,eol,start set guioptions-=T " Disable toolbar" set completeopt=menuone,preview set cinoptions=:0,(s,u0,U1,g0,t0 " Some indentation options ':h cinoptions' for details set modelines=5 " Number of lines to check for vim: directives at the start/end of file set autoindent " AutomaticAlly indent new line " Indentation set ts=2 " Number of spaces in a tab set sw=2 " Number of spaces for indent set et " Expand tabs into spaces " Mouse settings if has("mouse") set mouse=a endif set mousehide " Hide mouse pointer on insert mode." " Search settings set incsearch " Incremental search set nohlsearch " Do not highlight search match set ignorecase " Do case insensitive matching set smartcase " Do not ignore if search pattern has CAPS " Directory settings set nobackup " Do not write backup files set noswapfile " Do not write .swp files " Stop here if running in restricted mode if v:progname =~? "rvim" finish endif " Backup settings if has("persistent_undo") silent !mkdir -vp ~/.backup/vim/undo/ > /dev/null 2>&1 set backupdir=~/.backup/vim,. " List of directories for the backup file set directory=~/.backup/vim,~/tmp,. " List of directory names for the swap file set undofile set undodir=~/.backup/vim/undo/,~/tmp,. endif " Folding if has("folding") set foldcolumn=0 " Columns for folding set foldmethod=indent set foldlevel=9 set nofoldenable " Don't fold by default endif if has("user_commands") let mapleader = "," let maplocalleader = "\\" endif " Remember last position in file if has("autocmd") autocmd BufReadPost * \ if line("'\"") > 0 && line("'\"") <= line("$") | \ exe "normal g`\"" | \ endif endif " In this house we obey the laws of airline let g:airline_powerline_fonts = 1 let g:airline_enable_fugitive = 1 let g:airline_theme = 'base16' " Use Q for formatting map Q gq " In many terminal emulators the mouse works just fine, thus enable it. if has('mouse') set mouse=a endif if has("autocmd") " Put these in an autocmd group, so that we can delete them easily. augroup vimrcEx au! " For all text files set 'textwidth' to 78 characters. autocmd FileType text setlocal textwidth=78 " 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). " Also don't do it when the mark is in the first line, that is the default " position when opening a file. autocmd BufReadPost * \ if line("'\"") > 1 && line("'\"") <= line("$") | \ exe "normal! g`\"" | \ endif augroup END " Makefile sanity autocmd BufEnter ?akefile* set noet ts=8 sw=8 autocmd BufEnter */debian/rules set noet ts=8 sw=8 endif " has("autocmd") " Various options set shortmess+=I " Don't show the intro message when starting vim set complete+=k " Scan files with the 'dictionary' option set completeopt+=longest set scrolloff=15 " Minimal number of screen lines above/below the cursor set linebreak " Wrap long lines at a blank if has("syntax") syntax on " Enable syntax highlighting filetype plugin indent on endif :noremap k gk :noremap j gj "" Take care of screen/tmux settings if &term =~ '^screen' " tmux will send xterm-style keys when its xterm-keys option is on execute "set =\e[1;*A" execute "set =\e[1;*B" execute "set =\e[1;*C" execute "set =\e[1;*D" endif " base16 color theme let base16colorspace=256 colorscheme base16-solarized-dark " Python-black if has("python3") packadd black endif " ALE conflicts with typescript-vim at the moment if ! &ft=="typescript" packadd ale endif