blob: 35353a845d88fd423de9df63aa953fc5a4f72882 [file] [log] [blame]
Skyler Greya7feb6e2022-08-26 06:51:55 +01001set whichwrap=b,s,<,>,[,]
Skyler Grey8fd63d02022-10-31 00:26:44 +00002set mouse=
Skyler Greye9e45852022-10-31 00:16:58 +00003
Skyler Grey8fd63d02022-10-31 00:26:44 +00004vmap <C-k> :m-2<CR>
5vmap <C-j> :m+1<CR>
6nmap <C-k> :m-2<CR>
Skyler Greye9e45852022-10-31 00:16:58 +00007nmap <C-j> :m+1<CR>
Skyler Greya7feb6e2022-08-26 06:51:55 +01008
Skyler Grey0c024ef2022-10-31 00:17:14 +00009vmap <F12> <Esc>
10imap <F12> <Esc>
11nmap <F12> <Esc>
12tmap <F12> <C-C>
13cmap <F12> <Esc>
14omap <F12> <Esc>
15smap <F12> <Esc>
Skyler Greyf8194602022-10-31 00:07:05 +000016
Skyler Greya7feb6e2022-08-26 06:51:55 +010017vnoremap // y/\V<C-R>=escape(@",'/\')<CR><CR>
18
19fun! SetupCommandAlias(from, to)
20 exec 'cnoreabbrev <expr> '.a:from
21 \ .' ((getcmdtype() is# ":" && getcmdline() is# "'.a:from.'")'
22 \ .'? ("'.a:to.'") : ("'.a:from.'"))'
23endfun
24
Skyler Grey3c6b6d62022-09-04 21:53:42 +010025augroup vimrc-auto-mkdir
26 autocmd!
27 autocmd BufWritePre * call s:auto_mkdir(expand('<afile>:p:h'), v:cmdbang)
28 function! s:auto_mkdir(dir, force)
Skyler Grey8fd63d02022-10-31 00:26:44 +000029 if !isdirectory(a:dir) && !(a:dir =~ "^suda:///.*$")
Skyler Grey3c6b6d62022-09-04 21:53:42 +010030 \ && (a:force
Skyler Grey8fd63d02022-10-31 00:26:44 +000031 \ || input("'" . a:dir . "' does not exist. Create? [y/N]: ") =~? '^y\%[es]$')
Skyler Grey3c6b6d62022-09-04 21:53:42 +010032 call mkdir(iconv(a:dir, &encoding, &termencoding), 'p')
33 endif
34 endfunction
35augroup END
36" https://stackoverflow.com/a/42872275/12293760
37
Skyler Greyee47c9f2022-09-05 07:01:33 +010038augroup vimrc-auto-neoformat
39 autocmd!
40 autocmd BufWritePre * call s:auto_neoformat(v:cmdbang)
41 function! s:auto_neoformat(force)
42 if a:force
43 Neoformat
44 endif
45 endfunction
46augroup END
47
Skyler Greya7feb6e2022-08-26 06:51:55 +010048command W w
49command Wq wq
50call SetupCommandAlias("git","Git")
Skyler Grey55f84552022-09-05 11:04:39 +010051call SetupCommandAlias("rg","Rg")
Skyler Greya7feb6e2022-08-26 06:51:55 +010052
53set ignorecase
54set smartcase
55
56set expandtab
Skyler Greyee47c9f2022-09-05 07:01:33 +010057
58let g:cursorhold_updatetime = 1000
59autocmd CursorHoldI,CursorHold,BufLeave ?* silent! update
Skyler Grey55f84552022-09-05 11:04:39 +010060
61set viewoptions-=options
62autocmd BufWinLeave ?* silent! mkview!
63
Skyler Greyf8194602022-10-31 00:07:05 +000064set nofoldenable
65autocmd BufWinEnter ?* silent! loadview
Skyler Greye42f4352022-10-30 23:09:36 +000066
67tnoremap <Esc><Esc> <C-\><C-n>
Skyler Grey8fd63d02022-10-31 00:26:44 +000068
69let g:camelcasemotion_key = '<leader>m'