Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
234 lines (188 sloc) 6.25 KB
" Vim config
" If you are using vim for the first time you might want to start
" with simpler setup, because this one will break if not setup correctly.
" For basic setup see:
" not vi compatible
set nocompatible
" encoding
set encoding=utf-8
" syntax highlighting
syntax on
" activate 256 colors
set t_Co=256
" set colorscheme
colorscheme old-hope
" file in ~/.vim/colors/old-hope.vim
" see:
" linenumbers, in normal mode numbers will be relative to the current line
set number relativenumber
" blink cursor on error instead of beeping
set visualbell
" color current horizontal line
set cursorline
" set as 'CursorLine' in colorscheme to style
" wrap content to next line when display width is reached
set wrap
" replace tab characters with spaces
set expandtab
" number of spaces a <Tab> consists of
set tabstop=2
" number of spaces to insert when indenting with >,<
set shiftwidth=2
" number of spaces to remove when pressing <Backspace>
set softtabstop=2
" allows <Backspace> to remove linebreaks
set backspace=2
" explaination of above settings:
" round <Tab>s to multiples of tabstop/shiftwidth
set shiftround
" activate automatic indention based on syntax files
set autoindent
" and based on static rules
set smartindent
" check first lines of file for vim commands to execute
" turned off for security
set modelines=0
" allow hidden buffers without forcing them (!)
" a hidden buffer is one with unsaved changed not currently open
set hidden
" defines <leader> key
let mapleader = "#"
" enable autocomplete
set wildmode=longest,list,full
" highlight search matches while typing
set incsearch
" dont highlight search matches at startup
set nohlsearch
" ignore search case
set ignorecase
" enforce case if search contains uppercase
set smartcase
" remove search highlighting, deselect/hide matches
map <leader><space> :nohls<Enter>
" number of lines visable while scrolling (in the scroll direction)
set scrolloff=6
" external formatting program
set formatprg=par\ -w80
" on arch: aur/par
" set whitespace characters
set listchars=tab:▸\ ,eol
" activate :set list
" deactivete :set nolist
" backup files
set backup
set writebackup
set backupdir=~/.vim/backup
" swap files
set swapfile
set directory=~/.vim/tmp
" undo files
set undofile
set undodir=~/.vim/tmp
" invert splits; the defaults are inverted, which is counter intuitive
set splitbelow " on sp
set splitright " on vsp
" remap ^w + <movement> to ^<movement> for easier window changing
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" toggle paste mode
set pastetoggle=<F5>
" custom coloring
" current tab in tabline
hi TabLineSel ctermfg=Red
" current status line
hi StatusLine ctermfg=Red
" vertical Split line
hi VertSplit ctermfg=Red
" number of splits, in tabline next to tab
hi Title ctermfg=Yellow
" only highlight wrongly spelled words
hi SpellBad ctermbg=167
hi SpellRare ctermbg=none
hi SpellLocal ctermbg=none
hi SpellCap ctermbg=none
" TODO: cleanup descriptions below
"## Sessions
" Dont write vimrc option to sessionfile - vimrc changes would be overwritten by old ones
" source:
" don't store vim options (config) in session
set ssop-=options
function! MakeSession()
let b:sessiondir = $HOME . "/.vim/sessions" . getcwd()
if (filewritable(b:sessiondir) != 2)
exe 'silent !mkdir -p ' b:sessiondir
let b:filename = b:sessiondir . '/session.vim'
exe "mksession! " . b:filename
function! LoadSession()
let b:sessiondir = $HOME . "/.vim/sessions" . getcwd()
let b:sessionfile = b:sessiondir . "/session.vim"
if (filereadable(b:sessionfile))
exe 'source ' b:sessionfile
echo "No session loaded."
" Load session automatically if no filename is provided
if(argc() == 0)
au VimEnter * nested :call LoadSession()
" Create session automatically on leave
au VimLeave * :call MakeSession()
" Save history/registers after :q session
set viminfo=%,'20,<100,:20
" set viminfo=%,'50,\"100,:100,n~/.vim/tmp/viminfo
" Enable folding
" Set foldmethod=snytax if current language has fold support
set foldmarker={{{,}}}
set foldmethod=marker
" copy to and from X clipboard
" src:
vmap <leader>c :!xclip -f -sel clip<CR>
map <leader>v mz:-1r !xclip -o -sel clip<CR>`z
" Write file with sudo, eventhough vim wasnt opened with sudo
cnoremap w!! execute 'silent! write !sudo tee % >/dev/null' <bar> edit!
" Disable automatic commenting on newline
" autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
" ^ not working
" Spell-check set to <leader>o, 'o' for 'orthography'
"map <leader>o :setlocal spell! spelllang=en_us<CR>
" ^ not working
" iab jn jneidel
" continue with , as sep
" set dict=~/.vim/dict.vim
" write file after losing focus, or leaving the window
au FocusLost,WinLeave * :silent! w " Doesnt trigger on i3 windows
" read file after regaining focus, entering the buffer
"au FocusGained,BufEnter * :silent! !
au BufEnter * :silent! !
" source:
" maybe checkout:
set autoread " takes 5s
au CursorHold * checktime
" Increment/Decrement next number
" src:
function! AddSubtract(char, back)
let pattern = &nrformats =~ 'alpha' ? '[[:alpha:][:digit:]]' : '[[:digit:]]'
call search(pattern, 'cw' . a:back)
execute 'normal! ' . v:count1 . a:char
silent! call repeat#set(":\<C-u>call AddSubtract('" .a:char. "', '" .a:back. "')\<CR>")
nnoremap <silent> <C-y> :<C-u>call AddSubtract("\<C-a>", '')<CR>
nnoremap <silent> <C-x> :<C-u>call AddSubtract("\<C-x>", '')<CR>
"Delete trailing whitespace on save
"au BufWritePre * DeleteTrailingWhitespace
" Save cursor position before writing and restore after writing
function! SaveCursorPosition()
let a:cursor_pos = getpos(".")
call setpos('.', a:cursor_pos)
" ^ not working, was supposed to mitigate eslint resetting the cursor location
" source external configs/plugins
source ~/.vim/config/init.vim
You can’t perform that action at this time.