set nocompatible
set hlsearch
set nobackup
set noswapfile
set autoindent
set smartindent
set cindent
set smarttab
set tabstop=4
set softtabstop=4
set shiftwidth=4
set cuc
set cul
set number
set ruler
set go=
set guifont=Consolas:h18:cANSI
set backspace=indent,eol,start
color solarized
set background=dark
syntax on
imap jf <Esc>:w<CR>
map <C-j> 6j
map <C-h> 6h
map <C-k> 6k
map <C-l> 6l
map <Space> <C-w>
map Y "+y
map P "+gP
let mapleader="-"
map <leader>as 1GVG"+y
map <F5> :call Debug()<cr>
map <F9> :call Compile()<cr>
map <F10> :call Run()<cr>
map <F11> :call Compile()<cr>:call Run()<cr>
map <F12> :call Debug_Mode()<cr>
function! Compile()
exec "wall"
exec "!g++ % -o %< -Wl,--stack=268435456 -Wall "
endfunction
function! Run()
exec "!%<"
endfunction
function! Debug()
exec "wall"
exec "!g++ % -o %< -Wl,--stack=268435456 -Wall -g"
exec "!gdb %<"
endfunction
function! Debug_Mode()
exec "vsp %<.out"
exec "sp %<.in"
endfunction
set autoread
set autochdir
au GUIEnter * call libcallnr ( "vimtweak.dll" , "SetAlpha" , 210 )
map <F8> :call SetTitle() <cr>'s
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""新文件标题""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"新建.c,.h,.sh,.java文件,自动插入文件头 博主使用cpp,你们可以使用其它的
autocmd BufNewFile *.cpp,*.[ch],*.sh,*.java exec ":call SetTitle()"
""定义函数SetTitle,自动插入文件头
func SetTitle()
"如果文件类型为.sh文件
if &filetype == 'sh'
call setline(1,"\#########################################################################")
call append(line("."), "\# File Name: ".expand("%"))
call append(line(".")+1, "\# Author: ma6174")
call append(line(".")+2, "\# mail: ma6174@163.com")
call append(line(".")+3, "\# Created Time: ".strftime("%c"))
call append(line(".")+4, "\#########################################################################")
call append(line(".")+5, "\#!/bin/bash")
call append(line(".")+6, "")
else
call setline(1,"/*************************************************************************")
call append(line("."), " > File Name: ".expand("%"))
call append(line(".")+1, " > Author: llz-cnyali")
call append(line(".")+2, " > Created Time: ".strftime("%c"))
call append(line(".")+3, "************************************************************************/")
call append(line(".")+4, "")
endif
if &filetype == 'cpp'
call append(line(".")+5, "#include<iostream>")
call append(line(".")+6, "#include<cstdio>")
call append(line(".")+7, "#include<cstdlib>")
call append(line(".")+8, "#include<cmath>")
call append(line(".")+9, "#include<cstring>")
call append(line(".")+10, "#include<algorithm>")
call append(line(".")+11, "")
call append(line(".")+12, "using namespace std;")
call append(line(".")+13, "")
call append(line(".")+14, "#define REP(i, a, b) for(register int i = (a), i##_end_ = (b); i <= i##_end_; ++ i)")
call append(line(".")+15, "#define DREP(i, a, b) for(register int i = (a), i##_end_ = (b); i >= i##_end_; -- i)")
call append(line(".")+16, "#define mem(a, b) memset((a), b, sizeof(a))")
call append(line(".")+17, "")
call append(line(".")+18, "int read()")
call append(line(".")+19, "{")
call append(line(".")+20, " int sum = 0, fg = 1; char c = getchar();")
call append(line(".")+21, " while(c < '0' || c > '9') { if (c == '-') fg = -1; c = getchar(); }")
call append(line(".")+22, " while(c >= '0' && c <= '9') { sum = sum * 10 + c - '0'; c = getchar(); }")
call append(line(".")+23, " return sum * fg;")
call append(line(".")+24, "}")
call append(line(".")+25, "")
call append(line(".")+26, "int main()")
call append(line(".")+27, "{")
call append(line(".")+28, "")
call append(line(".")+29, " return 0;")
call append(line(".")+30, "}")
endif
"新建文件后,自动定位到文件末尾
autocmd BufNewFile * normal G
endfunc
"一键运行代码
function CheckPythonSyntax()
let mp = &makeprg
let ef = &errorformat
let exeFile = expand("%:t")
setlocal makeprg=python\ -u
set efm=%C\ %.%#,%A\ \ File\ "%f"\,\ line\ %l%.%#,%Z%[%^\ ]%\@=%m
silent make %
copen
" set efm 是设置quickfix的errorformat,以便vim识别
" makeprg 是vim内置的编译命令,可以通过更改来实现编译对应类型文件。具体可参考vim官方说明文件。
" copen是打开quickfix,n用来设置quichfix窗口大小,如 cope5。在错误描述上回车,可以直接跳转到错误行。