-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkeybinds.vim
More file actions
102 lines (79 loc) · 2.58 KB
/
keybinds.vim
File metadata and controls
102 lines (79 loc) · 2.58 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
" Normal mode {{{1
" View word count
nnoremap <leader>wc g<C-g>
" Toggle syntax highlighting {{{
function! s:ToggleSyntax()
if exists("g:syntax_on")
syntax off
else
syntax enable
endif
endfunction
nnoremap <silent> <leader>sy :call <sid>ToggleSyntax()<CR>
"}}}
" Quickly edit/source .vimrc file, keybinds, and abbrevs file
nnoremap <leader>evf :15split $MYVIMRC<CR>
nnoremap <leader>svf :source $MYVIMRC<CR>
nnoremap <leader>eaf :15split ~/.vim/abbrevs.vim<cr>
nnoremap <leader>saf :source ~/.vim/abbrevs.vim<cr>
nnoremap <leader>ekf :15split ~/.vim/keybinds.vim<cr>
nnoremap <leader>skf :source ~/.vim/keybinds.vim<cr>
" Quickly turn off search highlighting
nnoremap <space> :nohl<cr>
" Quickly reindent file
nnoremap <leader>i mzgg=G`z
" Quick switch buffer
nnoremap gb :ls<CR>:buf<Space>
" Copy text left of cursor and start new line
nnoremap <leader>o v^yo<C-r>"
" Copy current buffer to clipboard and exit vim
" Insert mode {{{1
" Jump back and fix most recent error
inoremap <C-s> <esc>[sz=
" Make getting into normal mode easier
inoremap jk <esc>
" Make c-return start a new line in insert mode
inoremap <C-Return> <esc>o
" Make c-backspace delete a word
inoremap <C-BS> <esc>bcw
" Visual mode {{{1
" Sort selected text
vnoremap s :sort<cr>
" Move highlighted text up and down in visual mode
vnoremap <Down> :m '>+1<CR>gv=gv
vnoremap <Up> :m '<-2<CR>gv=gv
" Change function of arrow keys {{{1
inoremap <Left> <nop>
inoremap <Right> <nop>
" Bind up to enter ONE normal mode command, ie <c-o>
inoremap <Up> <C-o>
" Bind down to insert an expression into the text, ie <C-r>=
inoremap <Down> <C-r>=
" Left and right switch tab
nnoremap <Left> :tabprevious<cr>
nnoremap <Right> :tabn<cr>
" Increase and decrease numbers easily
nnoremap <Up> <C-a>
nnoremap <Down> <C-x>
" Misc binds {{{1
nnoremap s <C-w>
nnoremap Y y$
nnoremap / /\v
nnoremap ? ?\v
onoremap / /\v
onoremap ? ?\v
" Disables Ex mode
nnoremap Q <nop>
" Rebind uppercase versions of h,l to do 'extreme' movements
nnoremap H ^
nnoremap L $
" Sudo save
cnoremap w!! w !sudo tee %
" More text objects, creates operator bindings for all the listed chars below, allowing operations between them. {{{
for char in [ '_', '-', '.', ':', ',', ';', '<bar>', '/', '<bslash>', '*', '+', '%', '`' ]
:silent! execute 'xnoremap i' . char . ' :<C-u>normal! T' . char . 'vt' . char . '<CR>'
:silent! execute 'onoremap i' . char . ' :normal vi' . char . '<CR>'
:silent! execute 'xnoremap a' . char . ' :<C-u>normal! F' . char . 'vf' . char . '<CR>'
:silent! execute 'onoremap a' . char . ' :normal va' . char . '<CR>'
endfor
" }}}