新建C++文件会自动生成基本框架
新建python文件会自动生成读入函数
- F3 打开输入文件编辑页面
- F4 以该输入文件运行该程序
- F5 打开输出文件编辑页面
- F8 运行该程序
- F9 编译程序
- F12 运行python程序
syntax on
set backspace=indent,eol,start
set shortmess=atI
set nu si ci ai mouse=a sw=4 sts=4 ts=4
set hlsearch incsearch
colorscheme torte
set guioptions-=m
set guioptions-=T
set completeopt=longest,menu
:cd ~/code
nmap<C-A> ggvG
vmap<C-C> "*y
nmap<F3> : vs %<.in <CR>
nmap<F4> : !/home/jk/code/%< < !/home/jk/code/%<.in <CR>
nmap<F5> : vs %<.out <CR>
nmap<F8> :call Run()<CR>
nmap<F9> :call Compile()<CR>
map <F12> :!python3 %<CR>
func Compile()
exec "w"
if &filetype == "python"
exec "!python %"
elseif &filetype == 'cpp'
exec "!g++ % -o %< -std=c++17"
endif
endfunc
func Run()
exec "w"
if &filetype == 'java'
exec "!java -classpath %:h; %:t:r"
elseif &filetype == 'cpp'
exec "!/home/jk/code/%< "
endif
endfunc
if executable("vimtweak.dll")
autocmd guienter * call libcallnr("vimtweak","SetAlpha",210)
endif
autocmd BufNewFile *.cpp,*.[ch],*.sh,*.java,*.py exec ":call StTitle()"
func StTitle()
if &filetype == 'cpp'
call setline(1,"#include <bits/stdc++.h>")
call append(line("."), "")
call append(line(".")+1, "using namespace std;")
call append(line(".")+2, "using ll = long long;")
call append(line(".")+3, "")
call append(line(".")+4, "int main() {")
call append(line(".")+5, " ios::sync_with_stdio(false);")
call append(line(".")+6, " cin.tie(nullptr);")
call append(line(".")+7, "")
call append(line(".")+8, "")
call append(line(".")+9, "")
call append(line(".")+10, "")
call append(line(".")+11, "")
call append(line(".")+12, " return 0;")
call append(line(".")+13, "}")
elseif &filetype == 'python'
call setline(1,"import sys")
call append(line("."), "")
call append(line(".")+1, "I = lambda: [*map(int, sys.stdin.readline().split())]")
call append(line(".")+2, "")
call append(line(".")+3, "")
endif
endfunc