Skip to content

Instantly share code, notes, and snippets.

@isphus1973
Last active June 9, 2019 18:08
Show Gist options
  • Save isphus1973/8dae1cddd1648f7216a41a3906bfa6c2 to your computer and use it in GitHub Desktop.
Save isphus1973/8dae1cddd1648f7216a41a3906bfa6c2 to your computer and use it in GitHub Desktop.
My .vimrc
" This vimrc is based in the book Mastering Vim
"
" Arthur Scardua 2019
"Set the leader key to a comma.
let mapleader=','
syntax on " Enable syntax highlighting.
filetype plugin indent on " Enable file type based indentation.
set autoindent " Respect indentation when starting a new line.
set expandtab " Expand tabs to spaces. Essential in Python.
set tabstop=4 " Number of spaces tab is counted for.
set shiftwidth=4 " Number of spaces to use for autoindent.
set backspace=2 " Fix backspace behavior on most terminals.
colorscheme murphy " Change a colorscheme.
packloadall " Load all plugins.
silent! helptags ALL " Load help files for all plugins.
" Set up persistent undo across all files and set swapdir
set undofile
if !isdirectory($HOME . "/.vim/undodir")
call mkdir($HOME . "/.vim/undodir","p")
endif
if !isdirectory($HOME . "/.vim/swap")
call mkdir($HOME . "/.vim/swap","p")
endif
set undodir=$HOME/.vim/undodir
set directory=$HOME/.vim/swap
" Fast split navigation with <Ctrl> + hjkl.
noremap <c-h> <c-w><c-h>
noremap <c-j> <c-w><c-j>
noremap <c-k> <c-w><c-k>
noremap <c-l> <c-w><c-l>
command! Bd :bp | :sp | :bn | :bd " Close buffer without clossing window.
set foldmethod=indent " Fold line with indentation.
set foldcolumn=3 " Fold indication.
" open all folds in buffer time.
" autocmd BufRead * normal zR
set wildmenu " Enable enhanced tab autocomplete.
set wildmode=list:longest,full " Complete till longest string,
" then open the wildmenu.
"nnoremap <C-b> :CtrlPBuffer<cr> " Map CtrlP buffer mode to Ctrl + B.
set nu " Number of lines
set hlsearch " Set highlight for searching
set clipboard=unnamedplus " Copy into system (+) register.
" Install the vim-plug if not installed
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
" Manage plugins with vim-plug
call plug#begin()
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'christoomey/vim-tmux-navigator'
Plug 'tpope/vim-vinegar'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'mileszs/ack.vim'
Plug 'easymotion/vim-easymotion'
Plug 'junegunn/vim-plug'
Plug 'junegunn/goyo.vim'
Plug 'junegunn/limelight.vim'
Plug 'sjl/gundo.vim'
let g:plug_timeout = 300 " Increase vim-plug timeout for YouCompleteMe.
Plug 'Valloric/YouCompleteMe', { 'do': './install.py' }
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-dispatch'
Plug 'vim-syntastic/syntastic'
call plug#end()
" Use ; in addition to : to type commands.
noremap ; :
" Saves using <Ctrl-u>.
noremap <c-u> :w<cr>
"Some mapping
"Search using space
nnoremap <space> /
"Exits the insert mode by pressing jk
inoremap jk <esc>
"Saving by pressing <leader>w and quit by pressing <leader>q
" Save a file with leader-w.
nnoremap <leader>w :w<cr>
" Save and quit a file with leader-q.
nnoremap <leader>q :wq<cr>
"Forcing me to use the mapping
inoremap <esc> <nop>
map <up> <nop>
map <down> <nop>
map <right> <nop>
map <left> <nop>
" Open and closing braces
inoremap ( ()<esc>i
" Open NERDTree
nnoremap <leader>n :NERDTreeToggle<cr>
" set CtrlP working directory to a repository root (with a
" fallback to current directory).
let g:ctrlp_working_path_mode = 'ra'
nnoremap <leader>] :YcmCompleter GoTo<cr>
set tags=tags; " Look for a tagas file recursively in
" parent directories.
" Regenerate tags when saving Python files.
autocmd BufWritePost *.py silent! !ctags -R &
" Fix Gundo python issue
if has('python3')
let g:gundo_prefer_python3 = 1
endif
noremap <f5> :GundoToggle<cr> " Map Gundo to <f5>.
nnoremap <leader>g :Goyo<cr> " Map Goyo to ,g.
nnoremap <leader><leader>d :diffu<cr> " Update with diffupdate.
"autocmd filetype python setlocal makeprg=pylint\ --reports=n\ --msg-template=\"{path}:{line}:\ {msg_id}\ {symbol},\ {obj}\ {msg}\"\ %:p
"autocmd filetype python setlocal errorformat=%f:%l:\ %m
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_python_pylint_exe = 'pylint'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment