Skyler Grey | a7feb6e | 2022-08-26 06:51:55 +0100 | [diff] [blame] | 1 | set whichwrap=b,s,<,>,[,] |
Skyler Grey | 8fd63d0 | 2022-10-31 00:26:44 +0000 | [diff] [blame] | 2 | set mouse= |
Skyler Grey | e9e4585 | 2022-10-31 00:16:58 +0000 | [diff] [blame] | 3 | |
Skyler Grey | bca7996 | 2022-11-02 08:50:13 +0000 | [diff] [blame] | 4 | vnoremap <silent> <C-k> :m-2<CR>gv |
| 5 | vnoremap <silent><expr> <C-j> ":m+" . (line("'>") - line("'<") + 1) . "\<CR>gv" |
| 6 | nnoremap <silent> <C-k> :m-2<CR> |
| 7 | nnoremap <silent> <C-j> :m+1<CR> |
Skyler Grey | a7feb6e | 2022-08-26 06:51:55 +0100 | [diff] [blame] | 8 | |
Skyler Grey | 7faf5cb | 2023-02-21 10:27:05 +0000 | [diff] [blame] | 9 | nnoremap <C-d> <C-d>zz |
| 10 | nnoremap <C-b> <C-b>zz |
| 11 | |
| 12 | nnoremap <C-u> <C-u>zz |
| 13 | nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>zz:redraw!<CR>" |
| 14 | |
| 15 | nnoremap N Nzz |
| 16 | nnoremap n nzz |
| 17 | |
Skyler Grey | 0c024ef | 2022-10-31 00:17:14 +0000 | [diff] [blame] | 18 | vmap <F12> <Esc> |
| 19 | imap <F12> <Esc> |
| 20 | nmap <F12> <Esc> |
| 21 | tmap <F12> <C-C> |
| 22 | cmap <F12> <Esc> |
| 23 | omap <F12> <Esc> |
| 24 | smap <F12> <Esc> |
Skyler Grey | f819460 | 2022-10-31 00:07:05 +0000 | [diff] [blame] | 25 | |
Skyler Grey | a7feb6e | 2022-08-26 06:51:55 +0100 | [diff] [blame] | 26 | vnoremap // y/\V<C-R>=escape(@",'/\')<CR><CR> |
| 27 | |
Skyler Grey | 3c6b6d6 | 2022-09-04 21:53:42 +0100 | [diff] [blame] | 28 | augroup vimrc-auto-mkdir |
| 29 | autocmd! |
| 30 | autocmd BufWritePre * call s:auto_mkdir(expand('<afile>:p:h'), v:cmdbang) |
| 31 | function! s:auto_mkdir(dir, force) |
Skyler Grey | 8fd63d0 | 2022-10-31 00:26:44 +0000 | [diff] [blame] | 32 | if !isdirectory(a:dir) && !(a:dir =~ "^suda:///.*$") |
Skyler Grey | 3c6b6d6 | 2022-09-04 21:53:42 +0100 | [diff] [blame] | 33 | \ && (a:force |
Skyler Grey | 8fd63d0 | 2022-10-31 00:26:44 +0000 | [diff] [blame] | 34 | \ || input("'" . a:dir . "' does not exist. Create? [y/N]: ") =~? '^y\%[es]$') |
Skyler Grey | 3c6b6d6 | 2022-09-04 21:53:42 +0100 | [diff] [blame] | 35 | call mkdir(iconv(a:dir, &encoding, &termencoding), 'p') |
| 36 | endif |
| 37 | endfunction |
| 38 | augroup END |
| 39 | " https://stackoverflow.com/a/42872275/12293760 |
| 40 | |
Skyler Grey | ee47c9f | 2022-09-05 07:01:33 +0100 | [diff] [blame] | 41 | augroup vimrc-auto-neoformat |
| 42 | autocmd! |
| 43 | autocmd BufWritePre * call s:auto_neoformat(v:cmdbang) |
| 44 | function! s:auto_neoformat(force) |
| 45 | if a:force |
| 46 | Neoformat |
| 47 | endif |
| 48 | endfunction |
| 49 | augroup END |
| 50 | |
Skyler Grey | 091a22c | 2022-11-05 10:10:38 +0000 | [diff] [blame] | 51 | command! W w |
| 52 | command! Wq wq |
| 53 | call g:SetupCommandAlias("rg","Rg") |
Skyler Grey | a7feb6e | 2022-08-26 06:51:55 +0100 | [diff] [blame] | 54 | |
| 55 | set ignorecase |
| 56 | set smartcase |
| 57 | |
| 58 | set expandtab |
Skyler Grey | ee47c9f | 2022-09-05 07:01:33 +0100 | [diff] [blame] | 59 | |
| 60 | let g:cursorhold_updatetime = 1000 |
| 61 | autocmd CursorHoldI,CursorHold,BufLeave ?* silent! update |
Skyler Grey | 55f8455 | 2022-09-05 11:04:39 +0100 | [diff] [blame] | 62 | |
| 63 | set viewoptions-=options |
| 64 | autocmd BufWinLeave ?* silent! mkview! |
| 65 | |
Skyler Grey | f819460 | 2022-10-31 00:07:05 +0000 | [diff] [blame] | 66 | set nofoldenable |
| 67 | autocmd BufWinEnter ?* silent! loadview |
Skyler Grey | e42f435 | 2022-10-30 23:09:36 +0000 | [diff] [blame] | 68 | |
| 69 | tnoremap <Esc><Esc> <C-\><C-n> |
Skyler Grey | 8fd63d0 | 2022-10-31 00:26:44 +0000 | [diff] [blame] | 70 | |
| 71 | let g:camelcasemotion_key = '<leader>m' |
Skyler Grey | bca7996 | 2022-11-02 08:50:13 +0000 | [diff] [blame] | 72 | |
Skyler Grey | bca7996 | 2022-11-02 08:50:13 +0000 | [diff] [blame] | 73 | nnoremap <nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>" |
| 74 | nnoremap <silent> <C-d> <C-d>:redraw!<CR> |
Skyler Grey | 9febe7b | 2023-01-25 21:31:33 +0000 | [diff] [blame] | 75 | |
| 76 | function! s:start_delete(key) |
| 77 | let l:result = a:key |
| 78 | if !s:deleting |
| 79 | let l:result = "\<C-G>u".l:result |
| 80 | endif |
| 81 | let s:deleting = 1 |
| 82 | return l:result |
| 83 | endfunction |
| 84 | |
| 85 | function! s:check_undo_break(char) |
| 86 | if s:deleting |
| 87 | let s:deleting = 0 |
| 88 | call feedkeys("\<BS>\<C-G>u".a:char, 'n') |
| 89 | endif |
| 90 | endfunction |
| 91 | |
| 92 | augroup smartundo |
| 93 | autocmd! |
| 94 | autocmd InsertEnter * let s:deleting = 0 |
| 95 | autocmd InsertCharPre * call s:check_undo_break(v:char) |
| 96 | augroup END |
| 97 | |
| 98 | inoremap <expr> <BS> <SID>start_delete("\<BS>") |
| 99 | inoremap <expr> <C-W> <SID>start_delete("\<C-W>") |
| 100 | inoremap <expr> <C-U> <SID>start_delete("\<C-U>") |
| 101 | |
| 102 | " Undo stuff from https://vi.stackexchange.com/a/2377/38793 |