-
Notifications
You must be signed in to change notification settings - Fork 0
/
keys.vim
82 lines (64 loc) · 1.64 KB
/
keys.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
let mapleader=" "
" Alternate way to save
nnoremap <leader>w :up<CR>
" make some backward-jumping operators inclusive (include character under cursor)
onoremap F vF
onoremap T vT
onoremap b vb
onoremap B vB
onoremap ^ v^
onoremap 0 v0
" Parens auto-close
inoremap ( ()<Left>
inoremap { {}<Left>
inoremap [ []<Left>
inoremap " ""<Left>
inoremap ` ``<Left>
" kill buffer
function! Qkey_func()
if len(getbufinfo({'buflisted':1})) == 1
quit!
else
bdelete!
endif
endfunction
nnoremap <leader>q :call Qkey_func()<CR>
" kill all buffers
nnoremap <leader>Q :qa!<CR>
" quickly switch/delete/... buffers
noremap <c-b> :buffers<CR>:b
" format
nnoremap Q gqq
vnoremap Q gq
" Better tabbing
vnoremap < <gv
vnoremap > >gv
" vertical split shortcut
nnoremap <C-w>v :vsplit<CR>
" copy to system clipboard
noremap Y "+y
nnoremap YY "+yy
" netrw (file explorer)
nnoremap <leader>n :Explore<CR>
" switch to next buffer
nnoremap <C-n> :bn<CR>
nnoremap <C-p> :bp<CR>
" unfuck python commenting
au FileType python nnoremap gco o#<space>
au FileType python nnoremap gcO O#<space>
" paste over a selection without changing contents of the unnamed register
vnoremap <leader>p "_dP
" Save file as sudo on files that require root permission
cnoremap w!! execute 'silent! write !sudo tee % >/dev/null' <bar> edit!
" easily generate sha256 hashes of random stuff
function! Hash()
let @h = system("dd if=/dev/random bs=512 count=1 2>/dev/null | sha256sum | cut -d' ' -f1")
let @h = substitute(strtrans(@h), '\^@', '', 'g')
norm "hp
endfunction
nnoremap <leader>h :call Hash()<CR>
" tabular plugin shortcut
nnoremap <c-t> :Tab /
vnoremap <c-t> :Tab /
nnoremap / /\v
vnoremap / /\v