vim编辑器的用户配置范例

版权声明:本文为博主原创文章,转载请声明出处! https://blog.csdn.net/weixin_42758707/article/details/90485995

vim编辑器的用户配置范例

set nu	#显示行号
set ts=4	#设置tab键为4格
set shiftwidth=4	#设置自动缩进长度为4空格
syntax on	#语法高亮
set cursorline	#突出显示当前行
set mouse=a		#允许鼠标
set ai		#智能缩进
set showmatch	#显示括号匹配
set paste	#设置粘贴模式
set laststatus=2	#总是显示状态栏
set ruler	#显示光标当前位置
set listchars=tab:>-,trail:-	#显示空格和tab键

#设置编码,中文不乱码
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set termencoding=utf-8
set encoding=utf-8

#创建后缀为sh的文件时执行下面的函数
autocmd BufNewFile *.sh exec ":call SetTitle()"
func SetTitle()
        if expand("%:e") == 'sh'
    call setline(1,"#!/bin/bash")
    call setline(2,"#")
    call setline(3,"#***********************************************************")
    call setline(4,"#Author:                Chen")
    call setline(5,"#QQ:                    ******")
    call setline(6,"#Date:                  ".strftime("%Y-%m-%d"))
    call setline(7,"#FileName:             ".expand("%"))
    call setline(8,"#URL:                   http://thson.blog.csdn.net")
    call setline(9,"#Description:          The test script")
    call setline(10,"#**********************************************************")
    call setline(11,"")
endif
endfunc
autocmd BufNewFile * normal G

猜你喜欢

转载自blog.csdn.net/weixin_42758707/article/details/90485995