.vimrc (2909B)
let mapleader="," " define a folder for extra .vim files, keeps the .vimrc itself from growing too big let g:vim_extras_home = get(g:, 'vim_extras_home', expand('$HOME/.config/vim')) execute 'source' g:vim_extras_home.'/spanishkeys.vim' execute 'source' g:vim_extras_home.'/prog_funcs.vim' execute 'source' g:vim_extras_home.'/statusline.vim' execute 'source' g:vim_extras_home.'/sql_query.vim' execute 'source' g:vim_extras_home.'/colours.vim' " get vim to recognize filetype, for getting the FileType event, load plugin for filetype (if any), load indent for filetype (if any) filetype plugin indent on " show existing tab with 4 spaces width set tabstop=4 " when indenting with '>', use 4 spaces width set shiftwidth=4 " press tab, get 4 spaces set expandtab " disables automatic commenting on newline autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o " remebers position of cursor on closed file autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | execute "normal! g`\"" | endif " auto-highlight trailing spaces at the end of line autocmd BufWinEnter,InsertLeave <buffer> match Error /\s\+$/ autocmd InsertEnter <buffer> match Error /\s\+\%#\@<!$/ autocmd BufWinLeave <buffer> call clearmatches() " syntax highlight for certain files augroup ft_detection_all autocmd! autocmd BufNewFile,BufRead /etc/i3/config set filetype=i3config autocmd BufNewFile,BufRead *.handlebars,*.hdbs,*.hbs,*.hb set filetype=html.handlebars autocmd BufNewFile,BufRead *.mustache,*.hogan,*.hulk,*.hjs set filetype=html.mustache augroup end " calls some git related functions for the statusbar augroup GetGitBranch autocmd! autocmd VimEnter,WinEnter,BufEnter * call StatuslineGitBranch() augroup end " a few filetype based maps, for saving a keystroke here and there " <C-o> <- run next command in Normal Mode, <C-m> to insert enter autocmd FileType html,html.handlebars inoremap <leader>! <!--<Space><Space>--><C-o>3h autocmd FileType html,html.handlebars inoremap <leader>t <table><C-m><C-m></table><C-o>^<C-o>k autocmd FileType html.handlebars inoremap <leader>c {{!--<Space><Space>--}}<C-o>4h autocmd FileType javascript inoremap <leader>c console.log('');<C-o>2h autocmd FileType html,javascript nnoremap <leader>s :call SwitchJS()<CR> autocmd FileType sql nnoremap <leader>q :call RunSQLFile()<CR> " when pasting something from another file, we don't want auto-indent nnoremap <leader>p :set invpaste<CR> " source ~/.vimrc (useful to test something simple out) nnoremap <leader><F2> :w<CR>:source %<CR> " save as root cnoremap w!! w !sudo -A tee > /dev/null % " sometimes I need Spanish accents but just in vim for taking notes nnoremap <leader>e :call ToggleSpanishKeys()<CR> " functions to help create or format certain code comments nnoremap <leader>x :call ToMultiLineComment()<CR> nnoremap <leader>y :call OneLineMultiComment()<CR>