-
Notifications
You must be signed in to change notification settings - Fork 1
/
_vimrc.base
184 lines (144 loc) · 3.9 KB
/
_vimrc.base
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
set langmenu=none
" iMproved, required
set nocompatible
" Desc: tab
set smarttab
" TAB 切换为空格
set expandtab
" tab=4 个空格
set tabstop=4
" 根据前方代码判断缩进
set cindent shiftwidth=4 " set cindent on to autoinent when editing c/c++ file, with 4 shift width
" 特定参数改变缩进行为, see help cinoptions-values for more details
set cinoptions=>s,e0,n0,f0,{0,}0,^0,:0,=s,l0,b0,g0,hs,ps,ts,is,+s,c3,C0,0,(0,us,U0,w0,W0,m0,j0,)20,*30
" Desc: 缩进
" shift 四舍五入到tab 的倍数
set shiftround
" 下一行复制上一行缩进
set autoindent
" {} 开始时添加缩进
set smartindent
"
" 相对行号
set relativenumber
" 显式当前行号
set nu
" 自动换行
set wrap
" 搜索
set showmatch " show matching paren
set incsearch " do incremental searching
set hlsearch " highlight search terms
set ignorecase " set search/replace pattern to ignore case
set smartcase " set smartcase mode on, If there is upper case character in the search patern, the 'ignorecase' option will be override.
" 剪切板
set clipboard+=unnamed,unnamedplus
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
" 指定按一次backspace就删除shiftwidth宽度
set smarttab
" 补全时即使有一个写显式菜单,不自动选第一个
set completeopt=menuone,noselect
" 保留5行
set scrolloff=10
" 关闭系统警告声
set noeb
" 通过闪烁代替警告
set vb
" 任意时刻使用鼠标
set mouse=a
" in visual block mode, cursor can be positioned where there is no actual character
set ve=block
" 解释所有数字为十进制
set nf=
" enable complete in command mode
set wildmenu
set showcmd
set cmdheight=1
" show the cursor position all the time
set ruler
" shortens messages to avoid 'press a key' prompt
set shortmess=aoOtTI
" do not redraw while executing macros (much faster)
set lazyredraw
" for easy browse last line with wrap text
set display+=lastline
" always have status-line
set laststatus=2
" allow to change buffer without saving
set hidden
" 当文件在外部被修改,自动更新该文件
set autoread
" make sure our terminal use 256 color
set termguicolors
set t_Co=256
" File encoding
set encoding=utf-8 " 设置gvim内部编码,默认不更改
set fileencodings=utf-8,ucs-bom,gbk,cp936,latin-1 "设置支持打开的文件的编码
" 默认在右边/下边打开新窗口
set splitright
set splitbelow
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
" 0 second to show the matching parent ( much faster )
set matchtime=0
" no autochchdir
set noacd
" 当前行高亮
if has('gui_running') || (empty($SSH_CLIENT) && empty($SSH_TTY))
set cursorline
endif
" mapper
let mapleader ="\\"
" 增强剪切板
map <leader>y "*y
vmap <leader>y "*y
map <leader>p "*p
" w为选择到这个单词结尾
nmap w e
" 缩进后保持v mode
vmap < <gv
vmap > >gv
" 全选
nmap <C-a> ggVG
nmap <D-a> ggVG<CR>
" 保存
cmap W w
cmap ww w !sudo tee %
" paste 后不替换
nnoremap <leader>d "_d
function! Paste()
" " 保存原始光标位置
" let save_cursor = getpos(".")
" 获取剪贴板内容
let clipboard_content = getreg('"')
" 检查内容是否以换行符结束
if clipboard_content[-1] == "\n"
" 如果是,执行 "_dp
execute 'normal! gv"_d'
execute 'normal! P'
else
" 如果不是,执行 "_dP
execute 'normal! gv"_d'
execute 'normal! P'
endif
"
" " 恢复原始光标位置
" call setpos('.', save_cursor)
endfunction
" 将 p 键映射到这个函数
vnoremap p :call Paste()<CR>
nmap gp '.
nmap <c-k> <c-w>k
nmap <c-j> <c-w>j
nmap <c-h> <c-w>h
nmap <c-l> <c-w>l
noremap <Up> <c-w>k
noremap <Down> <c-w>j
noremap <Left> <c-w>h
noremap <Right> <c-w>l
if has('multi_byte_ime')
hi Cursor guifg=bg guibg=White gui=NONE
hi CursorIM guifg=NONE guibg=Skyblue gui=NONE
set iminsert=0 imsearch=0
endif