💾 Archived View for tilde.club › ~filip › tech › dotfiles › .vimrc captured on 2024-06-16 at 12:51:09.
⬅️ Previous capture (2022-07-16)
-=-=-=-=-=-=-
" GENERAL let skip_defaults_vim=1 set nocompatible " do not force vi compatibility set encoding=UTF-8 " always use utf-8 encoding set viminfo="NONE" " no viminfo file set viewdir=~/.cache/vim/view set noswapfile " no swap file set shortmess+=c " avoid all |hit-enter| promts set autoread " automatically change the file if it has been changed outside vim set backspace=2 " the same as `set backspace=indent,eol,start` set noshowmatch " do not jump to a matching bracket set hidden " don't unload a buffer when no longer shown in a window set updatetime=50 " default is 4000ms set noerrorbells " no error message bells set spelllang=en " British English set lazyredraw " do not redraw screen while executing macros set nowrap set textwidth=0 set clipboard=unnamedplus " global clipboard set iskeyword+=- " treat dash separated words as a word text object" " TAB AND INDENTATION set tabstop=4 softtabstop=4 set shiftwidth=4 "set expandtab set smartindent " AUTOCOMPLETE "" Tab completion set wildmenu set wildmode=longest,list,full "" Omnicomplete (C-d start; <CR> accept; C-e cancel) filetype plugin on set omnifunc=syntaxcomplete#Complete set completeopt=menuone,noinsert,preview inoremap <C-d> <C-x><C-o> inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>" " GUI colorscheme nord "" Syntax syntax on au FileType * setlocal formatoptions-=cro " disable automatic commenting on newline au BufRead,BufNewFile *.gmi,*.gemini,*.gemtext set filetype=gemtext au BufRead,BufNewFile *.tex set filetype=tex "" Cursor set guicursor= if exists('$TMUX') let &t_SI="\<Esc>Ptmux;\<Esc>\e[2 q\<Esc>\\" let &t_SR="\<Esc>Ptmux;\<Esc>\e[2 q\<Esc>\\" let &t_EI="\<Esc>Ptmux;\<Esc>\e[2 q\<Esc>\\" else let &t_SI.="\e[2 q" "SI = INSERT mode let &t_SR.="\e[2 q" "SR = REPLACE mode let &t_EI.="\e[2 q" "EI = NORMAL mode (ELSE) endif """ Cursor settings: 1=blinking block; 2=solid block; 3=blinking underscore; 4=solid underscore; 5=blinking vertical bar; 6=solid vertical bar "" Line numbers set relativenumber " relative numbers set nu " cursor line global number "set cul " cursor line highlight "" Scroll set scrolloff=4 "" Visual mode highlight highlight Visual cterm=reverse ctermbg=NONE "" Status line set laststatus=2 " always show the statusline highlight highlightStatusline ctermfg=darkgrey ctermbg=233 set statusline=%#highlightStatusline#%f\ %y[%{strlen(&fenc)?&fenc:'none'}]%=%l:%c%V\ %P "" Command line set cmdheight=1 " SPLITS set splitbelow set splitright "" Navigation nnoremap <leader>h :split<Enter> nnoremap <leader>v :vsplit<Enter> map <C-h> <C-w>h map <C-j> <C-w>j map <C-k> <C-w>k map <C-l> <C-w>l "" Window resizing nnoremap <Up> :resize +2<Enter> nnoremap <Down> :resize -2<Enter> nnoremap <Left> :vertical resize -2<Enter> nnoremap <Right> :vertical resize +2<Enter> " HISTORY set noswapfile set nobackup set undodir=~/.vim/undodir set undofile " SEARCH set incsearch set smartcase set ignorecase set nohlsearch " MACROS let @w="/haha\<Esc>xxxx\<Insert>" " SCHEME augroup SCHEME autocmd! autocmd BufRead,BufNewFile *.ss syntax keyword Statement lambda conceal cchar=λ autocmd BufRead,BufNewFile *.ss syntax keyword Statement define conceal cchar=Δ autocmd BufRead,BufNewFile *.ss hi! link Conceal Statement autocmd BufRead,BufNewFile *.ss set conceallevel=2 autocmd BufRead,BufNewFile *.ss set concealcursor=nvi augroup END " KEY MAPPINGS "" <ESC> au VimEnter * silent! !xmodmap -e 'clear Lock' -e 'keycode 0x42 = Escape' au VimLeave * silent! !xmodmap -e 'clear Lock' -e 'keycode 0x42 = Caps_Lock' imap jj <Esc> "" <leader> let g:mapleader = " " " set leader key as <Space> "" General nnoremap <leader><Space> /<+++><CR>5x<Insert> vnoremap . :normal .<CR> vnoremap < <gv vnoremap > >gv """ navigation in INSERT mode inoremap <C-h> <C-o>h inoremap <C-j> <C-o>j inoremap <C-k> <C-o>k inoremap <C-l> <C-o>l """ delete to null register vnoremap <leader>d "_d """ open directory tree nnoremap <leader>ex :wincmd v<bar> :Ex <bar> :vertical resize 30<CR> """ wrap nnoremap <leader>tw :call ToggleWrap()<CR> """ spell nnoremap <leader>ts :let &spell=!&spell<CR> "" Quotes nnoremap <leader>qs a‘’<ESC><Insert> nnoremap <leader>qd a“”<ESC><Insert> nnoremap <leader>qa a»«<ESC><Insert> "" XML autocmd FileType xml let @t="\<Insert><<+++>></<+++>>\<ESC>" autocmd FileType xml nnoremap <leader>t "xdawi<<ESC>"xpa></<ESC>"xpa><ESC>cit autocmd FileType xml nnoremap <leader>e o<entry><CR><Tab><id><+++></id><CR><title><+++></title><CR><updated><+++></updated><CR><link href="<+++>" rel="alternate"/><CR><Backspace></entry><ESC>5k "" Shell """ echo autocmd FileType sh nnoremap <leader>e aecho ""<ESC><Insert> """ printf autocmd FileType sh nnoremap <leader>p aprintf ""<ESC><Insert> """ if [[ ]] autocmd FileType sh nnoremap <leader>[ aif [[ ]]; then<Enter><Backspace>fi<ESC><UP>f]<Insert> """ if (( )) autocmd FileType sh nnoremap <leader>( aif (( )); then<Enter><Backspace>fi<ESC><UP>f)<Insert> """ for number autocmd FileType sh nnoremap <leader>for afor ((i=;i<;i++)); do<Enter><Backspace>done<ESC>kf=<Right><Insert> """ iterate over values autocmd FileType sh nnoremap <leader>fval afor item in "${[@]}"; do<Enter><Backspace>done<ESC>kf{a """ iterate over keys autocmd FileType sh nnoremap <leader>fkey afor item in "${![@]}"; do<Enter><Backspace>done<ESC>kf!a """ read file line by line autocmd FileType sh nnoremap <leader>read awhile read line; do<Enter><Backspace>done < $ "" LaTeX autocmd FileType tex nnoremap <leader>na i\documentclass[12pt]{article}<CR><CR>\usepackage[utf8]{inputenc}<CR>\usepackage[T1]{fontenc}<CR>\usepackage[english]{babel}<CR>\usepackage{csquotes}<CR><CR>\usepackage{amsmath,amssymb,amsfonts,amsthm,amscd}<CR>\usepackage{latexsym}<CR>\usepackage{tikz,graphicx,subfigure}<CR>\usepackage{subfigure}<CR>\usepackage{url}<CR><CR>%\usepackage{biblatex}<CR>%\addbibresource{}<CR><CR>\numberwithin{equation}{section}<CR>\newtheorem{defin}[equation]{Definition}<CR>\newtheorem{thm}[equation]{Theorem}<CR>\newtheorem{prop}[equation]{Proposition}<CR>\newtheorem{lem}[equation]{Lemma}<CR>\newtheorem{cor}[equation]{Corollary}<CR>\newtheorem{exam}[equation]{Example}<CR>\newtheorem{rem}[equation]{Remark}<CR>\newtheorem{obs}[equation]{Observation}<CR>\newtheorem{quest}[equation]{Question}<CR>\newtheorem{prob}[equation]{Problem}<CR>\newtheorem{conj}[equation]{Conjecture}<CR><CR>\title{<+++>}<CR>\author{<+++>}<CR>\date{<+++>}<CR><CR>\begin{document}<CR><CR>\maketitle<CR><CR>\begin{abstract}<+++>\end{abstract}<CR><CR>%\printbibliography[title={References}]<CR><CR>\end{document}<ESC>41k autocmd FileType tex nnoremap <leader>b b"xdEa\begin{<ESC>"xpa}\end{<ESC>"xpa}<ESC>F\i "" BibTex au BufRead,BufNewFile *.bib nnoremap <leader>a a@article{,<Enter><Tab>author={},<Enter>title={},<Enter>abstract={},<Enter>journal={},<Enter>volume={},<Enter>number={},<Enter>pages={},<Enter>month=,<Enter>year={},<Enter>issn={},<Enter>url={},<Enter>doi={},<Enter>keywords={},<Enter>}<ESC>14kf,<Insert> au BufRead,BufNewFile *.bib nnoremap <leader>b a@book{,<Enter><Tab>author={},<Enter>title={},<Enter>year={},<Enter>publisher={},<Enter>address={},<Enter>isbn={},<Enter>url={},<Enter>doi={},<Enter>keywords={},<Enter>}<Esc>10kf,<Insert> au BufRead,BufNewFile *.bib nnoremap <leader>c a@inbook{,<Enter><Tab>author={},<Enter>title={},<Enter>chapter={},<Enter>publisher={},<Enter>year={},<Enter>keywords={},<Enter>}<Esc>7kf,<Insert> vnoremap <leader>ss "cy :call RunCode("c","ss")<CR> vnoremap <leader>pp "cy :call RunCode("c","perl")<CR> vnoremap <leader>ll "cy :call RunCode("c","lua")<CR> "inoremap ( ()<Esc>i fun Testtest() let l:xxx =<< trim END of mice and men END echo l:xxx endfun " AUTOCMD "" Functions fun! TrimWhitespace() let l:save = winsaveview() keeppatterns %s/\s\+$//e call winrestview(l:save) endfun fun! ToggleWrap() if (&wrap) set nowrap else set wrap linebreak endif endfun fun RunCode(register,language) let l:tempname = tempname() if (a:language == "ss") call writefile(getreg(a:register,1,1), l:tempname) echom "= SCHEME RESULT BEGIN =" echom system("csi -s " . l:tempname) echom "== SCHEME RESULT END ==" call delete(l:tempname) endif if (a:language == "perl") call writefile(getreg(a:register,1,1), l:tempname) echom "= PERL RESULT BEGIN =" echo system("perl " . l:tempname) echom "== PERL RESULT END ==" call delete(l:tempname) endif if (a:language == "lua") call writefile(getreg(a:register,1,1), l:tempname) echom "= LUA RESULT BEGIN =" echo system("lua " . l:tempname) echom "== LUA RESULT END ==" call delete(l:tempname) endif endfun "" Commands augroup TRIM_WHITESPACES autocmd! autocmd BufWritePre * :call TrimWhitespace() augroup END augroup REMEMBER_FOLDS autocmd! autocmd BufWinLeave * mkview autocmd BufWinEnter * silent! loadview augroup END