Home

Awesome

cfparser.vim

A codeforces helper plugin for vim, ported from emacs plugin gnull/cfparser.

Installation

Plug 'gabrielsimoes/cfparser.vim'

Optional setup

You can setup some variables at your .vimrc:

let g:cf_pl_by_ext_custom = {'.cpp': "42"}
function! cfparser#CFTestAll()
    echo system(printf("g++ %s -o /tmp/cfparser_exec;
                        \cnt=0;
                        \for i in `ls %s/*.in | sed 's/\\.in$//'`; do
                        \   let cnt++;
                        \   echo \"\nTEST $cnt\";
                        \   /tmp/cfparser_exec < $i.in | diff -y - $i.out;
                        \done;
                        \rm /tmp/cfparser_exec",
        \ expand('%:p'), expand('%:p:h')))
endfunction

This will compile the file with g++ and test it against 0.in and 0.out, 1.in and 1.out, etc...

function! cfparser#CFRun()
    echo system(printf("g++ %s -o /tmp/cfparser_exec", expand('%s:p')))
    RunInInteractiveShell /tmp/cfparser_exec
    call system("rm /tmp/cfparser_exec")
endfunction

This will compile the file with g++ and run it with the command RunInteractiveShell, which is provided by the following plugin: christoomey/vim-run-interactive.

Usage

When using the submit, download sample tests and problem statement functions, cfparser will "guess" the contest number, problem index and the programming language by the current file name. It should be in one of the following forms: (it could be any extension besides .cpp)