" ===============================================
" === set设置===================================
" ===============================================
" 设置leader键"
let mapleader=" "
"设置剪贴板
set clipboard=unnamed
let &t_ut=''
set autochdir
" 设置寻找高亮
set hlsearch
exec "nohlsearch"
set incsearch
"从不备份
set nobackup
" 不要使用vi的键盘模式,而是vim自己的
set nocompatible
" 设置没有声音
set noerrorbells
set novisualbell
" 设置在cmap单词补全
set wildmenu
" 设置搜索ignorecase/smartcase
set ignorecase
set smartcase
set t_vb=
set tm=500
" 设置行号
set number
set relativenumber
" 设置最大标签页
set tabpagemax=20
"设置水平显示
set cursorline
set cuc
" 设置tab键和自动缩进
set tabstop=4
set shiftwidth=4
set softtabstop=4
” 下一行和上一行的格式相同
set autoindent
set cindent
" 不要用空格代替制表符
set noexpandtab
" 在行和段开始处使用制表符
set smarttab
"编码设置
set encoding=utf-8
set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
set fileformats=unix,dos,mac
set termencoding=utf-8
set formatoptions+=m
set formatoptions+=B
" 可以在buffer的任何地方使用鼠标(类似office中在工作区双击鼠标定位)
set mouse=a
set selection=exclusive
set selectmode=mouse,key
" 在被分割的窗口间显示空白,便于阅读
set fillchars=vert:\ ,stl:\ ,stlnc:\
" 高亮显示匹配的括号
“ set showmatch
" 设置在状态栏显示按键
set showcmd
” 总是显示状态栏
set showtabline=2
” 设置显示行尾结束符和制表符/空格和tab的样式
set list
set listchars=tab:\|\ ,trail:▫
“ 总是显示状态栏
set laststatus=2
” 设置粘贴的模式
set paste
” 显示光标当前位置'
set ruler
" 设置一直留下的行数
set scrolloff=15
" 设置vim操作的等待时间
set ttimeoutlen=0
set notimeout
“ 设置字不超过窗口
set wrap
set tw=0
set indentexpr=
set foldmethod=indent
set foldlevel=99
set foldenable
set formatoptions-=tc
set splitright
set splitbelow
set noshowmode
set shortmess+=c
set completeopt=longest,noinsert,menuone,noselect,preview
set ttyfast "should make scrolling faster
set visualbell
set colorcolumn=80
set updatetime=1000
set virtualedit=block
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
" ===============================================
" === 移动光标===================================
" ===============================================
" J K 快速移动上下五行
noremap <silent> K 5k
noremap <silent> J 5j
" 快速到行首
noremap H 0
" 快速到行尾
noremap L $
" 快速的单词跳转
noremap W 5w
noremap B 5b
" 快速移动5行
noremap <C-J> 5<C-y>
noremap <C-K> 5<C-e>
" 在插入模式下快速到行尾和行首
inoremap <C-h> <Left>
inoremap <C-j> <Down>
inoremap <C-k> <Up>
inoremap <C-l> <Right>
inoremap <C-a> <Home>
inoremap <C-e> <End>
" ===============================================
" === 复制,删除,查找和替换恢复和撤消=============
" ===============================================
" 快速选中一个单词
noremap vw viwl
" 快速选中括号中的内
noremap vb vibl
" 快速选中""的内
noremap v' vi"l
" 快速选中''的内
noremap v" vi"l
" 快速选html标签中的
noremap vt vitl
noremap vws viwl"+p
noremap vbs vibl"+p
noremap vts vitl"+p
noremap v's vi"l"+p
noremap v"s vi'l"+p
" ===
" ===b () t html中的<> s {}
" ===
" ciw
nnoremap ciw "+ciw
nnoremap cw ciw
" ci' "word"
nnoremap ci" "+ci'
nnoremap c" ci'
" cib (word)
nnoremap cib "+cib
nnoremap cb cib
" ci" "word"
nnoremap ci' "+ci"
nnoremap c' ci"
" cis {word}
nnoremap cis "+ci{
nnoremap cs ci{
" cit <>word<>
nnoremap cit "+cit
nnoremap ct cit
" yiw
nnoremap yiw "+yiw
nnoremap yw yiw
" yib (word)
nnoremap yib "+yib
nnoremap yb yib
" yit <>word<>
nnoremap yit "+yit
nnoremap yt yit
" y-' 'word'
nnoremap yi" "+yi'
nnoremap y" yi'
" y-" "word"
nnoremap yi' "+yi"
nnoremap y' yi"
" yi{
nnoremap yis "+yi{
nnoremap ys yi{
" diw
nnoremap siw "+diw
nnoremap sw diw
" dib
nnoremap sib "+dib
nnoremap sb dib
" dit
nnoremap sit "+dit
nnoremap st dit
" di'
nnoremap si" "+di'
nnoremap s" di'
" di"
nnoremap si' "+di"
nnoremap s' di"
" di{
nnoremap sis "+di{
nnoremap ss di{
" 查找和替换
noremap \s :%s//g<left><left>
" 查找到的内容居中
nnoremap <silent> n nzz
nnoremap <silent> N Nzz
nnoremap <silent> * *zz
nnoremap <silent> # #zz
nnoremap <silent> g* g*zz
" Y复制到行尾
nnoremap Y y$
" 复制到系统剪贴板
vnoremap Y "+y
vnoremap P "+p
vnoremap <C-c> "+y
"设置快捷键将系统剪贴板内容粘贴至 vim
noremap sp "+p
noremap sgp "+gp
" 设置S 为<C-r>/恢复
noremap S <C-r>
" ==============================================
" === 其它....===================================
" ==============================================
" 在正常模式下添加空行
noremap <CR> o<ESC>
noremap <S-Enter> O<Esc>
“ 全选快捷键
map <leader>sa ggVG
" 在插入模式下非递归映射(为 )<Esc>i"
inoremap ( ()<Esc>i
inoremap [ []<Esc>i
inoremap { {}<Esc>i
inoremap " ""<Esc>i
" 跳转命令
nnoremap ' `
nnoremap ` '
" 打开所有的折叠
noremap zr zR
" 关闭所有的折叠
noremap zm zM
" 插入模式下kj返回normal模式
inoremap kj <Esc>
" <space>sc/拼写检查
noremap <LEADER>sc :set spell!<CR>
" C-c 回到正中
noremap <C-c> zz
" Search/取消搜索高亮
noremap <C-s> :nohlsearch<CR>
“ noremap
" 默认s键无用
noremap s <nop>
" noremap ; :
" 退出所有的页面
nnoremap <C-q> :qa!<CR>
" Save & quit/保存和退出
noremap Q :q<CR>
" Indentation/缩进一个> < 代表两个<>
nnoremap < <<
nnoremap > >>
" ===============================================
" === 窗口管理===================================
" ===============================================
noremap <LEADER>w <C-w>w
noremap <LEADER>k <C-w>k
noremap <LEADER>j <C-w>j
noremap <LEADER>h <C-w>h
noremap <LEADER>l <C-w>l
" 在窗口间跳转
noremap sj :set nosplitbelow<CR>:split<CR>:set splitbelow<CR>
noremap sk :set splitbelow<CR>:split<CR>
noremap sh :set nosplitright<CR>:vsplit<CR>:set splitright<CR>
noremap sl :set splitright<CR>:vsplit<CR>
" 调整窗口大小
" noremap <up> :res +5<CR>
" noremap <down> :res -5<CR>
" noremap <left> :vertical resize-5<CR>
" noremap <right> :vertical resize+5<CR>
" 上下放置两个屏幕
" noremap sg <C-w>t<C-w>K
" 并排放置两个屏幕
" noremap sv <C-w>t<C-w>
" 旋转屏幕
" noremap srh <C-w>b<C-w>K
" noremap srv <C-w>b<C-w>H
" 关闭下方窗口
noremap <LEADER>q <C-w>j:q<CR>
" ===============================================
" === 窗口管理===================================
" ===============================================
" Create a new tab with tu /新建一个tab
" noremap tk :tabe<CR>
" " Move around tabs with tn and ti
" noremap th :-tabnext<CR>
" noremap tl :+tabnext<CR>
" " Move the tabs with tmn and tmi
" noremap tmh :-tabmove<CR>
" noremap tml :+tabmove<CR>
" 标签切换
nnoremap tn gt
nnoremap tp gT
" ===============================================
" === vim的插件===================================
" ===============================================
" vim插件开始
call plug#begin('~/.vim/plugged')
Plug 'vim-airline/vim-airline'
Plug 'connorholyday/vim-snazzy'
call plug#end()
color snazzy
let g:SnazzyTransparent = 1
我的vimrc
最新推荐文章于 2024-06-20 17:54:22 发布