Skyler Grey | a7feb6e | 2022-08-26 06:51:55 +0100 | [diff] [blame] | 1 | set whichwrap=b,s,<,>,[,] |
Skyler Grey | e9e4585 | 2022-10-31 00:16:58 +0000 | [diff] [blame^] | 2 | " set mouse=a |
| 3 | |
| 4 | nmap <C-k> :m-2<CR> |
| 5 | nmap <C-j> :m+1<CR> |
Skyler Grey | a7feb6e | 2022-08-26 06:51:55 +0100 | [diff] [blame] | 6 | |
Skyler Grey | f819460 | 2022-10-31 00:07:05 +0000 | [diff] [blame] | 7 | vnoremap <F12> <Esc> |
| 8 | inoremap <F12> <Esc> |
| 9 | nnoremap <F12> <Esc> |
| 10 | tnoremap <F12> <C-C> |
| 11 | cnoremap <F12> <Esc> |
| 12 | onoremap <F12> <Esc> |
| 13 | snoremap <F12> <Esc> |
| 14 | |
Skyler Grey | a7feb6e | 2022-08-26 06:51:55 +0100 | [diff] [blame] | 15 | vnoremap // y/\V<C-R>=escape(@",'/\')<CR><CR> |
| 16 | |
| 17 | fun! SetupCommandAlias(from, to) |
| 18 | exec 'cnoreabbrev <expr> '.a:from |
| 19 | \ .' ((getcmdtype() is# ":" && getcmdline() is# "'.a:from.'")' |
| 20 | \ .'? ("'.a:to.'") : ("'.a:from.'"))' |
| 21 | endfun |
| 22 | |
Skyler Grey | 3c6b6d6 | 2022-09-04 21:53:42 +0100 | [diff] [blame] | 23 | augroup vimrc-auto-mkdir |
| 24 | autocmd! |
| 25 | autocmd BufWritePre * call s:auto_mkdir(expand('<afile>:p:h'), v:cmdbang) |
| 26 | function! s:auto_mkdir(dir, force) |
| 27 | if !isdirectory(a:dir) |
| 28 | \ && (a:force |
| 29 | \ || input("'" . a:dir . "' does not exist. Create? [y/N]") =~? '^y\%[es]$') |
| 30 | call mkdir(iconv(a:dir, &encoding, &termencoding), 'p') |
| 31 | endif |
| 32 | endfunction |
| 33 | augroup END |
| 34 | " https://stackoverflow.com/a/42872275/12293760 |
| 35 | |
Skyler Grey | ee47c9f | 2022-09-05 07:01:33 +0100 | [diff] [blame] | 36 | augroup vimrc-auto-neoformat |
| 37 | autocmd! |
| 38 | autocmd BufWritePre * call s:auto_neoformat(v:cmdbang) |
| 39 | function! s:auto_neoformat(force) |
| 40 | if a:force |
| 41 | Neoformat |
| 42 | endif |
| 43 | endfunction |
| 44 | augroup END |
| 45 | |
Skyler Grey | a7feb6e | 2022-08-26 06:51:55 +0100 | [diff] [blame] | 46 | command W w |
| 47 | command Wq wq |
| 48 | call SetupCommandAlias("git","Git") |
Skyler Grey | 55f8455 | 2022-09-05 11:04:39 +0100 | [diff] [blame] | 49 | call SetupCommandAlias("rg","Rg") |
Skyler Grey | a7feb6e | 2022-08-26 06:51:55 +0100 | [diff] [blame] | 50 | |
| 51 | set ignorecase |
| 52 | set smartcase |
| 53 | |
| 54 | set expandtab |
Skyler Grey | ee47c9f | 2022-09-05 07:01:33 +0100 | [diff] [blame] | 55 | |
| 56 | let g:cursorhold_updatetime = 1000 |
| 57 | autocmd CursorHoldI,CursorHold,BufLeave ?* silent! update |
Skyler Grey | 55f8455 | 2022-09-05 11:04:39 +0100 | [diff] [blame] | 58 | |
| 59 | set viewoptions-=options |
| 60 | autocmd BufWinLeave ?* silent! mkview! |
| 61 | |
Skyler Grey | f819460 | 2022-10-31 00:07:05 +0000 | [diff] [blame] | 62 | set nofoldenable |
| 63 | autocmd BufWinEnter ?* silent! loadview |
Skyler Grey | e42f435 | 2022-10-30 23:09:36 +0000 | [diff] [blame] | 64 | |
| 65 | tnoremap <Esc><Esc> <C-\><C-n> |