该空间是个人实践过程中的总结,欢迎交流吐槽!

【shell脚本】CentOS 上vim 文件模板(python、shell、cpp、php)编制

上一篇 / 下一篇  2016-12-21 13:13:25 / 个人分类:SHELL

CentOS上使用vim编辑文件时使用的pythonshell、cpp、php模板编制

1、【vim .vimrc】   录入如下内容:=====之间部分,不包括======
================================
syntax on         " 语法高亮显示
set nocompatible  " 关闭vim扩展功能,模拟vi行为
set number        " 设置行号
filetype on       " 开启文件类型检测
set history=1000
set background=dark
set autoread        " 设置文件被改动时自动载入
set autoindent      " 自动缩进
"set cindent         " 针对C语言
"set smartindent
set tabstop=4       " Tab键宽度
set shiftwidth=4
set showmatch
set guioptions-=T
set ruler           " 打开状态标尺
"set cursorline      " 突出显示当前行
set nohls
set incsearch
set nocompatible    " 共享剪贴板
"set fileencodings=utf-8

if &term=="xterm"
    set t_Co=8
    set t_Sb=^[[4%dm
    set t_Sf=^[[3%dm
endif
function AddFileInformation_php()
      let infor = "<?php\n"
      \." ******************************************************************** \n"
      \." * Copyright (c) 2016 \n"
      \." *  \n"
      \." ********************************************************************/ \n"
      \." \n"
      \."/** \n"
      \." * @file: ".expand("%")." \n"
      \." * @author: Janesong \n"
      \." * @mail: Janesong0806@163.com \n"
      \." * @date: ".strftime("%Y-%m-%d %H:%M:%S")." \n"
      \." * @version 1.0 \n"
      \." **/ \n"
      \." \n"
      \." \n"
      \." \n"
      \." \n"
      \."?>"
      silent  put! =infor
endfunction
autocmd BufNewFile *.php call AddFileInformation_php()

function AddFileInformation_sh()
      let infor = "#!/bin/bash\n"
      \."\n"
      \."# ******************************************************************** \n"
      \."# * @file: ".expand("%")." \n"
      \."# * @author: Janesong \n"
      \."# * @mail: Janesong0806@163.com \n"
      \."# * @date: ".strftime("%Y-%m-%d %H:%M:%S")." \n"
      \."# * @version 1.0  \n"
      \."# * @description: Shell script. \n"
      \."# * @Copyright (c)  all right reserved \n"
      \."# ********************************************************************/ \n"
      \."\n"
      \."\n"
      \."\n"
      \."\n"
      \."exit 0"
      silent  put! =infor
endfunction
autocmd BufNewFile *.sh call AddFileInformation_sh()

function AddFileInformation_py()
      let infor = "#!/usr/bin/env python\n"
      \."# -*- coding: utf-8 -*-\n"
      \."# ******************************************************************** \n"
      \."# * @file:".expand("%")." \n"
      \."# * @author: Janesong \n"
      \."# * @mail: Janesong0806@163.com \n"
      \."# * @date: ".strftime("%Y-%m-%d %H:%M:%S")." \n"
      \."# * @version 1.0  \n"
      \."# * @description: Python Script. \n"
      \."# * @Copyright (c)  all right reserved \n"
      \."# ********************************************************************/ \n"
      \."import os,sys"
      \."\n"
      \."print u'''??'''\n"
      \."\n"
      \."\n"
      \."\n"
      \."\n"
      \."exit()"
      silent  put! =infor
endfunction
autocmd BufNewFile *.py call AddFileInformation_py()

function AddFileInformation_cpp()
       let infor = "#include<iostream>\n"
       \."# ******************************************************************** \n"
       \."# * @file: ".expand("%")." \n"
       \."# * @author: Janesong \n"
       \."# * @mail: Janesong0806@163.com \n"
       \."# * @date: ".strftime("%Y-%m-%d %H:%M:%S")." \n"
       \."# * @version 1.0  \n"
       \."# * @description: C++ Script. \n"
       \."# * @Copyright (c)  all right reserved \n"
       \."# ********************************************************************/ \n"
       \."\n"
       \."\n"
       \."\n"
       \."\n"
      silent  put! =infor
endfunction
autocmd BufNewFile *.cpp call AddFileInformation_cpp()
====================

2、将.vimrc放到对应的用户目录下即可。


TAG: shell

 

评分:0

我来说两句

我的栏目

日历

« 2024-03-13  
     12
3456789
10111213141516
17181920212223
24252627282930
31      

数据统计

  • 访问量: 17513
  • 日志数: 16
  • 建立时间: 2016-09-08
  • 更新时间: 2018-03-28

RSS订阅

Open Toolbar