1、 只需在Home目录创建一个~/.vimrc文件即可以配置vim
"" Source your .vimrc
"source ~/.vimrc
"" -- Suggested options --
" Show a few lines of context around the cursor. Note that this makes the
" text scroll if you mouse-click near the start or end of the window.
set scrolloff=5
" Do incremental searching.
set incsearch
" Don't use Ex mode, use Q for formatting.
map Q gq
"搜索忽略大小写
set ignorecase
"" -- Map IDE actions to IdeaVim -- https://jb.gg/abva4t
"" Map \r to the Reformat Code action
"map \r <Action>(ReformatCode)
"" Map <leader>d to start debug
"map <leader>d <Action>(Debug)
"" Map \b to toggle the breakpoint on the current line
"map \b <Action>(ToggleLineBreakpoint)
" Find more examples here: https://jb.gg/share-ideavimrc
let g:ycm_show_diagnostics_ui = 0 " 禁用语法检查
set nu
set relativenumber
set ic
" 去掉输入错误的提示声音
set noeb
" 在处理未保存或只读文件的时候,弹出确认
set confirm
set history=1000
" 可以在buffer的任何地方使用鼠标(类似office中在工作区双击鼠标定位)
set mouse=a
set selection=exclusive
set selectmode=mouse,key
" 通过使用: commands命令,告诉我们文件的哪一行被改变过
set report=0
"键位映射 1. 减少小拇指的负担 2. 减少指的移动 "
"选项卡的左右切换"
map Q :q<CR>
nmap J gT
nmap K gt
"窗口的左右切换"
nmap H <C-w>h
nmap L <C-w>l
nmap O <C-w>o
"上下翻页"
nmap ff <C-d>
vmap ff <C-d>
nmap bb <C-u>
vmap bb <C-u>
"nmap vv <C-v>
"nmap uu <C-u>
"nmap uu <C-u>
"nmap oo <C-o>
"vmap uu <C-u>
" nmap ee <C-e>
"括号自动补全
inoremap ( ()<Esc>i
inoremap [ []<Esc>i
inoremap { {}<Esc>i
"backspace的映射"
nnoremap z i<BS><Esc>l
2.、需安装插件,在~/.vim目录下创建一个bundle文件夹,插件装在里面。
3、键位映射 自定义快捷键
非字母键位 对照 定义标识
- 小键盘 0 到 9
<S-字母> Shift+字母键 , 例如 表 shift+a键
<C-字母> Control+字母键
<M-字母> Alt+字母键 或 meta+字母键
<A-字母> 同 <m-字母>
'CR-used-for-NL,即表示新行的意思,可以使用 CRTL-V CRTL-M(输入的是 字符本身) 或者 ‘\r’,Vim 并不会在文件中直接输入 字符,它会根据当前 ‘fileformat’ 的设置来决定使用(Mac),(*nix) 还是 (dos)。