" Set color scheme. Other good ones are bubblegum-256-dark, sorcerer, and zenburn colorscheme xoria256 " keyboard shortcuts let mapleader = ',' noremap b :CtrlPBuffer nnoremap d :NERDTreeToggle nnoremap f :NERDTreeFind noremap p :CtrlP noremap P :CtrlPClearCache:CtrlP noremap r :source ~/.vimrc:filetype detect:exe ":echo 'vimrc reloaded'" " Switch buffers using ctrl+left or ctrl+right map :bp map :bn " Move between windows easily noremap :wincmd k noremap :wincmd j noremap :wincmd h noremap :wincmd l noremap k :wincmd k noremap j :wincmd j noremap h :wincmd h noremap l :wincmd l " Switch buffers using F5 nnoremap :buffers:buffer " Set keyboard shortcut for paste toggle. set pastetoggle= map :call TrimWhiteSpace() " Removes trailing spaces func! TrimWhiteSpace() %s/\s*$// '' :endfunction " Airline "let g:airline_powerline_fonts=1 "let g:airline#extensions#tabline#enabled = 1 "let g:airline_theme='laederon' " Clear search highlight with c-l noremap :nohls " Map to / (search) and Ctrl- to ? (backwards search) map / map ? let c_space_errors = 1 " Fix tmux background color if &term =~ '256color' set t_ut= endif " Show line numbers set number " Enable filetype plugins filetype plugin indent on " Enable syntax highlighting syntax on " Turn backup off set nobackup set nowb set noswapfile " this turns off physical line wrapping (ie: automatic insertion of newlines) set textwidth=0 wrapmargin=0 " Enable auto-indent set ai " Use spaces instead of tabs set expandtab " Be smart when using tabs set smarttab " 1 tab == 4 spaces set shiftwidth=4 set tabstop=4 set ai "Auto indent set si "Smart indent " Ignore case while searching set ignorecase " Highlight search results set hlsearch " Makes search act like search in modern browsers set incsearch " Set utf8 as standard encoding and en_US as the standard language set encoding=utf8 " Use Unix as the standard file type set ffs=unix,dos,mac " Visual mode pressing * or # searches for the current selection " Super useful! From an idea by Michael Naumann vnoremap * :call VisualSelection('f') vnoremap # :call VisualSelection('b') " Return to the last edit position when opening files. augroup vimrcEx autocmd! autocmd BufReadPost * \ if line("'\"") > 0 && line("'\"") <= line("$") | \ exe "normal g`\"" | \ endif augroup END " Ensure cursor is at the top of the file, if editing a git commit message: au FileType gitcommit au! BufEnter COMMIT_EDITMSG call setpos('.', [0, 1, 1, 0]) " Remember info about open buffers on close set viminfo^=% " Returns true if paste mode is enabled function! HasPaste() if &paste return 'PASTE MODE ' en return '' endfunction " Always show the status line set laststatus=2 " Format the status line set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l " Delete trailing white space on save, useful for (Python) func! DeleteTrailingWS() exe "normal mz" %s/\s\+$//ge exe "normal `z" endfunc autocmd BufWrite *.py :call DeleteTrailingWS() " in case you forgot to sudo cnoremap w!! %!sudo tee > /dev/null % " Set the cursorline set cursorline "hi cursorline gui=none augroup CursorlineOnlyInActiveWindow autocmd! autocmd VimEnter,WinEnter,BufWinEnter * setlocal cursorline autocmd WinLeave * setlocal nocursorline augroup END " Enhanced vim tweaks silent! source ~/.vimrc-extra