"""""""""""""""""""""" " __ _____ __ __ " " \ \ / /_ _| \/ | " " \ V / | || |\/| | " " \_/ |___|_| |_| " " " """""""""""""""""""""" set nocp set tsr+=~/.vim/thesaurus/thesaurus-vim-en set dict+=/usr/share/dict/words " Save-vvvvv vvvv-with root v- To original file cnoremap w!! execute 'silent! write !sudo /usr/bin/tee % >/dev/null' edit! " Ignoring buffer warning ^^^^^^^^^^^ nnoremap "+yy vnoremap "+y nnoremap b :ls:b set splitbelow set splitright nnoremap j 10j nnoremap k 10k nnoremap :W :w nnoremap z* *zz nnoremap z# #zz nnoremap Z* *zz nnoremap Z# #zz nnoremap zn nzz nnoremap zN Nzz nnoremap ZN Nzz nnoremap z[ [[zz nnoremap z] ]]zz " Use 4 spaces set tabstop=8 set softtabstop=0 set expandtab set shiftwidth=8 set smarttab set conceallevel=0 " Except for makefiles autocmd FileType make setlocal noexpandtab " Search up to ~ for tags file set tags=./tags;/ " setl spell inoremap " adjust a missed delete nnoremap du ujdd onoremap ~a ta~ onoremap ~b tb~ onoremap ~c tc~ onoremap ~d td~ onoremap ~e te~ onoremap ~f tf~ onoremap ~g tg~ onoremap ~h th~ onoremap ~i ti~ onoremap ~j tj~ onoremap ~k tk~ onoremap ~l tl~ onoremap ~m tm~ onoremap ~n tn~ onoremap ~o to~ onoremap ~p tp~ onoremap ~q tq~ onoremap ~r tr~ onoremap ~s ts~ onoremap ~t tt~ onoremap ~u tu~ onoremap ~v tv~ onoremap ~w tw~ onoremap ~x tx~ onoremap ~y ty~ onoremap ~z tz~ " Line numbers set number set relativenumber set ignorecase set smartcase set autoindent set smartindent colorscheme desert inoremap jj l " Add ; to end of line nnoremap :: m`A;`` " Put above line at end of current line nnoremap K kddpkJ:s-//-//<- nnoremap <. :s/ // nnoremap >. :s/\s\+$//e:s/.*\zs / / nnoremap ^ nnoremap U ~ " Paste last yank (not delete)) nnoremap "p "0p " Window jumps nnoremap nnoremap nnoremap nnoremap " inoremap " inoremap " inoremap " inoremap inoremap nnoremap ! :! " Map directions to end/beginning of lines nnoremap yl y$ nnoremap yh y^ nnoremap dl d$ nnoremap dh d^ " will replace text after the cursor with unnamed reg contents nnoremap m`v$hp``y$ set foldmethod=syntax set foldlevelstart=5 " PLUGINS " let g:NERDSpaceDelims = 1 let g:NERDCompactSexyComs = 1 filetype plugin on let IS_QT = !has("python") if IS_QT " For Qt Creator, etc., use C hardcode nnoremap // m`I//``:s-////-- nnoremap te :stopprog:runprog else " Use plugin when in normal vim nnoremap // :call NERDComment(0,"toggle") nnoremap te :w:!clear && cargo test " nnoremap w :call AfterUnderscore() nnoremap W :silent! call JumpCase("go") nnoremap gd lb:call Follow() endif " Generate and display a printable version nnoremap PP :ha > ~/.vim.ps:!xdg-open ~/.vim.ps vnoremap PP :ha > ~/.vim.ps:!xdg-open ~/.vim.ps nnoremap p :call Build() nnoremap R :call Run() autocmd FileType vim ab nre nnoremap autocmd FileType vim ab ire inoremap iab ruetn return iab reteun return iab reutner return " Display last 5 lines of clisp output autocmd FileType lisp call SetUpBuild() autocmd FileType python call SetUpBuild() autocmd FileType ruby call SetUpBuild() " Display last 5 lines of python output function! SetUpBuild() let &cmdheight=10 setl updatetime=400 autocmd CursorHold * call Build() endfunction function! LispBuild() redraw! silent write! /tmp/lisp.lisp echo system("clisp /tmp/lisp.lisp | tail -n 5") endfunction function! PyBuild() redraw! silent write! /tmp/py.py echo system("python3 /tmp/py.py | tail -n 5") endfunction function! RubyBuild() redraw! silent write! /tmp/rb.rb echo system("ruby /tmp/rb.rb | tail -n 5") endfunction function! CBuild() redraw! if(filereadable(expand("%:h/makefile"))) !make else silent write! silent !gcc % endif endfunction function! Build() if(&ft=='lisp') call LispBuild() elseif(&ft=='ruby') call RubyBuild() elseif(&ft=='python') call PyBuild() elseif(&ft=='c') call CBuild() elseif(expand("%:p") =~ "banana_pi_kernel") setl updatetime=100000 " 100 seconds silent !/home/cprtools/.screen_build.sh endif endfunction function! Run() if(expand("%:p") =~ "banana_pi_kernel") silent !/home/cprtools/.screen_update.sh elseif(&ft=='c') call Build() !./a.out endif endfunction nnoremap / I/** nnoremap cw ciw nnoremap ciw cw " " Swap current word with next " nnoremap gs dawwP nnoremap gs "xdiwdwep"xp " Inverted nnoremap gb dawbP noremap , noremap , " Git without needing '!' cnoreabbrev git !git cnoreabbrev grepr !grepr nnoremap gd :!git diff % nnoremap gD :!git diff nnoremap gB :!git blame % nnoremap gc :!git commit -m "" nnoremap gh :!git --help nnoremap gl :!git log nnoremap gp :!git push nnoremap gu :!git add -u nnoremap ga :!git add % nnoremap r :source ~/.vimrc nnoremap v :tabedit~/.vimrc nnoremap n :tabedit~/.notes "" Add back-Ticks to outside of current word " nnoremap gt bi`ea` set expandtab set tabstop=4 autocmd BufNewFile,BufRead * if expand('%:t') !~ '\.' | setl spell | endif " " inoremap AA A " inoremap II I " inoremap OO O " " inoremap SS S " inoremap UU u " inoremap DD dd " nnoremap Oj Oj " nnoremap OJ Oj " nnoremap ok ok highlight Conceal term=bold cterm=bold ctermfg=white ctermbg=NONE highlight OverLengthC ctermbg=black ctermfg=red guibg=#592929 match OverLengthC /\%81v.\+/ syntax match concConc ".\{-}m" conceal cchar=# syntax match concConc "#\[.\{-}\]" conceal cchar=# " hi link Conceal concConc " Expand %% to the current files dir cabbr %% expand('%:p:h') cnoreabbrev vimc tabedit ~/.vimrc cnoreabbrev cargo !cargo " Try to add an arrow around the right and bottom of the visual selection vnoremap $A \|gvyyp:s/./_/g:s/^_/\|/:s/_$/\|/o\|oVo " Skeletons " if has ("autocmd") augroup templates autocmd BufNewFile *.cpp 0r ~/.vim/templates/skeleton.cpp autocmd BufNewFile *.c 0r ~/.vim/templates/skeleton.c autocmd BufNewFile *.sh 0r ~/.vim/templates/skeleton.sh autocmd BufNewFile *.lisp 0r ~/.vim/templates/skeleton.lisp autocmd BufNewFile *.py 0r ~/.vim/templates/skeleton.py autocmd BufNewFile *.rb 0r ~/.vim/templates/skeleton.rb autocmd BufNewFile makefile 0r ~/.vim/templates/makefile augroup END endif autocmd BufWrite .notes call SubColors() autocmd BufRead .notes set conceallevel=3 autocmd BufRead .notes match OverLengthC /\%981v.\+/ function! SubColors() silent! %s/#\[black\]/\[30m/g silent! %s/#\[red\]/\[31m/g silent! %s/#\[green\]/\[32m/g silent! %s/#\[yellow\]/\[33m/g silent! %s/#\[yel\]/\[33m/g silent! %s/#\[blue\]/\[34m/g silent! %s/#\[magenta\]/\[35;1m/g silent! %s/#\[mag\]/\[35m/g silent! %s/#\[reset\]/\[0m/g silent! %s/#\[u\]/\[4m/g silent! %s/#\[und\]/\[4m/g silent! %s/#\[underline\]/\[4m/g endfunction function! ExMac() let l:macro_file_name = "__macroexpand__" . tabpagenr() let l:file_name = expand("%") " Create mark execute "normal! Oint " . l:macro_file_name . ";" execute "w" let buffbuff = system("gcc -E " . l:file_name . " | grep " \ . l:macro_file_name . " | sed 's/int __macroexpand__...//'") execute "normal!u" execute "w" echo buffbuff endfunction " w (and only w) will not skip past underscores function! AfterUnderscore() set iskeyword=@,48-57,# execute "normal! w" if getline('.')[col('.')-1] == '_' execute "normal! l" endif set iskeyword=@,48-57,_,192-255,# endfunction function! Follow() let save_pos = getpos(".") let l:char = getline('.')[col('.')-1] execute "normal! gd" if getpos(".") == save_pos && l:char == getline('.')[col('.')-1] execute "normal! " endif endfunction " W jumps to the next capitalized letter function! JumpCase(del) set noignorecase let l:char = getline('.')[col('.')-1] while l:char == toupper(l:char) let l:col = col('.') execute "normal! l" let l:char = getline('.')[col('.')-1] if l:col == col('.') execute "normal! j^" if l:col == col('.') break endif endif endwhile while l:char != toupper(l:char) let l:col = col('.') execute "normal! l" let l:char = getline('.')[col('.')-1] if l:col == col('.') execute "normal! j^" if l:col == col('.') break endif else if a:del == "del" execute "normal! x" endif endif endwhile set ignorecase endfunction set backspace=indent,eol ",start