From 09c373075e20ff002ec08d09a939117b86f35900 Mon Sep 17 00:00:00 2001 From: Maciej Sobkowski Date: Thu, 2 Jul 2015 10:41:08 +0200 Subject: Added dotfiles for Vim My vimrc along with other files used in my configuration --- vim/.vimrc | 218 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 218 insertions(+) create mode 100644 vim/.vimrc (limited to 'vim/.vimrc') diff --git a/vim/.vimrc b/vim/.vimrc new file mode 100644 index 0000000..06f69ac --- /dev/null +++ b/vim/.vimrc @@ -0,0 +1,218 @@ +" Vim configuration +" +" ============================================================================= +" Vim-plug setup +" ============================================================================= +call plug#begin() +Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } +Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets' +Plug 'christoomey/vim-tmux-navigator' +Plug 'vim-scripts/cscope.vim' +Plug 'bling/vim-airline' +Plug 'chriskempson/base16-vim' +Plug 'jlanzarotta/bufexplorer' +Plug 'rking/ag.vim' +call plug#end() + +set nocompatible +set ttyfast + +" ============================================================================= +" External configuration +" ============================================================================= + +" enable modeline in files +set modeline +" allow local .vimrc files but use only safe options +set exrc +set secure + +" ============================================================================= +" Colorscheme +" ============================================================================= + +set t_Co=256 +let base16colorspace=256 " Access colors present in 256 colorspace +colorscheme base16-eighties +set background=dark + +syntax on +" highlight matching brackets +set showmatch + +" ============================================================================= +" Interface +" ============================================================================= + +set cursorline +set number +set wildmenu +set relativenumber +set shortmess=atI +set laststatus=2 + +" leader r to toggle relative line numbers +nmap r :set rnu! + +nnoremap ; : +nnoremap : ; +vnoremap ; : +vnoremap : ; + +" ============================================================================= +" Indentation +" ============================================================================= + +set tabstop=8 +set softtabstop=8 +set shiftwidth=8 +set noexpandtab + +filetype plugin indent on + +" ============================================================================= +" Invisible characters +" ============================================================================= + +nmap l :set list! +set listchars=tab:▸\ ,eol:¬ + +function! Preserve(command) + + " Save last search and cursor position + let _s=@/ + let l = line(".") + let c = col(".") + + execute a:command + + " Restore search history and cursor position + let @/=_s + call cursor(l, c) + +endfunction +nmap _$ :call Preserve("%s/\\s\\+$//e") + +" ============================================================================= +" Buffers +" ============================================================================= + +" Auto hide buffers without raising error +set hidden + +" ============================================================================= +" Navigation mappings +" ============================================================================= + +" better window navigation +map h +map j +map k +map l + +" disable arrow keys +map +map +map +map +imap +imap +imap +imap + +" better scrolling within wrapped lines +nnoremap j gj +nnoremap k gk + +" leader r to toggle relative line numbers +nmap r ;set rnu! + +set pastetoggle= + +" ============================================================================= +" Search +" ============================================================================= + +set hlsearch +nnoremap :noh + +set incsearch +set smartcase + +" use g flag by default +set gdefault +" very magic regular expressions +nnoremap / /\v +vnoremap / /\v + +" ============================================================================= +" Temporary/backup/undo files +" ============================================================================= + +" save backups to .vim-backup directory in pwd (if exists), if not, then at +" ~/.vim/backup +if isdirectory($HOME . '/.vim/backup') == 0 + :silent !mkdir -p ~/.vim/backup >/dev/null 2>&1 +endif +set backupdir-=. +set backupdir+=. +set backupdir-=~/ +set backupdir^=~/.vim/backup +set backupdir^=./.vim-backup +set backup + +" do simmilar thing for swap files +if isdirectory($HOME . '/.vim/swap') == 0 + :silent !mkdir -p ~/.vim/swap >/dev/null 2>&1 +endif +set directory=./.vim-swap// +set directory+=~/.vim/swap// + +" and for undo files +if exists("+undofile") + if isdirectory($HOME . '/vim/undo') == 0 + :silent !mkdir -p ~/.vim/undo >/dev/null 2>&1 + endif + set undodir=./.vim-undo// + set undodir+=~/.vim/undo// + set undofile +endif + +set viminfo+=n~/.vim/viminfo + +" ============================================================================= +" Scrolling +" ============================================================================= + +set scrolloff=10 + + +" ============================================================================= +" Cscope +" ============================================================================= +" +nnoremap fa :call cscope#findInteractive(expand('')) +nnoremap l :call ToggleLocationList() +" s: Find this C symbol +nnoremap fs :call cscope#find('s', expand('')) +" g: Find this definition +nnoremap fg :call cscope#find('g', expand('')) +" d: Find functions called by this function +nnoremap fd :call cscope#find('d', expand('')) +" c: Find functions calling this function +nnoremap fc :call cscope#find('c', expand('')) +" t: Find this text string +nnoremap ft :call cscope#find('t', expand('')) +" e: Find this egrep pattern +nnoremap fe :call cscope#find('e', expand('')) +" f: Find this file +nnoremap ff :call cscope#find('f', expand('')) +" i: Find files #including this file +nnoremap fi :call cscope#find('i', expand('')) + + +" ============================================================================= +" Plugins configuration +" ============================================================================= +" +let g:airline_powerline_fonts = 1 -- cgit v1.2.3-70-g09d2