This repository was archived by the owner on Apr 3, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremappings.vim
More file actions
126 lines (114 loc) · 3.31 KB
/
remappings.vim
File metadata and controls
126 lines (114 loc) · 3.31 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
""" Visual shifting {
" Visual shifting (does not exit Visual mode). Keeps the selection in place
vnoremap < <gv
vnoremap > >gv
""" }
""" Blockwise visual block {
nnoremap <Leader>v <c-v>
" }
"""
" Yank a region in VIM without the cursor moving to the top of the block
" https://stackoverflow.com/questions/3806629/yank-a-region-in-vim-without-the-cursor-moving-to-the-top-of-the-block
vmap y ygv<Esc>
""" }
""" Break lines {
" Treat long lines as break lines (useful when moving around in them)
nmap j gj
nmap k gk
vmap j gj
vmap k gk
""" }
""" :W sudo saves the file {
" (useful for handling the permission-denied error)
command! W w !sudo tee % > /dev/null
""" }
" Change cursor shape for iTerm2 on macOS {
" bar in Insert mode
" inside iTerm2
if $TERM_PROGRAM =~# 'iTerm'
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_SR = "\<Esc>]50;CursorShape=2\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
endif
" inside tmux
if exists('$TMUX')
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_SR = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=2\x7\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
endif
" }
" Key (re)Mappings {
"" Quit normal mode
nnoremap <Leader>q :q<CR>
nnoremap <Leader>Q :qa!<CR>
nnoremap <Leader>x :x<CR>
nnoremap <Leader>X :qa!<CR>
" Move to the start of line
nnoremap H ^
" Move to the end of line
nnoremap L $
" Redo
nnoremap U <C-r>
" Quick command mode
nnoremap ; :
" Yank to the end of line
nnoremap Y y$
"""" Windows manipulation {
" https://github.com/liuchengxu/vim-better-default/wiki/A-brief-introduction-to-key-bindins
nnoremap <Leader>ww <C-W>w
" Swap window
nnoremap <Leader>wr <C-W>r
" delete-window
nnoremap <Leader>wd <C-W>c
nnoremap <Leader>wq <C-W>q
" window-down
nnoremap <Leader>wj <C-W>j
" window-up
nnoremap <Leader>wk <C-W>k
" window-left
nnoremap <Leader>wh <C-W>h
nnoremap <Leader>wl <C-W>l
" window-right
nnoremap <Leader>wH <C-W>5<
nnoremap <Leader>wL <C-W>5>
nnoremap <Leader>wJ :resize +5<CR>
nnoremap <Leader>wK :resize -5<CR>
" balance-windows
nnoremap <Leader>w= <C-W>=
" split-window-below
nnoremap <Leader>ws <C-W>s
" split-window-below
nnoremap <Leader>w- <C-W>s
" split-window-vertical
nnoremap <Leader>wv <C-W>v
" split-window-vertical
nnoremap <Leader>w\| <C-W>v
" layout-double-columns
nnoremap <Leader>w2 <C-W>v
"""" }
"""" Easier split navigations {
" https://robots.thoughtbot.com/vim-splits-move-faster-and-more-naturally
" instead of ctrl-w then j, it’s just ctrl-j
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
"""" }
""" }
""" Automatically change the current directory {
" http://vim.wikia.com/wiki/Set_working_directory_to_the_current_file
autocmd BufEnter * silent! lcd %:p:h
""" }
""" AutoSaveFolds {
" " https://til.hashrocket.com/posts/17c44eda91-persistent-folds-between-vim-sessions
" " http://stackoverflow.com/questions/2142402/code-folding-is-not-saved-in-my-vimrc
" " http://vim.wikia.com/wiki/Make_views_automatic
" augroup AutoSaveFolds
" autocmd BufWinLeave .* mkview
" autocmd BufWinEnter .* silent loadview
" augroup END
""" }
""" Static and Relative Numbers {
" autocmd InsertEnter * :set number norelativenumber " Static numbers in insert mode
" autocmd InsertLeave * :set nonumber relativenumber " Relative numbers in normal mode
""" }