博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Linux-vimrc

Posted on 2023-03-14 07:01  乔55  阅读(20)  评论(0编辑  收藏  举报

vimrc注释

syntax on           #进行语法检验,颜色显示
 set nu             #设置行号
 set tabstop=4      #设置tab键宽度
 set shiftwidth=4   #gg=G默认是个空格的缩进,设置为
 set autoindent     #自动缩进
 set smartindent    #智能缩进
 set cindent        #C缩进
 set ruler          #显示标尺,编辑过程中右下角显示光标位置的状态行
 set showmatch      #自动匹配括号
 set showmatch      #自动匹配括号
 set matchtime=2    #匹配括号高亮显示的时间
 set showcmd        #输入的命令显示出来,看的清楚些
 set cursorline     #突出显示当前行
 set hlsearch       #搜索高亮末行模式下输入noh,可取消当前高亮显示状态
 set nohls          #关闭搜索时高亮显示
 set incsearch      #搜索时逐字高亮
 set ignorecase     #搜索时忽略大小写
 set vb t_vb        #去掉命令错误时的响声
 set wrap           #自动换行
 set list           #显示制表符
 set backspace      #设置退格键可用

myvimrc.txt

syntax on
set nu
set norelativenumber

set tabstop=2
set shiftwidth=2
set matchtime=2

set smartindent
set cindent
set autoindent

set ruler
set cursorline

set showmatch
set showcmd

set hlsearch
set incsearch
exec "nohlsearch"
set ignorecase
set smartcase

set wildmenu

let mapleader=" "
noremap <LEADER><CR> :noh<CR>

noremap n h

map s <nop>
map S :w<CR>
map Q :q<CR>

inoremap ( ()<Esc>i
inoremap [ []<Esc>i
inoremap { {}<Esc>i<Enter><Esc>O
inoremap " ""<Esc>i
inoremap ' ''<Esc>i
inoremap <C-b> <Backspace>
inoremap <C-g> <Down><Right>
inoremap <C-j> <Down>
inoremap <C-k> <Up>
inoremap <C-h> <Left>
inoremap <C-l> <Right>

func SkipPair()  
    if getline('.')[col('.') - 1] == ')' || getline('.')[col('.') - 1] == ']' || getline('.')[col('.') - 1] == '"' || getline('.')[col('.') - 1] == "'" || getline('.')[col('.') - 1] == '}'  
        return "\<ESC>la"  
    else  
        return "\t"  
    endif  
endfunc  

inoremap <TAB> <c-r>=SkipPair()<CR>
  • 注意
    • 使用了上述.vimrc后,退格健失效
    • 记得在CRT客户端设置:Session Options->Terminal->Emulation->Mapped Keys
    • 勾选:Backspace send delete

.vimrc文件相关

  • /etc/vimrc // 全局文件
  • ~/.vimrc // 用户配置文件,优先级大于/etc/vimrc
  • 记得安装 :yum install vimrc