vim的一些小技巧

在/etc/vim.rc中设置全局变化
在~/.vimrc中设置当前用户 — 推荐
没有此文件可手工添加

autocmd BufNewFile *.py,*.cc,*.sh,*.java exec ":call SetTitle()"


func SetTitle()
    if expand("%:e") == 'sh'
        call setline(1,"#!/bin/bash")
        call setline(2, "##############################################################")
        call setline(3, "# File Name: ".expand("%"))##脚本名称信息
        call setline(4, "# Version: V1.0")##脚本版本信息
        call setline(5, "# Author: YC")##脚本作者信息
        call setline(6, "# Organization: www.oldboyedu.com")##公司信息
        call setline(7, "# Created Time : ".strftime("%F %T"))##创建时间
        call setline(8, "# Description:")##脚本说明
        call setline(9, "##############################################################")
        call setline(10, "")
    endif
endfunc

修改后创建新文件

#!/bin/bash
##############################################################
# File Name: cloer.sh  
# Version: V1.0
# Author: name 
# Organization: www.oldboyedu.com 
# Created Time : 2020-01-16 10:35:07 
# Description:  
##############################################################

vim 的一些简单优化

set nocompatible
set history=100
filetype on
filetype plugin on
filetype indent on
set autoread
set mouse=c
syntax enable
set cursorline
hi cursorline guibg=#00ff00
hi CursorColumn guibg=#00ff00
set foldenable
set foldmethod=manual
set foldcolumn=0
setlocal foldlevel=3
set foldclose=all           
nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>
set expandtab
set tabstop=4
set shiftwidth=4
set softtabstop=4
set smarttab
set ai  
set si
set wrap
set sw=4
set wildmenu
set ruler
set cmdheight=1
set lz
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
set magic
set noerrorbells
set novisualbell
set showmatch
set mat=4
set hlsearch
set ignorecase
set encoding=utf-8
set fileencodings=utf-8
set termencoding=utf-8
set smartindent
set cin
set showmatch
set guioptions-=T
set guioptions-=m
set vb t_vb=
set laststatus=4
set pastetoggle=<F9>
set background=dark
highlight Search ctermbg=black  ctermfg=white guifg=white guibg=black
发布了24 篇原创文章 · 获赞 0 · 访问量 320

猜你喜欢

转载自blog.csdn.net/xiaobaiqifei/article/details/104010212