Skip to content

Instantly share code, notes, and snippets.

@IanMejias
Last active March 9, 2026 13:39
Show Gist options
  • Select an option

  • Save IanMejias/264d8996e90fb84395644a93f6747afa to your computer and use it in GitHub Desktop.

Select an option

Save IanMejias/264d8996e90fb84395644a93f6747afa to your computer and use it in GitHub Desktop.
" vim:fdm=marker
" 0. CORE {{{1
" »»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
" Enable true color 启用终端24位色
if exists('+termguicolors')
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
set termguicolors
endif
set runtimepath+=~\.vim
execute pathogen#infect()
syntax on
filetype plugin indent on
set linebreak
set modeline
set smartcase ignorecase
set smartindent
set updatetime=100
set fo=acjlqrw
set hls
" 1. Fix to autoread {{{1
" »»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
if ! exists("g:CheckUpdateStarted")
let g:CheckUpdateStarted=1
call timer_start(1,'CheckUpdate')
endif
function! CheckUpdate(timer)
silent! checktime
call timer_start(1000,'CheckUpdate')
endfunction
" 2. Looks {{{1
" »»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
set nu rnu
set cursorline
set cc=80
" 3. Autoclosing brackets {{{1
" »»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
inoremap ( ()<left>
inoremap <expr> ) strpart(getline('.'), col('.')-1, 1) == ")" ? "\<Right>" : ")"
inoremap [ []<left>
inoremap <expr> ] strpart(getline('.'), col('.')-1, 1) == "]" ? "\<Right>" : "]"
inoremap { {}<left>
inoremap <expr> } strpart(getline('.'), col('.')-1, 1) == "}" ? "\<Right>" : "}"
inoremap <expr> ' strpart(getline('.'), col('.')-1, 1) == "'" ? "\<Right>" : "''<left>"
inoremap <expr> " strpart(getline('.'), col('.')-1, 1) == "\"" ? "\<Right>" : "\"\"<left>"
" 4. Maps {{{1
" »»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
" switch tabs
nmap <c-tab> gt
nmap <c-s-tab> gT
nmap <c-n> gt
nmap <c-p> gT
" move tabs
" nmap <A-s-h> :-1tabmove<CR>
" nmap <A-s-l> :+1tabmove<CR>
" new tab
nmap <c-t> :tabe<CR>
nmap <c-s> :w<CR>
map <Esc><Esc> :nohls<CR>
inoremap <c-m> <CR><Esc>O
" pasting
imap <c-s-v> <c-r>*
" moving
nmap <c-j> gj
nmap <c-k> gk
nmap <s-k> zc
nmap <down> <c-e>
nmap <up> <c-y>
" commands
imap !date <c-r>=strftime("%Y-%m-%d")<CR>
" 5. Plugins Configuration {{{1
" »»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
" 5.1 NERDTree {{{2
let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾'
let g:NERDTreeSortOrder = ['\/$', '[[extension]]', '*', '\.swp$', '\.bak$', '\~$']
nmap <F3> :NERDTreeToggle<CR>r
nmap <F2> :NERDTreeFind<CR>r
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" 5.2 VimTemplates {{{2
let g:username = 'Ian Mejías'
let g:email = 'idmconejeros@gmail.com'
let g:license = 'GPLv3'
" 5.3 Fugitive {{{2
nmap <F4> :G<CR>
" 5.3 Gruvbox {{{2
set bg=dark
nnoremap <F5> :let &bg=(&bg=='light'?'dark':'light')<cr>
" let g:gruvbox_contrast_dark="hard"
" let g:gruvbox_contrast_light="hard"
let g:gruvbox_material_background = 'hard'
let g:airline_theme = 'gruvbox_material'
colorscheme gruvbox-material
" 5.4 GitGutter {{{2
let g:gitgutter_realtime = 1
let g:gitgutter_preview_win_floating = 1
nmap <F7> <Plug>(GitGutterPrevHunk)
nmap <F8> <Plug>(GitGutterPreviewHunk)
nmap <F9> <Plug>(GitGutterNextHunk)
nmap <F10> <Plug>(GitGutterUndoHunk)
nmap <F12> <Plug>(GitGutterStageHunk)
" 5.5 vim-terraform
let g:terraform_fold_sections=1
" 6. Format {{{1
" »»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
augroup formatting_options
au BufNew,BufRead,BufCreate *.{ts,js,html,css,scss} setlocal sw=2 sts=-1 et fdm=indent
au BufNew,BufRead,BufCreate *.{json,yaml,yml} setlocal sw=2 sts=-1 et fdm=indent
au BufNew,BufRead,BufCreate *.py setlocal nowrap fdm=indent fdn=2 tw=72
au BufNew,BufRead,BufCreate *.{java} setlocal nowrap fdm=syntax fdn=5 fdl=1 sw=4 sts=-1 et
augroup END
augroup javascript_folding
au!
au FileType javascript setlocal foldmethod=syntax
augroup END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment