Skip to content

Instantly share code, notes, and snippets.

@srithon
Created May 2, 2020
Embed
What would you like to do?
My .vimrc config as of 5/2/2020
" Source: https://www.youtube.com/watch?v=FWUeqcBQmDo
" Use system clipboard
" set clipboard+=unnamedplus
" autocmd InsertEnter * norm zz
" Source: https://www.linode.com/docs/tools-reference/tools/introduction-to-vim-customization/
" Set compatibility to Vim only.
set nocompatible
" Helps force plug-ins to load correctly when it is turned back on below.
filetype off
" Turn on syntax highlighting.
syntax on
" For plug-ins to load correctly.
filetype plugin indent on
" Turn off modelines
set modelines=0
" Automatically wrap text that extends beyond the screen length.
" set wrap
" ^ set wrap will split words across lines, linebreak does not
set linebreak
" Vim's auto indentation feature does not work properly with text copied from outside of Vim. Press the <F2> key to toggle paste mode on/off.
" nnoremap <F2> :set invpaste paste?<CR>
" imap <F2> <C-O>:set invpaste paste?<CR>
" set pastetoggle=<F2>
" Uncomment below to set the max textwidth. Use a value corresponding to the width of your screen.
" set textwidth=79
set formatoptions=tcqrn1
set tabstop=4
set shiftwidth=2
set softtabstop=2
set expandtab
set noshiftround
" Display 5 lines above/below the cursor when scrolling with a mouse.
set scrolloff=5
" Fixes common backspace problems
set backspace=indent,eol,start
" Speed up scrolling in Vim
set ttyfast
" Status bar
set laststatus=2
" Set True Color in terminal
set termguicolors
" Display options
" set showmode
set showcmd
set noshowmode
" Highlight matching pairs of brackets. Use the '%' character to jump between them.
set matchpairs+=<:>
" Display different types of white spaces.
set list
set listchars=tab:›\ ,trail:•,extends:#,nbsp:.
" Enable mouse
set mouse=a
" Show line numbers
set number
set relativenumber
set number relativenumber
" Encoding
set encoding=utf-8
" Highlight matching search patterns
set hlsearch
" Enable incremental search
set incsearch
" Include matching uppercase words with lowercase search term
set ignorecase
" Include only uppercase words with uppercase search term
set smartcase
" Store info from no more than 100 files at a time, 9999 lines of text, 100kb of data. Useful for copying large amounts of data between files.
set viminfo='100,<9999,s100
" Tab completion wildmode
set wildmode=longest,list,full
" Fix splitting
set splitbelow splitright
" " Map the <Space> key to toggle a selected fold opened/closed.
" nnoremap <silent> <Space> @=(foldlevel('.')?'za':"\<Space>")<CR>
" vnoremap <Space> zf
"
" " Automatically save and load folds
" autocmd BufWinLeave *.* mkview
" autocmd BufWinEnter *.* silent loadview"
" Vim-Plug
call plug#begin('~/.vim/plugged')
" Make sure you use single quotes
" Plug 'junegunn/seoul256.vim'
" Plug 'junegunn/vim-easy-align'
" Commenting code
Plug 'tomtom/tcomment_vim'
" Fuzzy search
Plug 'ctrlpvim/ctrlp.vim'
" OneDark theme
Plug 'joshdick/onedark.vim'
" High Contrast Theme
Plug 'agude/vim-eldar'
" Other theme
Plug 'arcticicestudio/nord-vim'
" Statusline
Plug 'itchyny/lightline.vim'
" Syntax Highlighting
Plug 'sheerun/vim-polyglot'
" Git Integration
Plug 'tpope/vim-fugitive'
" Code Completion
Plug 'ycm-core/YouCompleteMe'
" Vim Wiki
" Plug 'vimwiki/vimwiki'
let g:ycm_clangd_binary_path = "/usr/bin/clangd"
" Group dependencies, vim-snippets depends on ultisnips
" Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
" On-demand loading
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
" Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
" Using git URL
" Plug 'https://github.com/junegunn/vim-github-dashboard.git'
" Plugin options
" Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' }
" Plugin outside ~/.vim/plugged with post-update hook
" Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': 'yes \| ./install' }
" Unmanaged plugin (manually installed and updated)
" Plug '~/my-prototype-plugin'
" Surround
Plug 'tpope/vim-surround'
" Improved incremental search
" Plug 'haya14busa/incsearch.vim'
" Quick-scope; highlighting for f, t, F, T
Plug 'unblevable/quick-scope'
" Distraction-free writing
Plug 'junegunn/goyo.vim'
" Focus current paragraph
" For use with Goyo
Plug 'junegunn/limelight.vim'
" Markdown
Plug 'godlygeek/tabular'
" Plug 'plasticboy/vim-markdown', { 'for': ['markdown'] }
Plug 'gabrielelana/vim-markdown'
" nvim Firefox integration
if has('nvim')
Plug 'glacambre/firenvim', { 'do': { _ -> firenvim#install(0) } }
" let g:firenvim_config = {
" \ "globalSettings": {
" \ "server": "persistent"
" \}
" \}
endif
call plug#end()
" Set color theme!
let g:onedark_hide_endofbuffer = 1
let g:onedark_termcolors = 256
let g:onedark_terminal_italics = 0
" colorscheme onedark
colorscheme eldar
" Set statusline theme
let g:lightline = {
\ 'colorscheme': 'powerlineish',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'gitbranch', 'readonly', 'filename', 'modified' ] ]
\ },
\ 'component_function': {
\ 'gitbranch': 'FugitiveHead',
\ 'readonly': 'LightlineReadonly',
\ },
\ }
" https://github.com/itchyny/lightline.vim/issues/168#issuecomment-569881983
" Make the statusline transparent
autocmd VimEnter * call SetupLightlineColors()
function SetupLightlineColors() abort
" transparent background in statusbar
let l:palette = lightline#palette()
let l:palette.normal.middle = [ [ 'NONE', 'NONE', 'NONE', 'NONE' ] ]
let l:palette.inactive.middle = l:palette.normal.middle
let l:palette.tabline.middle = l:palette.normal.middle
call lightline#colorscheme()
endfunction
function! LightlineReadonly()
return &readonly && &filetype !=# 'help' ? 'Read-Only' : ''
endfunction
" function! SetLightTheme() abort
"
"
" :command LightTheme
" Keymappings
noremap <Space> <Nop>
let mapleader = ' '
" nnoremap <silent> <Leader>/ :TComment<CR>
" Bind 'jk' to escape
inoremap jk <Esc>
" Bind ctrl-hjkl to movement in insert mode
" inoremap <C-k> <Up>
" inoremap <C-h> <Left>
" inoremap <C-l> <Right>
" inoremap <C-j> <Down>
" Brodie Robertson's video
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" Shortcut 'S' for find and replace
nnoremap S :%s//gI<Left><Left><Left>
nnoremap <leader>h :split<Space>
nnoremap <leader>v :vsplit<Space>
" Bind '/<Enter>' to clearing current search highlighting
nnoremap /<CR> :let @/=""<CR>
" Bind Leader + Arrow Keys to resize splits
" nnoremap <leader><Up> 5<C-W>+
" nnoremap <leader><Down> 5<C-W>-
" nnoremap <leader><Left> 5<C-W><
" nnoremap <leader><Right> 5<C-W>>
" Remap arrow keys in normal mode to resizing splits
" Source: https://www.youtube.com/watch?v=Igfm59WL3NE
nnoremap <Up> :resize +2<CR>
nnoremap <Down> :resize -2<CR>
nnoremap <Left> :vertical resize +2<CR>
nnoremap <Right> :vertical resize -2<CR>
" Make it easier to indent a visual selection several times
xnoremap > >gv
xnoremap < <gv
" Toggle Goyo
nnoremap <leader>g :Goyo<CR>
" NERDTree
nnoremap <leader>k :NERDTreeToggle<CR>
"Goyo.vim with Limelight
autocmd! User GoyoEnter Limelight
autocmd! User GoyoLeave Limelight!
" https://github.com/stoeffel/.dotfiles/blob/master/vim/visual-at.vim
" executes a macro for each line in the selection
xnoremap @ :<C-u>call ExecuteMacroOverVisualRange()<CR>
function! ExecuteMacroOverVisualRange()
echo "@".getcmdline()
execute ":'<,'>normal @".nr2char(getchar())
endfunction
" Markdown settings
" autocmd FileType markdown set conceallevel=0
"
" let g:vim_markdown_new_list_item_indent = 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment