-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot_vimrc
181 lines (165 loc) · 4.75 KB
/
dot_vimrc
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
" My old broken .vimrc:
" https://github.com/CyrusYip/dotfiles/blob/main/broken_config/dot_vimrc
" default configs[[[1
" Get the defaults that most users want.
source $VIMRUNTIME/defaults.vim
" backup, undo [[[2
if has("vms")
set nobackup " do not keep a backup file, use versions instead
else
set backup " keep a backup file (restore to previous version)
if has('persistent_undo')
" set undodir=~/.vim/undo_dir " todo: create dir if notexit
set undofile " keep an undo file (undo changes after closing)
endif
endif
" ]]]
" hlsearch[[[2
if &t_Co > 2 || has("gui_running")
" Switch on highlighting the last used search pattern.
set hlsearch
endif
" ]]]
" autocmd group[[[2
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78
augroup END
" ]]]
" matchit[[[2
" Add optional packages.
"
" The matchit plugin makes the % command work better, but it is not backwards
" compatible.
" The ! means the package won't be loaded right away but when plugins are
" loaded during initialization.
if has('syntax') && has('eval')
packadd! matchit
endif
" ]]]
" ]]]
" my configs[[[1
" number, clipboard[[[2
set clipboard^=unnamed,unnamedplus
set relativenumber numberwidth=1
autocmd FileType help setlocal relativenumber numberwidth=1
let g:netrw_bufsettings = 'relativenumber numberwidth=1 noma nomod ro nobl'
" set number relativenumber numberwidth=1
" autocmd FileType help setlocal number relativenumber numberwidth=1
" let g:netrw_bufsettings = 'number relativenumber numberwidth=1 noma nomod ro nobl'
"]]]
" indent, tab, case, whitespaces [[[2
" indent
set smartindent
set autoindent
" tab
" set smarttab
set tabstop=2 " The width of a TAB is set to 2.
set shiftwidth=2 " Indents will have a width of 2
" set softtabstop=2 " Sets the number of columns for a TAB
set expandtab " Expand TABs to spaces
" case insensitive
set ignorecase smartcase
" whitespaces, prefer multispace to space
set listchars=eol:¬,tab:>␣,trail:~,extends:>,precedes:<
try
set listchars+=multispace:···⬝
catch
set listchars+=space:·
endtry
" space:·, space:␣ ,leadmultispace:---+
"set list
"]]]
" true color, background[[[2
" true color
if (has("termguicolors"))
set termguicolors
endif
if $TERM == "xterm-256color"
set t_Co=256
endif
" tmux color
set term=xterm-256color
if &term =~ '256color'
" Disable Background Color Erase (BCE) so that color schemes work
" properly within 256-color terminals
set t_ut=
endif
" colorscheme
colorscheme slate
set laststatus=2
"]]]
" cursor shape[[[2
" https://stackoverflow.com/a/70135079/14399237
let &t_SI.="\e[5 q"
let &t_SR.="\e[3 q"
let &t_EI.="\e[1 q"
"]]]
" other[[[2
" filetype plugin
filetype plugin indent on
" switch buffers without saving
set hidden
" search all subdirectory of current directory
set path+=**
" wildmenu
set wildmode=longest:full,full
silent! set wildoptions=pum " ignore error in old Vim
" ask to save
set confirm
" show search count
set shortmess-=S
" remove intro message to reduce redrawing
set shortmess+=I
" make ctrl-d normal
set nostartofline
" auto wrap in vimdiff
au VimEnter * if &diff | execute 'windo set wrap' | endif
"
set autoread
set timeoutlen=500 " for vim-which-key
set nrformats+=alpha " manipulate alphabetical characters
" ]]]
" ]]]
" keybindings, commands[[[1
let mapleader = "\<space>"
nnoremap <leader>d :
vnoremap <leader>d :
nnoremap <silent> <esc><esc> :noh<return><esc>
" save and exit
nnoremap <silent> <leader>w :update<CR>
nnoremap <silent> <leader>W :wa<CR>
nnoremap <silent> <leader>c :q<CR>
nnoremap <silent> <leader>C :qa<CR>
nnoremap <silent> <leader>x :x<CR>
nnoremap <silent> <leader>X :xa<CR>
" search
nnoremap <leader>f /
vnoremap <leader>f /
nnoremap <leader>b ?
vnoremap <leader>b ?
" wrap
nnoremap <silent> <leader>rr :set wrap!<CR>
" list
nnoremap <silent> <leader>i :set list!<CR>
" plugin
" nnoremap <silent> <leader>s :AutoSaveToggle<CR>
" nnoremap <silent> <leader>l :LF<CR>
" nnoremap <silent> <leader>f :Files<CR>
" nnoremap <silent> <leader>j :JO<CR>
" nnoremap <silent> <leader>mf :TableFormat<CR>
" nnoremap <silent> <leader>mt :Toc<CR>
" nnoremap <silent> <leader> :WhichKey '<Space>'<CR>
" Cv: clean vim, used for fast macro replaying
command Cv silent! w | wviminfo | !vim -c 'set rnu nuw=1' -c 'file' --clean -i ~/.viminfo %
" CleanCocExtensions
command CleanCocExtensions !rm -r ~/.config/coc/extensions/ && echo 'removed'
" UP: upgrade all plugins and managers
command UP PlugClean | PlugUpdate | JetpackSync | PlugUpgrade | CocUpdate
" JO: copy Joplin note to another file
command JO w ~/Desktop/joplin-tmp.md | tabnew ~/Desktop/joplin-tmp.md | silent AutoSaveToggle
" ]]]
" fold this file with [[[ and ]]]
" vim:foldmethod=marker:foldmarker=[[[,]]]