Greatly condensed vimrc
This commit is contained in:
parent
a457f85c1f
commit
4b8957e9d4
343
.vimrc
343
.vimrc
|
@ -7,107 +7,64 @@
|
|||
""""""""""""""""""""""
|
||||
set nocp
|
||||
|
||||
so ~/.vim/user/*
|
||||
|
||||
colorscheme desert
|
||||
|
||||
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' <bar> edit!
|
||||
" Ignoring buffer warning ^^^^^^^^^^^
|
||||
set foldmethod=syntax
|
||||
set foldlevelstart=5
|
||||
|
||||
nnoremap <C-C> "+yy
|
||||
vnoremap <C-C> "+y
|
||||
|
||||
nnoremap <Leader>b :ls<CR>:b<Space>
|
||||
set backspace=indent,eol ",start
|
||||
|
||||
set splitbelow
|
||||
set splitright
|
||||
|
||||
nnoremap <Space>j 10j
|
||||
nnoremap <Space>k 10k
|
||||
|
||||
nnoremap :W<CR> :w<CR>
|
||||
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
|
||||
|
||||
set conceallevel=0
|
||||
|
||||
" Use 4 spaces
|
||||
set tabstop=8
|
||||
set softtabstop=0
|
||||
set expandtab
|
||||
set shiftwidth=8
|
||||
set smarttab
|
||||
set conceallevel=0
|
||||
set tabstop=8 softtabstop=0 expandtab shiftwidth=8 smarttab
|
||||
|
||||
" Except for makefiles
|
||||
autocmd FileType make setlocal noexpandtab
|
||||
|
||||
" Search up to ~ for tags file
|
||||
" Search up to / for tags file
|
||||
set tags=./tags;/
|
||||
|
||||
" setl spell
|
||||
" *** BINDINGS ***
|
||||
|
||||
" Beautful escapes
|
||||
inoremap jj <Esc>l
|
||||
inoremap jk <Esc>l
|
||||
inoremap kj <Esc>l
|
||||
|
||||
" C comment
|
||||
nnoremap // m`I//<Esc>``:s-////--<Cr>
|
||||
|
||||
" Current-file keywords
|
||||
inoremap <C-J> <C-X><C-N>
|
||||
|
||||
" 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 number relativenumber
|
||||
|
||||
set ignorecase
|
||||
set smartcase
|
||||
set ignorecase smartcase
|
||||
set autoindent smartindent
|
||||
|
||||
set autoindent
|
||||
set smartindent
|
||||
"Yank to clipboard
|
||||
nnoremap <C-C> "+yy
|
||||
vnoremap <C-C> "+y
|
||||
|
||||
colorscheme desert
|
||||
|
||||
inoremap jj <Esc>l
|
||||
|
||||
" Add ; to end of line
|
||||
nnoremap :: m`A;<Esc>``
|
||||
|
||||
" Put above line at end of current line
|
||||
nnoremap K kddpkJ:s-//-//<-<CR>
|
||||
|
||||
nnoremap <. :s/ //<CR>
|
||||
nnoremap >. :s/\s\+$//e<CR>:s/.*\zs / /<CR>
|
||||
" List buffers
|
||||
nnoremap <Leader>b :ls<CR>:b<Space>
|
||||
|
||||
nnoremap <C-I> ^
|
||||
|
||||
nnoremap U ~
|
||||
nnoremap ~ U
|
||||
|
||||
" Paste last yank (not delete))
|
||||
nnoremap "p "0p
|
||||
|
@ -118,13 +75,6 @@ nnoremap <C-K> <C-W><C-K>
|
|||
nnoremap <C-L> <C-W><C-L>
|
||||
nnoremap <C-H> <C-W><C-H>
|
||||
|
||||
" inoremap <C-J> <Esc><C-W><C-J>
|
||||
" inoremap <C-K> <Esc><C-W><C-K>
|
||||
" inoremap <C-L> <Esc><C-W><C-L>
|
||||
" inoremap <C-H> <Esc><C-W><C-H>
|
||||
|
||||
inoremap <C-D> <C-X><C-K>
|
||||
|
||||
nnoremap ! :!
|
||||
|
||||
" Map directions to end/beginning of lines
|
||||
|
@ -136,126 +86,23 @@ nnoremap dh d^
|
|||
" <C-P> will replace text after the cursor with unnamed reg contents
|
||||
nnoremap <C-P> 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//<Esc>``:s-////--<Cr>
|
||||
nnoremap <Leader>te :stopprog<CR>:runprog<CR>
|
||||
else " Use plugin when in normal vim
|
||||
nnoremap // :call NERDComment(0,"toggle")<CR>
|
||||
nnoremap <Leader>te :w<CR>:!clear && cargo test<CR>
|
||||
" nnoremap w :call AfterUnderscore()<CR>
|
||||
nnoremap W :silent! call JumpCase("go")<CR>
|
||||
nnoremap gd lb:call Follow()<CR>
|
||||
endif
|
||||
|
||||
" Generate and display a printable version
|
||||
nnoremap <Leader>PP :ha > ~/.vim.ps<CR>:!xdg-open ~/.vim.ps<CR>
|
||||
vnoremap <Leader>PP :ha > ~/.vim.ps<CR>:!xdg-open ~/.vim.ps<CR>
|
||||
|
||||
nnoremap <Leader>p :call Build()<CR>
|
||||
nnoremap <Leader>R :call Run()<CR>
|
||||
|
||||
autocmd FileType vim ab nre nnoremap
|
||||
autocmd FileType vim ab ire inoremap
|
||||
|
||||
" Return spelling corrections
|
||||
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 <Leader>/ I/**<CR>
|
||||
|
||||
nnoremap cw ciw
|
||||
nnoremap ciw cw
|
||||
"
|
||||
|
||||
" Swap current word with next
|
||||
" nnoremap gs dawwP
|
||||
nnoremap gs "xdiwdwep"xp
|
||||
" Inverted
|
||||
nnoremap gb dawbP
|
||||
|
||||
noremap <C-,> ,
|
||||
noremap <C-;> ,
|
||||
|
||||
" Git without needing '!'
|
||||
cnoreabbrev git !git
|
||||
cnoreabbrev grepr !grepr
|
||||
|
||||
nnoremap <Leader>gd :!git diff %<CR>
|
||||
nnoremap <Leader>gD :!git diff<CR>
|
||||
nnoremap <Leader>gB :!git blame %<CR>
|
||||
|
@ -270,43 +117,12 @@ nnoremap <Leader>r :source ~/.vimrc<CR>
|
|||
nnoremap <Leader>v :tabedit~/.vimrc<CR>
|
||||
nnoremap <Leader>n :tabedit~/.notes<CR>
|
||||
|
||||
"" Add back-Ticks to outside of current word
|
||||
" nnoremap gt bi`<Esc>ea`<Esc>
|
||||
|
||||
set expandtab
|
||||
set tabstop=4
|
||||
|
||||
autocmd BufNewFile,BufRead * if expand('%:t') !~ '\.' | setl spell | endif
|
||||
"
|
||||
" inoremap AA <Esc>A
|
||||
" inoremap II <Esc>I
|
||||
" inoremap OO <Esc>O
|
||||
"
|
||||
" inoremap SS <Esc>S
|
||||
" inoremap UU <Esc>u
|
||||
" inoremap DD <Esc>dd
|
||||
|
||||
" nnoremap Oj O<Esc>j
|
||||
" nnoremap OJ O<Esc>j
|
||||
" nnoremap ok o<Esc>k
|
||||
|
||||
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 <expr> %% 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 <C-L> $A \|<Esc>gv<Esc>yyp:s/./_/g<CR>:s/^_/\|/<CR>:s/_$/\|/<CR>o\|<Esc>oV<Esc>o<Esc>
|
||||
|
||||
" Skeletons "
|
||||
if has ("autocmd")
|
||||
|
@ -320,94 +136,3 @@ if has ("autocmd")
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue