Skip to content

Instantly share code, notes, and snippets.

@miyakogi
Last active June 17, 2016 15:23
Show Gist options
  • Save miyakogi/28b16449b90fdf11d36e815ac7724ad4 to your computer and use it in GitHub Desktop.
Save miyakogi/28b16449b90fdf11d36e815ac7724ad4 to your computer and use it in GitHub Desktop.
function! s:tm(timer) abort
" 何か時間のかかる処理
for i in range(1000)
let a = 1
endfor
if job_status(get(s:, 'job')) !=# 'run'
call timer_stop(a:timer)
endif
endfunction
let s:options = {
\ 'out_mode': 'raw',
\ 'err_mode': 'raw',
\ 'out_io': 'buffer',
\ 'err_io': 'buffer',
\ 'out_name': 'output',
\ 'err_name': 'output',
\ }
function! Job() abort
let s:job = job_start(['python', 'job.py'], s:options)
" 環境によっては3msだと短すぎてVimが応答しなくなるかもなので調整して下さい
call timer_start(3, function('s:tm'), {'repeat': -1})
endfunction
for _ in range(10000):
print('.', end='', flush=True)
vim a.vim
:so %
:call Job()
:buffer output
改行がたくさん入っていてつらいので連結
ggVGgJ
@h-east
Copy link

h-east commented Jun 17, 2016

「手順」の最後 ggVGgJ:%j! でも可です。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment