首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >VIM之个性化配置 .vimrc

VIM之个性化配置 .vimrc

作者头像
保持热爱奔赴山海
发布2019-09-18 15:08:41
6820
发布2019-09-18 15:08:41
举报
文章被收录于专栏:饮水机管理员饮水机管理员

贴一个自己常用的vim配置文件,个人感觉这些配置不算臃肿,对于运维已经基本够用了。

set shortmess=atI

syntax enable

syntax on "设置语法高亮

set nu

set ruler

set autoindent "设置自动缩进

set nocompatible

set magic

set confirm

set history=1000

set cursorline

highlight Comment ctermfg=lightblue guifg=darkblue

set cindent

set tabstop=4

set softtabstop=4 "设置软制表符4个空格

set shiftwidth=4 "设置缩进4个空格

set smarttab

set si

set wrap

set showmatch

set smartindent

set cin

set hlsearch

au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif

" 下面是添加F4热键自动加入文件头注释信息

map <F4> ms:call AddAuthor()<cr>'S

function AddAuthor()

    let n=1

    while n < 11

        let line = getline(n)

        if line=~'[#]*\s*\*\s*\S*Last\s*modified\s*:\s*\S*.*$'

        call UpdateTitle()

        return

    endif

    let n = n + 1

    endwhile

    if &filetype == 'sh'

        call AddTitleForShell()

    elseif &filetype == 'python'

        call AddTitleForPython()

    else

        call AddTitleForC()

    endif

endfunction

function UpdateTitle()

    normal m'

    execute '/* Last modified\s*:/s@:.*$@\=strftime(": %Y-%m-%d %H:%M")@'

    normal mk

    execute '/* Filename\s*:/s@:.*$@\=": ".expand("%:t")@'

    execute "noh"

    normal 'k

    echohl WarningMsg | echo "Successful in updating the copy right." |echohl None

endfunction

"" add comment for C

function AddTitleForC()

    call append(0,"/**********************************************************")

    call append(1," * Author        : Lee")

    call append(2," * Email         : leeeee@gmail.com")

    call append(3," * Create time   : ".strftime("%Y-%m-%d %H:%M"))

    call append(4," * Last modified : ".strftime("%Y-%m-%d %H:%M"))

    call append(5," * Filename      : ".expand("%:t"))

    call append(6," * Description   : ")

    call append(7," * *******************************************************/")

    echohl WarningMsg | echo "Successful in adding the copyright." | echohl None

endfunction

"" add comment for Python

function AddTitleForPython()

    call append(0,"#!/usr/bin/python")

    call append(1,"# -*- coding: UTF-8 -*-")

    call append(2,"")

    call append(3,"# **********************************************************")

    call append(4,"# * Author        : Lee")

    call append(5,"# * Email         : leeeee@gmail.com")

    call append(6,"# * Create time   : ".strftime("%Y-%m-%d %H:%M"))

    call append(7,"# * Last modified : ".strftime("%Y-%m-%d %H:%M"))

    call append(8,"# * Filename      : ".expand("%:t"))

    call append(9,"# * Description   : ")

    call append(10,"# **********************************************************")

    echohl WarningMsg | echo "Successful in adding the copyright." | echohl None

endfunction

"" add conment for shell

function AddTitleForShell()

    call append(0,"#!/bin/bash")

    call append(1,"# **********************************************************")

    call append(2,"# * Author        : Lee")

    call append(3,"# * Email         : leeeee@gmail.com")

    call append(4,"# * Create time   : ".strftime("%Y-%m-%d %H:%M"))

    call append(5,"# * Last modified : ".strftime("%Y-%m-%d %H:%M"))

    call append(6,"# * Filename      : ".expand("%:t"))

    call append(7,"# * Description   : ")

    call append(8,"# **********************************************************")

endfunction

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2016-11-12 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档