-
Notifications
You must be signed in to change notification settings - Fork 0
/
myvimrc
204 lines (165 loc) · 5.66 KB
/
myvimrc
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
let mapleader = "'"
map <Space> <Leader>
map <Backspace> <Leader>
runtime! vimrcs/*.vimrc
if has('nvim')
runtime! vimrcs/*.nvimrc
runtime! vimrcs/*.lua
else
runtime! vimrcs/*.vvimrc
endif
" Window Splits
" http://sontek.net/turning-vim-into-a-modern-python-ide#id4
map <c-s-j> <c-w>J
map <c-s-k> <c-w>K
map <c-s-l> <c-w>L
map <c-s-h> <c-w>H
" In WSL, <c-s-h> overrides <c-h>. Mapping <c-h> later prevents it.
" Although <c-s-h> is not mapped any more, I use <c-h> a lot more frequently.
map <c-j> <c-w>j
map <c-k> <c-w>k
map <c-l> <c-w>l
map <c-h> <c-w>h
nnoremap gq <c-w>c
" Syntax Highlighting and Validation
" http://sontek.net/turning-vim-into-a-modern-python-ide#id8
syntax on " syntax highlighing
filetype on " try to detect filetypes
filetype plugin indent on " enable loading indent file for filetype
" http://stevelosh.com/blog/2010/09/coming-home-to-vim/#important-vimrc-lines
set nocompatible
" https://soooprmx.com/vim%ec%9d%98-%ed%83%ad-%eb%b0%8f-%eb%93%a4%ec%97%ac%ec%93%b0%ea%b8%b0-%ea%b4%80%eb%a0%a8-%ec%84%a4%ec%a0%95/
set tabstop=4 softtabstop=-1 shiftwidth=4 expandtab
set encoding=utf-8
set scrolloff=10
set autoindent
set showcmd
set wildmenu
set wildmode=list,full
set ttyfast
set ruler
set backspace=indent,eol,start
set laststatus=2
set relativenumber
set undofile
set history=5000
set ignorecase
set smartcase
set gdefault
set incsearch
set showmatch
set hlsearch
nnoremap <leader><Backspace> :noh<cr>
set wrap
"set textwidth=100
set formatoptions=qcron1
"set colorcolumn=100
" https://lee-phillips.org/badvim/
set nobackup
set nowritebackup
nnoremap <Down> gj
nnoremap <Up> gk
nnoremap j gj
nnoremap k gk
nnoremap gj j
nnoremap gk k
inoremap <F1> <ESC>
nnoremap <F1> <ESC>
vnoremap <F1> <ESC>
nnoremap "~ "+ # Kinesis 2 has + key in a place where normal keyboards has ~
vnoremap "~ "+
augroup myautocommands
autocmd!
" http://stackoverflow.com/a/1552193
autocmd CursorMoved * exe printf('match IncSearch /\V\<%s\>/', escape(expand('<cword>'), '/\'))
" https://www.reddit.com/r/vim/comments/g4dhvf/is_there_a_way_to_create_random_file_name_for/fnwyd4j?utm_source=share&utm_medium=web2x&context=3
autocmd CursorHold,BufLeave,FocusLost * if &buftype == "" | if expand('%') == "" | execute 'update ~/dev/hjdocs/scratches/vim_scratch_' . strftime("%Y%m%d_%H%M") . '.md' | else | update | endif | endif
" https://stackoverflow.com/a/38082157
autocmd BufEnter * silent! :lcd %:p:h | silent! lcd `git rev-parse --show-superproject-working-tree --show-toplevel \| head -1`
"autocmd BufEnter * silent! :lcd %:p:h | silent! lcd `git rev-parse --show-superproject-working-tree --show-toplevel \| head -1`| silent! lcd ../../src
" http://www.bestofvim.com/tip/better-commit-messages/
autocmd FileType gitcommit setlocal spell
autocmd FileType markdown setlocal spell
"autocmd FileType python setlocal foldmethod=indent
augroup END
if has("gui_running")
silent! source ~/.session.vim
augroup remember_session
autocmd!
autocmd VimLeave * silent! mksession! ~/.session.vim
augroup END
endif
" when neovide opens new I had to set cmdheight=1 for each tab.
augroup tabcmdheight
autocmd!
autocmd TabEnter * silent! set cmdheight=1
augroup END
" https://stackoverflow.com/a/37558470
augroup remember_folds
autocmd!
autocmd BufWinLeave * silent! mkview
autocmd BufWinEnter * silent! loadview
augroup END
" https://vim.fandom.com/wiki/Saving_a_file
map <Esc><Esc> :wa<CR>
" http://stevelosh.com/blog/2010/09/coming-home-to-vim/#using-the-leader
"nnoremap <leader>ev <C-w><C-s>:e $MYVIMRC<cr>
nnoremap <leader>ev :split +e $MYVIMRC<cr>
" http://www.bestofvim.com/tip/auto-reload-your-vimrc/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+bestOfVim+%28%3Abest+of+Vim%29
augroup reload_vimrc " {
autocmd!
autocmd BufWritePost $MYVIMRC source $MYVIMRC
autocmd BufWritePost ~/.vim/* source $MYVIMRC
autocmd BufWritePost ~/.dotfiles/vim.symlink/* source $MYVIMRC
autocmd BufWritePost ~/.dotfiles/vim.symlink/vimrcs/* source $MYVIMRC
augroup END " }
" http://stevelosh.com/blog/2010/09/coming-home-to-vim/#quicker-escaping
inoremap hh <ESC>hh
inoremap jj <ESC>jj
inoremap kk <ESC>kk
inoremap lll <ESC>lll
inoremap bb <ESC>bb
inoremap wwww <ESC>wwww
" http://www.reddit.com/r/vim/comments/ybx2x/whats_he_using_to_make_spaces_or_tabs_looks_like/c5u7kq3
"set list
set nolist
"set listchars=tab:▸\ ,trail:⋅,nbsp:⋅
"set listchars=tab:\ \ ,trail:⋅,nbsp:⋅
" https://stackoverflow.com/a/7078429
" Allow saving of files as sudo when I forgot to start vim using sudo.
cmap w!! w !sudo tee > /dev/null %
" https://www.reddit.com/r/vim/comments/cn20tv/tip_histogrambased_diffs_using_modern_vim/?utm_source=share&utm_medium=web2x&context=3
if has('nvim-0.3.2') || has("patch-8.1.0360")
set diffopt=filler,internal,algorithm:histogram,indent-heuristic
endif
""""""""""""
" 내 설정! "
""""""""""""
" :help ins-completion
inoremap ^] ^X^]
inoremap ^F ^X^F
inoremap ^D ^X^D
inoremap ^L ^X^L
map [q :update<Enter>:cp<Enter>
map ]q :update<Enter>:cn<Enter>
map [Q :update<Enter>:cfirst<Enter>
map ]Q :update<Enter>:clast<Enter>
map <leader>d :diffoff<Enter>:diffthis<Enter>
map <leader>D :diffoff<Enter>:set nocursorbind<Enter>:set noscrollbind<Enter>
map <leader>dg :diffget<Enter>
map <leader>dp :diffput<Enter>
" First fold then unfold all the way down
nnoremap zO zczO
set background=dark
"colorscheme torte
colorscheme github_dark_high_contrast
set modeline
set novisualbell t_vb=
set number
set linebreak
" :help ft-markdown-plugin
"let g:markdown_folding = 1
set nofixendofline
" https://stackoverflow.com/a/8752690
command! -bang -complete=file -nargs=+ Rename saveas<bang> <args> | call delete(expand('#'))`
set noautoread