Skip to content

Instantly share code, notes, and snippets.

@WhoAteDaCake
Last active January 4, 2021 18:50
Show Gist options
  • Save WhoAteDaCake/3002aadf6ba1bd20d8047f8057c35dae to your computer and use it in GitHub Desktop.
Save WhoAteDaCake/3002aadf6ba1bd20d8047f8057c35dae to your computer and use it in GitHub Desktop.
call plug#begin()
Plug 'joshdick/onedark.vim'
Plug 'sheerun/vim-polyglot'
Plug 'lifepillar/pgsql.vim'
Plug 'ctrlpvim/ctrlp.vim'
call plug#end()
set runtimepath^=~/.vim/bundle/ctrlp.vim
let g:ctrlp_custom_ignore = '\v[\/](node_modules|target|dist)|(\.(swp|ico|git|svn))$'
let g:sql_type_default = 'pgsql'
syntax on
colorscheme onedark
" Spaces & Tabs {{{
set tabstop=2 " number of visual spaces per TAB
set softtabstop=2 " number of spaces in tab when editing
set shiftwidth=2 " number of spaces to use for autoindent
set expandtab " tabs are space
set autoindent
set copyindent " copy indent from the previous line
" }}} Spaces & Tabs
" Clipboard {{{
set clipboard+=unnamedplus
" }}} Clipboard
" UI Config {{{
set hidden
set number " show line number
set showcmd " show command in bottom bar
set cursorline " highlight current line
" Auto complete
set wildmenu " visual autocomplete for command menu
set wildmode=list:full
set wildignorecase
set showmatch " highlight matching brace
set laststatus=2 " window will always have a status line
set nobackup
set noswapfile
let &colorcolumn="80,".join(range(119,999),",")
" }}} UI Config
" Search {{{
set incsearch " search as characters are entered
set hlsearch " highlight matche
set ignorecase " ignore case when searching
set smartcase " ignore case if search pattern is lower case
" case-sensitive otherwise
" Folding {{{
set foldenable
set foldlevelstart=10 " default folding level when buffer is opened
set foldnestmax=10 " maximum nested fold
set foldmethod=syntax " fold based on indentation
" }}} Folding
" Leader & Mappings {{{
let mapleader="," " leader is comma
" edit/reload vimrc
nmap <leader>ev :e $MYVIMRC<CR>
nmap <leader>sv :so $MYVIMRC<CR>
" better ESC
inoremap jj <esc>
" fast save and close
nmap <leader>w :w<CR>
nmap <leader>x :x<CR>
nmap <leader>q :q<CR>
" insert blank line before current line without leaving insert mode
imap <leader>o <c-o><s-o>
" move up/down consider wrapped lines
nnoremap j gj
nnoremap k gk
" fix indentation
nnoremap <leader>i mzgg=G`z<CR>
" turn off search highlights
nnoremap <leader><space> :nohlsearch<CR>
" move through grep results
" nmap <silent> <right> :cnext<CR>
" nmap <silent> <left> :cprev<CR>
" buffers
nnoremap <tab> :bn<CR>
nnoremap <s-tab> :bp<CR>
nnoremap <leader>bd :bd<CR>
" split navigation
nnoremap <c-j> <c-w><c-j>
nnoremap <c-k> <c-w><c-k>
nnoremap <c-l> <c-w><c-l>
nnoremap <c-h> <c-w><c-h>
" regex completion instead of whole word completion
nnoremap <leader>f :find *
" restrict the matching to files under the directory
" of the current file, recursively
nnoremap <leader>F :find <C-R>=expand('%:p:h').'/**/*'<CR>
" same as the two above but opens the file in an horizontal window
nnoremap <leader>s :sfind *
nnoremap <leader>S :sfind <C-R>=expand('%:p:h').'/**/*'<CR>
" same as the two above but with a vertical window
nnoremap <leader>v :vert sfind *
nnoremap <leader>V :vert sfind <C-R>=expand('%:p:h').'/**/*'<CR>
" for command mode
nnoremap <S-Tab> <<
" for insert mode
inoremap <S-Tab> <C-d>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment