forked from mutewinter/dot_vim
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmappings.vim
More file actions
82 lines (62 loc) · 1.89 KB
/
mappings.vim
File metadata and controls
82 lines (62 loc) · 1.89 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
" ----------------------------------------
" Mappings
" ----------------------------------------
" Set leader to ,
" Note: This line MUST come before any <leader> mappings
let mapleader=','
let maplocalleader = ' '
" ---------------
" Regular Mappings
" ---------------
" Use ; for : in normal and visual mode, less keystrokes
nnoremap ; :
vnoremap ; :
" Yank entire buffer with gy
nnoremap gy :0,$ y<cr>
" Select entire buffer
nnoremap vy ggVG
" Just to beginning and end of lines easier. From http://vimbits.com/bits/16
noremap H ^
noremap L $
" ---------------
" Insert Mode Mappings
" ---------------
" Let's make escape better, together.
inoremap jk <Esc>
inoremap JK <Esc>
inoremap Jk <Esc>
inoremap jK <Esc>
" ---------------
" Leader Mappings
" ---------------
" Search and replace word under cursor
nnoremap <leader>sr :%s/\<<c-r><c-w>\>//<left>
" Smart insert semicolon
noremap <leader>; mqA;<Esc>`q
" Clear search
noremap <silent><leader>/ :nohls<CR>
" Highlight search word under cursor without jumping to next
nnoremap <leader>h *<C-O>
" Quickly switch to last buffer
nnoremap <leader>. :e#<CR>
" Underline the current line with '-'
nnoremap <silent> <leader>ul :t.\|s/./-/\|:nohls<cr>
" Surround the commented line with lines.
"
" Example:
" # Test 123
" becomes
" # --------
" # Test 123
" # --------
nnoremap <silent> <leader>cul :normal "lyy"lpwvLr-^"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>:wincmd =<CR>
nnoremap <silent> <leader>vs :vsplit<Bar>:wincmd l<CR>:wincmd =<CR>
" Open a new tab
nnoremap <silent> <leader>tn :tabnew<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 @@