-
Notifications
You must be signed in to change notification settings - Fork 1
/
mappings.vim
122 lines (94 loc) · 2.89 KB
/
mappings.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
" ----------------------------------------
" Mappings
" ----------------------------------------
" Set leader to ,
" Note: This line MUST come before any <leader> mappings
let mapleader=","
let maplocalleader = "\\"
" ---------------
" Regular Mappings
" ---------------
" Select entire buffer
nnoremap vy ggVG
" Make Y behave like other capital commands.
nnoremap Y y$
" Just to beginning and end of lines easier. From http://vimbits.com/bits/16
noremap H ^
noremap L $
" remap U to <C-r> for easier redo
nnoremap U <C-r>
" ---------------
" Window Movement
" ---------------
nnoremap <silent> gh :wincmd h<CR>
nnoremap <silent> gj :wincmd j<CR>
nnoremap <silent> gk :wincmd k<CR>
nnoremap <silent> gl :wincmd l<CR>
" 4 Window Splits
" -----------------
" g1 | g2 | g3 | g4
" -----------------
nnoremap <silent> g1 :wincmd t<CR>
nnoremap <silent> g2 :wincmd t<bar>:wincmd l<CR>
nnoremap <silent> g3 :wincmd t<bar>:wincmd l<bar>:wincmd l<CR>
nnoremap <silent> g4 :wincmd b<CR>
" Previous Window
nnoremap <silent> gp :wincmd p<CR>
" Equal Size Windows
nnoremap <silent> g= :wincmd =<CR>
" Swap Windows
nnoremap <silent> gx :wincmd x<CR>
" Buffer
nnoremap <silent> <F4> :bdelete<CR>
nnoremap <silent> <F3> :bnext<CR>
nnoremap <silent> <F2> :bprev<CR>
" ---------------
" Modifer Mappings
" ---------------
" Make line completion easier.
inoremap <C-l> <C-x><C-l>
" Easier Scrolling (think j/k with left hand)
" All variations are mapped for now until I get used to one
" C/M/D + d (page up)
" C/M/D + f (page down)
nnoremap <C-j> 15gjzz
nnoremap <C-k> 15gkzz
vnoremap <C-j> 15gjzz
vnoremap <C-k> 15gkzz
" ---------------
" Leader Mappings
" ---------------
" Clear search
noremap <silent><leader>/ :nohls<CR>
" Highlight search word under cursor without jumping to next
nnoremap <leader>h *<C-O>
" Toggle spelling mode with ,s
nnoremap <silent> <leader>s :set spell!<CR>
" Underline the current line with '-'
nnoremap <silent> <leader>ul :t.\|s/./-/\|:nohls<cr>
" Underline the current line with '='
nnoremap <silent> <leader>uul :t.\|s/./=/\|:nohls<cr>
" Surround the commented line with lines.
nnoremap <silent> <leader>cul :normal "lyy"lpwv$r-^"lyyk"lP<cr>
" Format the entire file
nnoremap <leader>fef mx=ggG='x
" Split window vertically or horizontally *and* switch to the new split!
nnoremap <silent> <leader>hs :split<Bar>:wincmd j<CR>
nnoremap <silent> <leader>vs :vsplit<Bar>:wincmd l<CR>
" Close the current window
nnoremap <silent> <leader>sc :close<CR>
"
" Typo Fixes
noremap <F1> <Esc>
inoremap <F1> <Esc>
cnoremap w' w<CR>
" Disable the ever-annoying Ex mode shortcut key. Type visual my ass. Instead,
" make Q repeat the last macro instead. *hat tip* http://vimbits.com/bits/263
nnoremap Q @@
" Removes doc lookup mapping because it's easy to fat finger and never useful.
nnoremap K k
vnoremap K k
" Toggle paste mode with F5
nnoremap <silent> <F5> :set paste!<CR>
"Sudo write"
cmap w!! w !sudo tee % >/dev/null