Lyle
Lyle

Reputation: 119

How to call vim script in C language

what's my goal:

i want a program to get session.vim and viminfo.info file for each file being edited by vim, and scp these file to another pc, then i can continue the work on another pc.

problems:

Here is my solution, but it doesn't work, maybe you get a better solution, i need your help.

kill all vim process, and get session.vim and viminfo.info for each file. in my C code:

system(kill -9 pid);//pid is the pid of vim process.

in my .vimrc file:

autocmd VimEnter * let s:this_session='.'.expand('%:t').'.vim'
autocmd VimLeave * if v:dying | call Somefunc() | endif
function! Somefunc()
    silent! wa
    execute 'mksession! '.fnameescape(s:this_session)
endfunction

it does not work.

do i make myself clear? i'm not good at english.

i'd be very grateful for any help.

Upvotes: 0

Views: 145

Answers (1)

Ingo Karkat
Ingo Karkat

Reputation: 172768

man kill says this:

SIGKILL 9 kill (cannot be caught or ignored)

With the -9 argument, Vim (as well as any other process) has no chance to react to the signal; the process will be forcibly terminated. Try sending the default SIGTERM (15) by omitting the -9 argument. See here for more information.

Upvotes: 1

Related Questions