Skip to content

Instantly share code, notes, and snippets.

@maguroguma
Last active October 16, 2022 07:04
Show Gist options
  • Save maguroguma/322fb142eb2f1c8e4c1afe8ace89c119 to your computer and use it in GitHub Desktop.
Save maguroguma/322fb142eb2f1c8e4c1afe8ace89c119 to your computer and use it in GitHub Desktop.
https://github.com/soimort/translate-shell を用いて単語レベルでサクッと意味を調べたい時用の和英・英和のvim wrapper
if executable('trans')
function! s:printToTempBuffer(exe_command)
execute 'botright' 10 'new'
setlocal nobuflisted bufhidden=unload buftype=nofile
execute a:exe_command
norm gg
setlocal nomodified
endfunction
function! s:engToJapa(arg)
let l:com = 'read !trans en:ja -no-ansi ' . "'" . a:arg . "'"
call s:printToTempBuffer(l:com)
endfunction
function! s:japaToEng(arg)
let l:com = 'read !trans ja:en -no-ansi ' . "'" . a:arg . "'"
call s:printToTempBuffer(l:com)
endfunction
" 英和 - :Enja <english word>
command! -nargs=1 Enja :call s:engToJapa(<f-args>)
" 和英 - :Jaen <日本語の単語>
command! -nargs=1 Jaen :call s:japaToEng(<f-args>)
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment