主要是針對vim IDE的一些配置,歡迎補充!
"設(shè)置字符集
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set termencoding=utf-8
set encoding=utf-8
"把當前行的對起格式應(yīng)用到下一行
set autoindent
"將換行自動縮進設(shè)置成4個空格箕速;
set shiftwidth=4
"表示一個tab鍵相當于4個空格鍵
set tabstop=4
"自動填充4個空格為tab
set expandtab
"顯示行號
set nu
"啟用標記折疊锁保。所有文本將按照特定標記(默認為{{{和}}})自動折疊。
set foldmethod=marker
"粘貼不縮進的方法:set paste
set paste
"從不備份
set nobackup
"禁止生成臨時文件
set noswapfile
"確認VI
set confirm
"關(guān)閉鼠標
set mouse -=a
"顯 示 TAB 鍵
"set list
"設(shè)置文件格式
set fileformat=unix
"代碼自動完成(ctrl-x ctrl-o)
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascrīpt set omnifunc=javascrīptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType c set omnifunc=ccomplete#Complete
filetype plugin on
"文件頭注釋生成,"映射F2快捷鍵排龄,生成后跳轉(zhuǎn)至第10行阀坏,然后使用o進入vim的插入模式
autocmd BufNewFile *.c,*.cpp,*.sh,*.py,*.java,*.php exec ":call Setfilehead()"
func Setfilehead()
"如果文件類型為.c或者.cpp文件
if (&filetype == 'c' || &filetype == 'cpp')
call setline(1, "/*************************************************************************")
call setline(2, "\ @Author: Your Name")
call setline(3, "\ @Created Time : ".strftime("%c"))
call setline(4, "\ @File Name: ".expand("%"))
call setline(5, "\ @Description:")
call setline(6, " ************************************************************************/")
call setline(7,"")
endif
"如果文件類型為.sh文件
if &filetype == 'shell'
call setline(1, "\#!/bin/sh")
call setline(2, "\# Author: Your Name")
call setline(3, "\# Created Time : ".strftime("%c"))
call setline(4, "\# File Name: ".expand("%"))
call setline(5, "\# Description:")
call setline(6,"")
endif
"如果文件類型為.py文件
if &filetype == 'python'
call setline(1, "\#!/usr/bin/env python")
call setline(2, "\# -*- coding=utf8 -*-")
call setline(3, "\"\"\"")
call setline(4, "\# Author: Your Name")
call setline(5, "\# Created Time : ".strftime("%c"))
call setline(6, "\# File Name: ".expand("%"))
call setline(7, "\# Description:")
call setline(8, "\"\"\"")
call setline(9,"")
endif
"如果文件類型為.php文件
if &filetype == 'php'
call append(0, '<?php ')
call append(1, '/**')
call append(2, '* @File: '.expand("%"))
call append(3, '* @Author: Your Name')
call append(4, '* @Description: ---')
call append(5, '* @Date: '.strftime("%Y-%m-%d %H:%M:%S"))
call append(6, '* @Last Modified: '.strftime("%Y-%m-%d %H:%M:%S")."\n" )
call append(7, '*/')
call append(8, '')
call append(9, '')
call append(10, '')
call append(11, '')
call append(12, '')
call append(13, '')
call append(14, '/* vim: set expandtab ts=4 sw=4 sts=4 tw=100: */')
call append(15, '?>')
endif
endfunc
map <F2> :call Setfilehead()<CR>:10<CR>o
"內(nèi)部注釋快捷鍵生成,映射F11快捷鍵如暖,生成后跳轉(zhuǎn)至下行,該注釋段可以自行修改
func SetComment()
call append(line(".") , '//**************** comment start ********************')
call append(line(".")+1, '//**************** comment end ********************')
endfunc
map <F11> :call SetComment()<CR>j<CR>O