" Set up vim " Basic configuration set nocompatible set clipboard=unnamed " Use the OS clipboard by default " Encoding set encoding=utf-8 set fileencoding=utf-8 set fileencodings=utf-8 set binary set ttyfast " Boost speed by altering character redraw rates to your terminal " Presentation settings set number " Show absolute line numbers on the left. set numberwidth=3 " Sets width of the 'gutter' column used for numbering to 3 (default 4) set textwidth=0 " Do not wrap words (insert) set wrap " Wrap overflowing lines set showcmd " Show (partial) command in status line. set showmatch " Show matching brackets when text indicator is over them 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 the error bells set laststatus=2 " Always show the status lines set cursorline " Highligh the cursor line "set cursorcolumn " Highlight current cursor column set t_Co=256 " Use 256 colors set background=dark " Use a dark background let base16colorspace=256 " vim hardcodes background color erase even if the terminfo file does " not contain bce (not to mention that libvte based terminals " incorrectly contain bce in their terminfo files). This causes " incorrect background rendering when using a color theme with a " background color. let &t_ut='' " 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 ai " Sets auto-indentation set si " Sets smart-indentation set tabstop=2 " Tab equal 2 spaces (default 4) set shiftwidth=2 " Arrow function (>>) creates 2 spaces set expandtab " Use spaces instead of a tab charater on TAB set smarttab " Be smart when using tabs " Search settings set incsearch " When searching (/), display results as you type (instead of only upon ENTER) set nohlsearch " Do not highlight search match set ignorecase " When searching (/), ignore case entirely set smartcase " When searching (/), automatically switch to a case-sensitive search if you use any capital letters set shiftround " Shift to the next round tab stop. Aka When at 3 spaces, hit >> to go to 4, not 5 if your shiftwidth is set to 2. " 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=1 " Place a width 1 margin on the left 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 set mousehide " Hide mouse pointer on insert mode." if ! has("nvim") set ttymouse=sgr set balloonevalterm endif endif " Styled and colored underline support let &t_AU = "\e[58:5:%dm" let &t_8u = "\e[58:2:%lu:%lu:%lum" let &t_Us = "\e[4:2m" let &t_Cs = "\e[4:3m" let &t_ds = "\e[4:4m" let &t_Ds = "\e[4:5m" let &t_Ce = "\e[4:0m" " Strikethrough let &t_Ts = "\e[9m" let &t_Te = "\e[29m" " Truecolor support let &t_8f = "\e[38:2:%lu:%lu:%lum" let &t_8b = "\e[48:2:%lu:%lu:%lum" let &t_RF = "\e]10;?\e\\" let &t_RB = "\e]11;?\e\\" " Bracketed paste let &t_BE = "\e[?2004h" let &t_BD = "\e[?2004l" let &t_PS = "\e[200~" let &t_PE = "\e[201~" " Cursor control let &t_RC = "\e[?12$p" let &t_SH = "\e[%d q" let &t_RS = "\eP$q q\e\\" let &t_SI = "\e[5 q" let &t_SR = "\e[3 q" let &t_EI = "\e[1 q" let &t_VS = "\e[?12l" " Focus tracking let &t_fe = "\e[?1004h" let &t_fd = "\e[?1004l" if ! has("nvim") execute "set =\[I" execute "set =\[O" endif " Window title let &t_ST = "\e[22;2t" let &t_RT = "\e[23;2t" 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 " Python-black if has("python3") packadd black endif " ALE conflicts with typescript-vim at the moment if ! &ft=="typescript" packadd ale endif