2015-03-09 10:02:16 -07:00
|
|
|
|
" make vim unusable for anyone else
|
2015-03-10 14:42:26 -07:00
|
|
|
|
" from the get-go, we assume version >= 703
|
2015-03-09 10:02:16 -07:00
|
|
|
|
|
2013-07-04 01:39:44 -07:00
|
|
|
|
set nocompatible " screw vi
|
2013-07-03 15:03:54 -07:00
|
|
|
|
|
2015-03-09 12:27:15 -07:00
|
|
|
|
" hacks {{{1
|
2013-07-04 01:39:44 -07:00
|
|
|
|
if has('multi_byte')
|
|
|
|
|
scriptencoding utf-8 " allow it in this script
|
|
|
|
|
set termencoding=utf-8 " and this terminal supports it
|
|
|
|
|
set encoding=utf-8 " and the default file is in it
|
2013-07-03 15:03:54 -07:00
|
|
|
|
endif
|
|
|
|
|
|
2022-09-08 00:07:57 -07:00
|
|
|
|
let g:rcvim=$HOME.'/.vim'
|
2015-03-10 15:21:29 -07:00
|
|
|
|
let &backupdir=g:rcvim.'/backup' " stash tilde files elsewhere
|
2021-10-19 00:10:51 -07:00
|
|
|
|
" using a double slash here enables file path inclusion for uniqueness:
|
2015-03-10 15:21:29 -07:00
|
|
|
|
let &directory=g:rcvim.'/swp//' " stash swap files too
|
|
|
|
|
let &undodir=g:rcvim.'/undo/' " undo files are cool
|
2021-10-19 02:56:42 -07:00
|
|
|
|
try | call mkdir(&backupdir, "p") | catch /E739/ | endtry
|
|
|
|
|
try | call mkdir(&directory, "p") | catch /E739/ | endtry
|
|
|
|
|
try | call mkdir(&undodir, "p") | catch /E739/ | endtry
|
2015-03-08 15:59:44 -07:00
|
|
|
|
|
2019-06-05 16:08:55 -07:00
|
|
|
|
" force colors on anything that looks reasonable
|
|
|
|
|
if (&term =~ "^xterm") || (&term == "screen")
|
2013-07-04 01:39:44 -07:00
|
|
|
|
let &t_Co=256
|
2019-06-05 13:07:43 -07:00
|
|
|
|
"let &t_AF="\e[38;5;%dm"
|
|
|
|
|
"let &t_AB="\e[48;5;%dm"
|
2013-07-04 01:39:44 -07:00
|
|
|
|
endif
|
|
|
|
|
|
2021-10-07 12:28:06 -07:00
|
|
|
|
if &term =~ '^tmux'
|
|
|
|
|
" https://unix.stackexchange.com/a/34723
|
|
|
|
|
" tmux will send xterm-style keys when xterm-keys is on
|
|
|
|
|
exec "set <xUp>=\e[1;*A"
|
|
|
|
|
exec "set <xDown>=\e[1;*B"
|
|
|
|
|
exec "set <xRight>=\e[1;*C"
|
|
|
|
|
exec "set <xLeft>=\e[1;*D"
|
|
|
|
|
endif
|
|
|
|
|
|
2015-03-09 12:27:15 -07:00
|
|
|
|
" main config {{{1
|
|
|
|
|
|
2013-07-04 01:39:44 -07:00
|
|
|
|
if has('syntax')
|
|
|
|
|
syntax enable " required for folding as well
|
|
|
|
|
set hlsearch " highlight search results
|
2021-10-19 00:10:51 -07:00
|
|
|
|
let c_syntax_for_h=1 " use C highlighting for .h files
|
2013-07-04 01:39:44 -07:00
|
|
|
|
endif
|
2013-07-03 15:03:54 -07:00
|
|
|
|
|
|
|
|
|
if has('gui_running')
|
2015-03-08 15:59:44 -07:00
|
|
|
|
set guioptions-=M " skip loading $VIMRUNTIME/menu.vim
|
|
|
|
|
set guioptions-=m " hide menu which isn't loaded anyway
|
2013-07-04 01:39:44 -07:00
|
|
|
|
set guioptions-=T " hide toolbar
|
2015-03-08 15:59:44 -07:00
|
|
|
|
set guioptions-=r " hide scrollbar
|
2015-11-24 19:01:34 -08:00
|
|
|
|
if has("gui_gtk2")
|
|
|
|
|
set guifont=Consolas\ 11
|
|
|
|
|
else
|
|
|
|
|
set guifont=Consolas:h9
|
|
|
|
|
end
|
2013-07-04 01:39:44 -07:00
|
|
|
|
set columns=84
|
|
|
|
|
set lines=36
|
|
|
|
|
cd $HOME " might not be ideal...
|
2015-03-08 15:59:44 -07:00
|
|
|
|
endif
|
2013-07-04 01:39:44 -07:00
|
|
|
|
|
2015-03-09 12:27:15 -07:00
|
|
|
|
if has('title') | set title | endif " terminal title
|
2021-09-25 04:19:56 -07:00
|
|
|
|
set history=10000 " command lines to remember
|
2015-03-09 12:27:15 -07:00
|
|
|
|
set number " lines
|
2013-07-04 01:39:44 -07:00
|
|
|
|
set ruler " write out the cursor position
|
2016-01-17 16:04:18 -08:00
|
|
|
|
set showcmd " show number of lines/etc. selected
|
2013-07-04 01:39:44 -07:00
|
|
|
|
set lazyredraw " when executing macros, untyped things
|
2015-03-09 12:27:15 -07:00
|
|
|
|
set shortmess=atI " be less verbose and shut up vim
|
|
|
|
|
set suffixes=.bak,~,.swp,.o,.log,.out " lower tab-completion priority
|
2013-07-04 01:39:44 -07:00
|
|
|
|
set noerrorbells visualbell t_vb= " disable bells
|
2021-10-19 00:10:51 -07:00
|
|
|
|
set scrolloff=3 " rows of context when scrolling
|
|
|
|
|
set sidescrolloff=2 " cols of context when scrolling
|
2013-07-04 01:39:44 -07:00
|
|
|
|
set incsearch " show first search result as we type
|
|
|
|
|
set ignorecase " insensitive searching
|
|
|
|
|
set smartcase " except when uppercase is used
|
|
|
|
|
set infercase " use existing case when ins-completing
|
2021-10-19 00:10:51 -07:00
|
|
|
|
set smarttab " handle insertion and deletion of indents
|
2022-09-06 01:46:56 -07:00
|
|
|
|
set noautoindent " some distros have this set by default
|
2015-04-24 13:04:56 -07:00
|
|
|
|
set virtualedit=block " allow cursor anywhere in visual block
|
2016-01-23 23:00:53 -08:00
|
|
|
|
set foldmethod=marker " (performance issues with other methods)
|
2015-03-13 12:31:16 -07:00
|
|
|
|
set foldlevelstart=99 " start with everything unfolded...?
|
2015-03-09 12:27:15 -07:00
|
|
|
|
set nowrap " word wrapping is pretty weak in vim
|
2019-06-07 01:47:44 -07:00
|
|
|
|
set nojoinspaces " don't use double-spaces for J and gq
|
2021-10-19 00:10:51 -07:00
|
|
|
|
set ffs=unix,dos " prefer unix-style EOLs (ffs indeed)
|
|
|
|
|
set nobomb " don't mention these on planes
|
2015-03-10 15:21:29 -07:00
|
|
|
|
set undofile " remember undos across files/sessions
|
2015-03-09 12:27:15 -07:00
|
|
|
|
set diffopt+=iwhite " ignore whitespace in diff command
|
2021-10-21 07:49:01 -07:00
|
|
|
|
set ttimeout ttimeoutlen=60 " make changing modes a bit snappier
|
2016-07-06 22:33:39 -07:00
|
|
|
|
set hidden " allow swapping out of unsaved buffers
|
2020-11-05 08:11:07 -08:00
|
|
|
|
set complete=.,w,b,u,t " don't scan every file with autocomplete
|
2021-10-21 07:49:01 -07:00
|
|
|
|
set nrformats=bin,hex,unsigned " ctrl+a/x non-negative numbers, no octal
|
2022-06-17 22:30:32 -07:00
|
|
|
|
set modeline modelines=5 " a file can specify its own vim settings
|
2015-03-10 15:21:29 -07:00
|
|
|
|
if has('mksession')
|
2021-10-21 07:49:01 -07:00
|
|
|
|
set sessionoptions=blank,buffers,curdir,folds,tabpages,winsize,resize,winpos
|
2015-03-10 15:21:29 -07:00
|
|
|
|
end
|
2013-07-03 15:03:54 -07:00
|
|
|
|
|
2016-01-23 23:00:53 -08:00
|
|
|
|
if has('wildignore')
|
2021-10-19 00:10:51 -07:00
|
|
|
|
" ignore files that typically aren't interesting to text editors like vim
|
|
|
|
|
" FWIW, these lines don't need trailing commas
|
2016-01-23 23:00:53 -08:00
|
|
|
|
set wildignore=""
|
2022-09-08 00:17:58 -07:00
|
|
|
|
set wildignore+=.git,.hg,.svn,pkg,tmp
|
|
|
|
|
set wildignore+=*.bak,*.cache,*.log,*.tmp
|
|
|
|
|
set wildignore+=*.lnk,.DS_Store,Desktop.ini,Thumbs.db
|
2022-08-29 22:03:42 -07:00
|
|
|
|
set wildignore+=*.7z,*.tar,*.tar.*,*.tgz,*.zip
|
2022-09-08 00:17:58 -07:00
|
|
|
|
set wildignore+=*.pch,*.pdb,*.pgc,*.pgd,*.sln,*.suo
|
|
|
|
|
set wildignore+=*.a,*.dll,*.elf,*.exe,*.lib,*.o,*.obj,*.out,*.so,*.so.*
|
|
|
|
|
set wildignore+=*.m4a,*.mkv,*.mp3,*.mp4,*.ogg,*.opus,*.wav
|
2022-08-04 18:35:30 -07:00
|
|
|
|
set wildignore+=*.bmp,*.gif,*.jfif,*.jpeg,*.jpg,*.pdf,*.png,*.webp
|
2022-09-08 00:17:58 -07:00
|
|
|
|
set wildignore+=*.h5,*.npy,*.npz,*.pkl,*.pyc,*.pyd,*.pyo,__pycache__
|
2016-01-23 23:00:53 -08:00
|
|
|
|
set wildignore+=*.gem,.bundle
|
2019-06-05 21:49:39 -07:00
|
|
|
|
set wildignore+=CMakeCache.txt,CMakeFiles,install_manifest.txt
|
2016-01-23 23:00:53 -08:00
|
|
|
|
endif
|
|
|
|
|
|
2021-08-01 11:29:56 -07:00
|
|
|
|
let $PATH .= ':'.$HOME.'/sh' " allow direct invocation of shell funcs
|
|
|
|
|
|
2021-10-07 12:28:40 -07:00
|
|
|
|
" fun {{{1
|
|
|
|
|
|
2021-10-29 06:07:29 -07:00
|
|
|
|
fu! Colour(name) " go nuts. go wild.
|
|
|
|
|
hi clear | syntax clear | syntax on " reset everything for sure (#4405)
|
|
|
|
|
if has('termguicolors')
|
|
|
|
|
if &term =~ "^tmux-256color"
|
|
|
|
|
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
|
|
|
|
|
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
|
|
|
|
|
set termguicolors
|
|
|
|
|
endif
|
|
|
|
|
endif
|
|
|
|
|
exe "colo " . a:name
|
|
|
|
|
endf
|
|
|
|
|
|
|
|
|
|
command! -nargs=* Colour call Colour(<f-args>)
|
|
|
|
|
|
2021-10-07 12:28:40 -07:00
|
|
|
|
" lifted from BurntSushi:
|
|
|
|
|
fu! GlobalReplace()
|
|
|
|
|
normal! gv"ry
|
|
|
|
|
let replacement = input("Replace " . @r . " with: ")
|
|
|
|
|
if replacement != ""
|
|
|
|
|
exe "%s/" . @r . "/" . replacement . "/g"
|
|
|
|
|
endif
|
|
|
|
|
endf
|
|
|
|
|
|
|
|
|
|
" lifted from BurntSushi:
|
|
|
|
|
fu! StripTrailingWhitespace()
|
|
|
|
|
let l = line(".")
|
|
|
|
|
let c = col(".")
|
|
|
|
|
%s/\s\+$//e
|
|
|
|
|
call cursor(l, c)
|
|
|
|
|
endf
|
2013-07-04 01:39:44 -07:00
|
|
|
|
|
2015-11-19 09:22:23 -08:00
|
|
|
|
fu! TabEight()
|
|
|
|
|
setlocal tabstop=8 shiftwidth=8 noexpandtab softtabstop=0
|
|
|
|
|
endf
|
|
|
|
|
|
2013-07-04 02:07:41 -07:00
|
|
|
|
fu! TabFour()
|
2015-03-09 10:02:16 -07:00
|
|
|
|
setlocal tabstop=8 shiftwidth=4 expandtab softtabstop=4
|
2013-07-04 02:07:41 -07:00
|
|
|
|
endf
|
2013-07-04 01:39:44 -07:00
|
|
|
|
|
2014-03-13 10:15:09 -07:00
|
|
|
|
fu! TabTwo()
|
|
|
|
|
setlocal tabstop=2 shiftwidth=2 expandtab
|
|
|
|
|
endf
|
|
|
|
|
|
2019-06-30 16:42:13 -07:00
|
|
|
|
fu! TabBad()
|
|
|
|
|
setlocal tabstop=4 shiftwidth=4 noexpandtab softtabstop=4
|
|
|
|
|
endf
|
|
|
|
|
|
2015-11-19 09:22:23 -08:00
|
|
|
|
" set TabFour as default
|
|
|
|
|
set tabstop=8 shiftwidth=4 expandtab softtabstop=4
|
|
|
|
|
|
2021-10-07 12:29:19 -07:00
|
|
|
|
fu! DetectShebang()
|
2021-10-19 00:10:51 -07:00
|
|
|
|
" vim has some rudimentary detection, but sometimes i want to override it.
|
|
|
|
|
" vim's version is typically found here: /usr/share/vim/vim82/scripts.vim
|
2021-10-07 12:29:19 -07:00
|
|
|
|
let l = getline(1)
|
2021-10-30 23:34:21 -07:00
|
|
|
|
if l[:1] !=# '#!' | return | endif
|
|
|
|
|
let l = trim(l[2:], ' ', 1) " sometimes there are spaces after the #!
|
|
|
|
|
let p = matchstr(l, '^\%(/usr\)\=/s\=bin/\%(env\%( \+-S\)\= \+\)\=\zs[^ ]*\ze')
|
2021-10-07 12:29:19 -07:00
|
|
|
|
|
|
|
|
|
if p ==# 'bash' | setlocal ft=bash | endif
|
|
|
|
|
if p ==# 'dash' | setlocal ft=bash | endif
|
|
|
|
|
if p ==# 'false' | setlocal ft=bash | endif
|
2022-01-08 21:13:21 -08:00
|
|
|
|
if p ==# 'kuroko' | setlocal ft=python | endif
|
2021-10-07 12:29:19 -07:00
|
|
|
|
if p ==# 'lua' | setlocal ft=lua | endif
|
|
|
|
|
if p ==# 'perl' | setlocal ft=perl | endif
|
|
|
|
|
if p ==# 'perl6' | setlocal ft=raku | endif
|
|
|
|
|
if p ==# 'python' | setlocal ft=python | endif
|
|
|
|
|
if p ==# 'python3' | setlocal ft=python | endif
|
|
|
|
|
if p ==# 'raku' | setlocal ft=raku | endif
|
|
|
|
|
if p ==# 'sh' | setlocal ft=bash | endif
|
|
|
|
|
if p ==# 'zsh' | setlocal ft=zsh | endif
|
|
|
|
|
endf
|
|
|
|
|
|
2021-09-25 04:19:56 -07:00
|
|
|
|
" autocmd {{{1
|
|
|
|
|
|
2013-07-04 01:39:44 -07:00
|
|
|
|
if has('autocmd')
|
2015-11-19 09:22:23 -08:00
|
|
|
|
augroup tabs
|
2013-07-04 01:39:44 -07:00
|
|
|
|
au!
|
2022-01-08 21:13:21 -08:00
|
|
|
|
au BufRead,BufNewFile PKGBUILD call TabTwo()
|
|
|
|
|
au FileType ruby call TabTwo()
|
|
|
|
|
au FileType nim call TabTwo()
|
|
|
|
|
au BufRead,BufNewFile *.bt,*.1sc call TabFour()
|
|
|
|
|
au BufRead,BufNewFile *.ys call TabTwo()
|
|
|
|
|
au FileType javascript,processing call TabTwo()
|
2022-08-29 22:04:08 -07:00
|
|
|
|
au FileType seed7 call TabTwo()
|
2022-01-08 21:13:21 -08:00
|
|
|
|
au BufRead,BufNewFile .gitconfig call TabEight()
|
2022-07-23 10:44:47 -07:00
|
|
|
|
exec 'au' 'BufRead,BufNewFile' $HOME..'/src/bass/*' 'call TabTwo()'
|
|
|
|
|
|
2014-03-13 10:15:09 -07:00
|
|
|
|
augroup END
|
|
|
|
|
|
2021-10-09 09:07:40 -07:00
|
|
|
|
augroup filetypes
|
2015-04-03 01:30:50 -07:00
|
|
|
|
au!
|
2022-05-27 18:14:07 -07:00
|
|
|
|
au BufRead,BufNewFile *.lib setlocal ft=spice
|
|
|
|
|
au BufRead,BufNewFile *.bt setlocal ft=c
|
|
|
|
|
au BufRead,BufNewFile *.1sc setlocal ft=c
|
|
|
|
|
au BufRead,BufNewFile *.fs setlocal ft=c
|
|
|
|
|
au BufRead,BufNewFile *.glsl setlocal ft=c
|
|
|
|
|
au BufRead,BufNewFile *.hlsl setlocal ft=c
|
|
|
|
|
au BufRead,BufNewFile *.krk setlocal ft=python
|
|
|
|
|
au BufRead,BufNewFile *.asm setlocal ft=lips
|
|
|
|
|
au BufRead,BufNewFile *.nim setlocal ft=nim
|
|
|
|
|
au BufRead,BufNewFile *.pde setlocal ft=processing
|
2021-10-19 00:11:13 -07:00
|
|
|
|
au BufRead,BufNewFile,StdinReadPost * call DetectShebang()
|
2015-04-03 01:30:50 -07:00
|
|
|
|
augroup END
|
|
|
|
|
|
2021-08-02 13:43:52 -07:00
|
|
|
|
augroup insanity
|
2021-10-07 12:29:19 -07:00
|
|
|
|
au!
|
2021-10-19 00:10:51 -07:00
|
|
|
|
au FileType netrw setlocal bufhidden=wipe
|
2021-08-02 13:43:52 -07:00
|
|
|
|
augroup END
|
|
|
|
|
|
2016-02-07 06:53:14 -08:00
|
|
|
|
augroup nocomment
|
|
|
|
|
au!
|
2021-10-19 00:10:51 -07:00
|
|
|
|
" set or unset some convenient or annoying formatoptions
|
2022-06-18 01:58:48 -07:00
|
|
|
|
au FileType * setlocal fo-=c fo-=r fo-=o fo-=j
|
2015-03-10 15:21:29 -07:00
|
|
|
|
augroup END
|
|
|
|
|
|
2021-10-07 12:30:00 -07:00
|
|
|
|
augroup forth
|
|
|
|
|
au!
|
|
|
|
|
" insert a newline every 64 bytes when reading
|
|
|
|
|
au! BufReadCmd blkfs,*.scr call setline('1', split(join(readfile(expand('<afile>')), ''), '\%65c\zs'))
|
|
|
|
|
" remove newlines when writing
|
|
|
|
|
au! BufWriteCmd blkfs,*.scr call writefile([join(getline('^', '$'), '')], expand('<afile>'))
|
|
|
|
|
augroup end
|
|
|
|
|
|
2015-03-09 12:27:15 -07:00
|
|
|
|
augroup nobells " good lord vim you are archaic
|
|
|
|
|
au!
|
2015-03-08 15:59:44 -07:00
|
|
|
|
au GUIEnter * set vb t_vb=
|
|
|
|
|
augroup END
|
|
|
|
|
|
2013-07-04 02:07:41 -07:00
|
|
|
|
fu! ResCur() " attempt to preserve cursor position
|
|
|
|
|
if line("'\"") > 1 && line("'\"") <= line("$")
|
|
|
|
|
normal! g`"
|
|
|
|
|
return 1
|
|
|
|
|
endif
|
|
|
|
|
endf
|
|
|
|
|
augroup resCur
|
|
|
|
|
au!
|
2022-01-08 21:13:55 -08:00
|
|
|
|
" au BufWinEnter * call ResCur()
|
2013-07-04 02:07:41 -07:00
|
|
|
|
augroup END
|
2013-07-04 01:39:44 -07:00
|
|
|
|
endif
|
|
|
|
|
|
2015-03-09 12:27:15 -07:00
|
|
|
|
" keys/binds {{{1
|
|
|
|
|
|
2013-07-04 01:39:44 -07:00
|
|
|
|
set backspace=eol,start,indent " make backspace useful
|
|
|
|
|
|
2015-03-09 10:02:16 -07:00
|
|
|
|
" tab completion in command-line
|
|
|
|
|
if has('wildmenu') | set wildmenu | endif
|
2015-03-05 10:10:22 -08:00
|
|
|
|
|
2021-07-21 15:30:05 -07:00
|
|
|
|
" mintty pls
|
|
|
|
|
"exec "set <s-Tab>=\e[Z"
|
|
|
|
|
"map <Esc>[Z <s-tab>
|
|
|
|
|
"ounmap <Esc>[Z
|
|
|
|
|
|
2013-07-04 01:39:44 -07:00
|
|
|
|
" easy indent/unindent
|
|
|
|
|
nn <tab> >>
|
|
|
|
|
nn <s-tab> <<
|
|
|
|
|
" indentation without ending selection
|
|
|
|
|
vn <silent> <tab> >gv
|
|
|
|
|
vn <silent> <s-tab> <gv
|
2013-07-03 15:03:54 -07:00
|
|
|
|
|
2016-01-08 09:12:49 -08:00
|
|
|
|
fu! Inn(q)
|
2015-03-09 12:27:15 -07:00
|
|
|
|
" bind both normal and insert modes
|
2015-03-09 10:02:16 -07:00
|
|
|
|
let args=split(a:q, '^\s*\(<[^>]\+>\s\+\)\+\zs')
|
|
|
|
|
exec 'nn '.args[0].' '.args[1]
|
|
|
|
|
exec 'ino '.args[0].' <c-o>'.args[1]
|
|
|
|
|
endf
|
|
|
|
|
com! -nargs=+ Inn call Inn(<q-args>)
|
|
|
|
|
|
|
|
|
|
Inn <F5> :w<cr>
|
2021-08-02 13:43:52 -07:00
|
|
|
|
Inn <F6> :Next<cr>
|
|
|
|
|
Inn <F7> :next<cr>
|
2022-03-05 17:39:11 -08:00
|
|
|
|
Inn <F8> :e %<cr>
|
2021-08-02 13:43:52 -07:00
|
|
|
|
Inn <F9> @@
|
2015-03-09 10:02:16 -07:00
|
|
|
|
Inn <F10> :bd<cr>
|
|
|
|
|
Inn <c-F5> :w!<cr>
|
2022-03-05 17:39:11 -08:00
|
|
|
|
Inn <c-F8> :e! %<cr>
|
2015-03-09 10:02:16 -07:00
|
|
|
|
Inn <c-F10> :bd!<cr>
|
|
|
|
|
Inn <s-F5> :wall<cr>
|
2015-03-05 10:10:22 -08:00
|
|
|
|
|
2015-03-09 12:27:15 -07:00
|
|
|
|
" np++ habits
|
2015-03-09 10:02:16 -07:00
|
|
|
|
Inn <c-up> <c-y>
|
|
|
|
|
Inn <c-down> <c-e>
|
|
|
|
|
Inn <silent> <c-s-up> :m-2<cr>
|
|
|
|
|
Inn <silent> <c-s-down> :m+1<cr>
|
2015-03-10 14:42:26 -07:00
|
|
|
|
Inn <silent> <c-s-PageUp> :tabm -1<cr>
|
|
|
|
|
Inn <silent> <c-s-PageDown> :tabm +1<cr>
|
2015-03-09 10:02:16 -07:00
|
|
|
|
|
2019-06-05 19:09:14 -07:00
|
|
|
|
" jump to top and bottom
|
|
|
|
|
Inn <c-Home> gg
|
|
|
|
|
Inn <c-End> G
|
|
|
|
|
nn <Esc>[1;5H gg
|
|
|
|
|
nn <Esc>[1;5F G
|
|
|
|
|
ino <Esc>[1;5H <c-o>gg
|
|
|
|
|
ino <Esc>[1;5F <c-o>G
|
|
|
|
|
|
2015-03-09 10:02:16 -07:00
|
|
|
|
" hide search highlighting
|
|
|
|
|
Inn <silent> <c-]> :nohls<enter>
|
2013-07-04 01:39:44 -07:00
|
|
|
|
|
2022-09-08 00:08:25 -07:00
|
|
|
|
" rebind annoying things:
|
2015-03-05 10:10:22 -08:00
|
|
|
|
" reflow text
|
2013-07-04 01:39:44 -07:00
|
|
|
|
nn Q gq
|
2015-03-24 19:54:57 -07:00
|
|
|
|
vn Q gq
|
2015-03-05 10:10:22 -08:00
|
|
|
|
" split lines (opposite of J)
|
|
|
|
|
nn K i<cr><esc>k$
|
2015-03-05 11:57:16 -08:00
|
|
|
|
vn K <nop>
|
2015-03-05 12:40:32 -08:00
|
|
|
|
" follow tag
|
|
|
|
|
nn <bar> <c-]>
|
2015-03-06 07:14:33 -08:00
|
|
|
|
" delete line
|
2015-03-24 19:54:57 -07:00
|
|
|
|
"nn D dd
|
2015-03-06 07:14:33 -08:00
|
|
|
|
|
2021-10-21 07:49:01 -07:00
|
|
|
|
" execute vim commands in visual selection
|
2018-03-21 04:04:43 -07:00
|
|
|
|
vmap <space> "xy:@x<cr>
|
2016-09-02 19:59:27 -07:00
|
|
|
|
|
2021-10-18 21:46:25 -07:00
|
|
|
|
" open a shell (only works if you `exec vim` instead of running it in a shell)
|
2021-10-07 12:30:41 -07:00
|
|
|
|
nn <C-z> :sh<cr>
|
|
|
|
|
|
2022-09-08 00:08:25 -07:00
|
|
|
|
" this frees up x and X for rebinding if you like
|
2019-06-08 09:52:31 -07:00
|
|
|
|
exec "set <s-Del>=\<Esc>[3;2~"
|
2015-03-09 12:27:15 -07:00
|
|
|
|
Inn <s-Del> X
|
2015-03-06 07:14:33 -08:00
|
|
|
|
|
2015-03-13 12:31:16 -07:00
|
|
|
|
let leader="\\"
|
2015-03-09 12:27:15 -07:00
|
|
|
|
"ino <c-\> <C-o><Leader> " this doesn't workkkkkkkkk
|
2022-09-08 00:18:10 -07:00
|
|
|
|
nn <Leader>2 :call TabTwo()<cr>
|
|
|
|
|
nn <Leader>3 :call TabBad()<cr>
|
|
|
|
|
nn <Leader>4 :call TabFour()<cr>
|
|
|
|
|
nn <Leader>5 :call TabEight()<cr>
|
2015-04-04 00:14:55 -07:00
|
|
|
|
nm <Leader>a a?<Esc>r
|
2021-10-07 12:30:41 -07:00
|
|
|
|
nm <Leader>i i?<Esc>r
|
|
|
|
|
nn <Leader>, :Tab /,\zs<cr>
|
2015-03-07 07:57:26 -08:00
|
|
|
|
nn <Leader>. @:
|
2021-10-07 12:30:41 -07:00
|
|
|
|
nn <Leader><Leader> :<cr>
|
|
|
|
|
nn <Leader><space> :call StripTrailingWhitespace()<cr>
|
2015-03-10 14:42:26 -07:00
|
|
|
|
"nn <Leader>? :exec getline(".")
|
2021-10-07 12:30:41 -07:00
|
|
|
|
nn <Leader>F :E .<cr>
|
|
|
|
|
nn <Leader>P "0P
|
|
|
|
|
nn <Leader>b :ls<cr>:b<space>
|
|
|
|
|
nn <Leader>e :e **/*
|
|
|
|
|
nn <Leader>f :E<cr>
|
|
|
|
|
nn <Leader>p "0p
|
2015-03-09 12:27:15 -07:00
|
|
|
|
"nn <Leader>x :system('chmod +x %') | e
|
2021-10-07 12:30:41 -07:00
|
|
|
|
nn <silent> <Leader>d :cd %:p:h<cr>:pwd<cr>
|
|
|
|
|
|
|
|
|
|
vn <silent> & :call GlobalReplace()<cr>
|
2015-03-24 19:54:57 -07:00
|
|
|
|
|
2021-10-14 14:09:34 -07:00
|
|
|
|
" TODO:
|
|
|
|
|
"nn ,, :call CommentLines()<cr>
|
|
|
|
|
"nn ,. :call UncommentLines()<cr>
|
|
|
|
|
|
2019-06-05 19:09:25 -07:00
|
|
|
|
" alias :W to :w, via https://stackoverflow.com/a/3879737
|
|
|
|
|
cnoreabbrev <expr> W ((getcmdtype() is# ':' && getcmdline() is# 'W')?('w'):('W'))
|
|
|
|
|
|
2022-07-23 10:47:43 -07:00
|
|
|
|
" https://stackoverflow.com/a/58244921
|
|
|
|
|
fu! SynStack()
|
|
|
|
|
for i1 in synstack(line("."), col("."))
|
|
|
|
|
let i2 = synIDtrans(i1)
|
|
|
|
|
let n1 = synIDattr(i1, "name")
|
|
|
|
|
let n2 = synIDattr(i2, "name")
|
|
|
|
|
echo n1 "->" n2
|
|
|
|
|
endfor
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
map gm :call SynStack()<CR>
|
|
|
|
|
|
2015-03-09 12:27:15 -07:00
|
|
|
|
" misc {{{1
|
2013-07-04 01:39:44 -07:00
|
|
|
|
|
2015-03-10 14:42:26 -07:00
|
|
|
|
set list listchars=tab:»·,trail:·,extends:…,nbsp:‗
|
|
|
|
|
" including this in case i'm on a _really_ bad terminal:
|
|
|
|
|
"set list listchars=tab:>-,trail:.,extends:>,nbsp:_
|
2015-03-05 10:10:22 -08:00
|
|
|
|
|
2022-09-08 00:08:25 -07:00
|
|
|
|
" deprecated, but still perfectly functional, and especially backwards compatible:
|
2021-10-19 02:56:42 -07:00
|
|
|
|
try | exec pathogen#infect() | catch /E117/ | endtry
|
2015-03-30 21:42:01 -07:00
|
|
|
|
|
2022-09-08 00:08:25 -07:00
|
|
|
|
let g:netrw_banner=0 " be quiet
|
2021-10-19 02:56:42 -07:00
|
|
|
|
let g:netrw_fastbrowse = 0 " so THAT'S what's been causing me agony
|
2018-03-21 04:04:43 -07:00
|
|
|
|
|
2015-03-30 21:42:01 -07:00
|
|
|
|
set background=dark
|
2021-10-21 07:49:01 -07:00
|
|
|
|
try | colorscheme minimalist | catch /E185/ | colorscheme desert | endtry
|
2021-08-02 13:43:52 -07:00
|
|
|
|
|
2017-01-23 11:56:26 -08:00
|
|
|
|
" ctrlp {{{1
|
2016-09-19 12:52:05 -07:00
|
|
|
|
|
2019-06-06 01:19:35 -07:00
|
|
|
|
map <silent> <c-n> :CtrlPBuffer<cr>
|
2018-04-12 13:12:19 -07:00
|
|
|
|
let g:ctrlp_match_window='bottom,order:btt,min:1,max:24,results:24'
|
2016-09-19 12:52:05 -07:00
|
|
|
|
|
2016-05-26 23:42:14 -07:00
|
|
|
|
" machine-specific configs {{{1
|
|
|
|
|
|
2018-04-12 13:12:19 -07:00
|
|
|
|
let s:hostname=hostname()
|
2016-06-27 04:33:41 -07:00
|
|
|
|
if s:hostname == "phantom-pi" || s:hostname == "wraith"
|
2021-10-21 07:49:01 -07:00
|
|
|
|
colorscheme minimalist
|
2016-05-26 23:42:14 -07:00
|
|
|
|
endif
|
2022-09-08 00:15:16 -07:00
|
|
|
|
|
|
|
|
|
" macros {{{1
|
|
|
|
|
|
|
|
|
|
" to dump a macro, enter insert mode and hit [Ctrl+R] [Ctrl+R] [macro letter].
|
|
|
|
|
" note that this will not properly escape any single quotes used in the macro.
|
|
|
|
|
let s:q="'"
|
|
|
|
|
|
|
|
|
|
" explode: split an expression's right-hand-side by commas
|
|
|
|
|
let @s= 'ma'
|
|
|
|
|
let @s.=':sil s/ *= */&\r/e
'
|
|
|
|
|
let @s.='-'
|
|
|
|
|
let @s.='mb' " the next line may error, so set a mark now
|
|
|
|
|
let @s.=':sil s/,/\r/g
'
|
|
|
|
|
let @s.='-'
|
|
|
|
|
let @s.='mb'
|
|
|
|
|
"let @s.=s:q..'a'
|
|
|
|
|
"let @s.='OEXPLODE=HERE;'
|
|
|
|
|
"let @s.=s:q..'b'
|
|
|
|
|
"let @s.='oEXPLODE=THERE;'
|
|
|
|
|
let @s.=s:q..'a'
|
|
|
|
|
let @s.='
'
|
|
|
|
|
|
|
|
|
|
" implode: join the previously split expression, sort -ui
|
|
|
|
|
let @j= ':sil '..s:q..'a+1,'..s:q..'b'..'sor ui
'
|
|
|
|
|
let @j.=':sil '..s:q..'a+1,'..s:q..'b-1'..'norm!A,
'
|
|
|
|
|
let @j.=':sil '..s:q..'a,'..s:q..'b'..'j!
'
|
|
|
|
|
let @j.=s:q..'a'
|