一、.vimrc配置文件 cat .vimrc set backupdir=/root/vimbackup set background=dark colorscheme desert syntax on set incsearch if has("autocmd") filetype plugin indent on endif set hlsearch autocmd BufReadPost * \ if line("‘\"") > 0 && line("‘\"") <= line("$") | \ exe "normal g`\"" | \ endif autocmd BufNewFile *.[ch],*.cpp,*.sh,*.java,*.php,*.py exec ":call SetTitle()" autocmd BufNewFile * normal G autocmd BufNewFile *.php normal k autocmd BufWrite *.[ch],*.cpp,*.sh,*.java,*.php,*.py exec ":!ctags -R *" autocmd BufNewFile,BufRead *.py set cinwords=if,elif,else,for,while,try,expect,finally,def,class autocmd BufNewFile,BufRead *.[ch],*.cpp set foldmethod=syntax func SetTitle() if &filetype == ‘sh‘ || &filetype == ‘python‘ call setline(1, "\#--------------------------------------------------") call append(line("."), "\#Author:jimmygong") call append(line(".")+1, "\#Email:[email protected]") call append(line(".")+2, "\#FileName:".expand("%")) call append(line(".")+3, "\#Function: ") call append(line(".")+4, "\#Version:1.0 ") call append(line(".")+5, "\#Created:".strftime("%Y-%m-%d")) call append(line(".")+6, "\#--------------------------------------------------") call append(line(".")+7, "") else call setline(1, "/**") call append(line("."), "--------------------------------------------------") call append(line(".")+1, "Author:jimmygong") call append(line(".")+2, "Email:[email protected]") call append(line(".")+3, "FileName:".expand("%")) call append(line(".")+4, "Function: ") call append(line(".")+5, "Version:1.0 ") call append(line(".")+6, "Created:".strftime("%Y-%m-%d")) call append(line(".")+7, "--------------------------------------------------") call append(line(".")+8, "**/") call append(line(".")+9, "") endif if &filetype == ‘php‘ call append(0, "<?php") call append(line("$"), "?>") endif if &filetype == ‘sh‘ call append(0, "\#!/bin/bash") elseif &filetype == ‘python‘ call append(0, "\#!/usr/bin/python") call append(1, "\# -*- coding: utf-8 -*-") endif endfunc 二、效果图
时间: 2024-11-05 11:42:46