Last active
January 22, 2020 15:27
-
-
Save Tmjohnst/1ae4ee0a97438cc4a75ae6e5ca1f65f0 to your computer and use it in GitHub Desktop.
My personal .vimrc aggregated from all over
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"{{{Auto Commands | |
" Stole these from https://stackoverflow.com/a/171558 | |
" Automatically cd into the directory that the file is in | |
autocmd BufEnter * execute "chdir ".escape(expand("%:p:h"), ' ') | |
" Remove any trailing whitespace that is in the file | |
autocmd BufRead,BufWrite * if ! &bin | silent! %s/\s\+$//ge | endif | |
" Restore cursor position to where it was before | |
augroup JumpCursorOnEdit | |
au! | |
autocmd BufReadPost * | |
\ if expand("<afile>:p:h") !=? $TEMP | | |
\ if line("'\"") > 1 && line("'\"") <= line("$") | | |
\ let JumpCursorOnEdit_foo = line("'\"") | | |
\ let b:doopenfold = 1 | | |
\ if (foldlevel(JumpCursorOnEdit_foo) > foldlevel(JumpCursorOnEdit_foo - 1)) | | |
\ let JumpCursorOnEdit_foo = JumpCursorOnEdit_foo - 1 | | |
\ let b:doopenfold = 2 | | |
\ endif | | |
\ exe JumpCursorOnEdit_foo | | |
\ endif | | |
\ endif | |
" Need to postpone using "zv" until after reading the modelines. | |
autocmd BufWinEnter * | |
\ if exists("b:doopenfold") | | |
\ exe "normal zv" | | |
\ if(b:doopenfold > 1) | | |
\ exe "+".1 | | |
\ endif | | |
\ unlet b:doopenfold | | |
\ endif | |
augroup END | |
"}}} | |
"{{{ Begin plugins | |
call plug#begin('~/.vim/plugged') | |
"{{ Configuring NerdTree | |
Plug 'scrooloose/nerdtree' | |
" ---> to hide unwanted files <--- | |
let NERDTreeIgnore = [ '__pycache__', '\.pyc$', '\.o$', '\.swp', '*\.swp', 'node_modules/' ] | |
" ---> show hidden files <--- | |
let NERDTreeShowHidden=1 | |
" ---> autostart nerd-tree when you start vim <--- | |
autocmd vimenter * NERDTree | |
autocmd StdinReadPre * let s:std_in=1 | |
autocmd VimEnter * if argc() == 0 && !exists("s:stdn_in") | NERDTree | endif | |
" ---> toggling nerd-tree using Ctrl-N <--- | |
map <C-n> :NERDTreeToggle<CR> | |
"}} | |
"{{ Configuring YouCompleteMe | |
Plug 'valloric/youcompleteme', { 'do': './install.py' } | |
" ---> youcompleteme configuration <--- | |
let g:ycm_global_ycm_extra_conf = '~/.vim/.ycm_extra_conf.py' | |
" ---> compatibility with another plugin (ultisnips) <--- | |
let g:ycm_key_list_select_completion = [ '<C-n>', '<Down>' ] | |
let g:ycm_key_list_previous_completion = [ '<C-p>', '<Up>' ] | |
let g:SuperTabDefaultCompletionType = '<C-n>' | |
" ---> disable preview window <--- | |
set completeopt-=preview | |
" ---> navigating to the definition of a a symbol <--- | |
map <leader>g :YcmCompleter GoToDefinitionElseDeclaration<CR> | |
"}} | |
"{{ Color-scheme | |
Plug 'morhetz/gruvbox' | |
set background=dark | |
colorscheme gruvbox | |
let g:gruvbox_contrast_dark='default' | |
"}} | |
"{{ TMux - Vim integration | |
Plug 'christoomey/vim-tmux-navigator' | |
"}} | |
call plug#end() | |
"}}} | |
set showcmd " Shows what you are typing as a command | |
set foldmethod=marker " Folding method | |
set smarttab " Inserts spaces when you hit tab? | |
set tabstop=2 " Display <TAB>s as 2 spaces wide | |
set softtabstop=2 " Insert 2 spaces for every <TAB> when editing | |
set expandtab " Expand <TAB>s in editing to spaces instead | |
set shiftwidth=2 " Insert 2 spaces for code folding | |
syntax enable " Enable syntax highlighting | |
set autoindent " Enable auto-indenting | |
set ignorecase " Ignore case for search/replace | |
set smartcase " Enables case searching if case is used | |
inoremap jj <Esc> " Remap jj to escape in insert mode. | |
nnoremap <silent> <Leader>ev :tabnew<CR>:e ~/.vimrc<CR> " Edit vimrc \ev | |
set number " Turn on line numbers | |
set showcmd " Show the last command in the boTtom right | |
set cursorline " Highlight the line the cursor is on | |
filetype indent on " Load filetype-specific indent config (is this needed?) | |
set showmatch " Mark the closing [{( )}] 's in code | |
set incsearch " Incrementally search | |
set hlsearch " Highlight search matches | |
set nocompatible " Turn off compatible before vim initializes | |
set encoding=utf-8 | |
filetype plugin indent on | |
call plug#begin('~/.vim/plugged') | |
call plug#end() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment