个人vim配置文件

runtime! debian.vim
if has("syntax")
  syntax on
endif
if filereadable("/etc/vim/vimrc.local")
  source /etc/vim/vimrc.local
endif
"syntax high light
syntax on
"show the line number
set nu
"为c程序提供自动缩进
set smartindent
"使用c程序的自动缩进
set cindent
"设置缩进的空格数为4
set shiftwidth=4
"设置制表符
set tabstop=4
set softtabstop=4
"匹配模式()
set showmatch
"不保留备份文件
set nobackup
"配色方案
colorscheme ron
"中文显示
set fileencodings=utf-8,gb2312,gbk,gb18030
set termencoding=utf-8
set encoding=utf-8
"字体
"自动插入头文件
autocmd BufNewFile *.cpp exec ":call SetTitle()"
func SetTitle()
	if &filetype =='cpp'
	call setline(1,"/****************************************************")
	call append(line("."),"   file name: ".expand("%")."")
	call append(line(".")+1,"   author: huangjipeng")
	call append(line(".")+2,"   creat time: ".strftime("%c")."")
	call append(line(".")+3,"***************************************************/")
	call append(line(".")+4,"#include<iostream>")
	call append(line(".")+5,"#include<cstdio>")
	call append(line(".")+6,"#include<cstdlib>")
	call append(line(".")+7,"#include<string.h>")
	call append(line(".")+8,"#include<math.h>")
	call append(line(".")+9,"#include<algorithm>")
	call append(line(".")+10,"#include<map>")
	call append(line(".")+11,"#include<vector>")
	call append(line(".")+12,"#include<queue>")
	call append(line(".")+13,"using namespace std;")
	call append(line(".")+14,"#define MAXN 1")
	call append(line(".")+15,"int main()")
	call append(line(".")+16,"{")
	call append(line(".")+17,"    return 0;")
	call append(line(".")+18,"}")
	endif
	"新建文件时定位到文件尾
	autocmd BufNewFile * normal G
endfunc
map <C-A> ggVG
map! <C-A> <Esc>ggVGY
" 选中状态下 Ctrl+c 复制
"C,C++ 按F9编译运行
map <F8> :call CompileRunGcc()<CR>
func! CompileRunGcc()
    exec "w"
	if &filetype == 'c'
	    exec "!g++ % -o %<"
		exec "! ./%<"
	elseif &filetype == 'cpp'
        exec "!g++ % -o a"
    elseif &filetype == 'java' 
        exec "!javac %" 
        exec "!java %<"
    elseif &filetype == 'sh'
        :!./%
    endif
endfunc
map <F9> :call RunGcc()<CR>
func! RunGcc()
	exec "w"
	exec "! ./a"
endfunc
map <F7> :call RunIn()<CR>
func!RunIn()
	exec "w"
	exec "! ./a < in.txt"
endfunc

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值