Translate-shell.vim is a plugin for translating text without leaving Vim. It provides a window that displays the translate of word under cursor, selected text or you can use "on fly" translation and translate inserted text. Also, you can save your translate story to file and import it to Anki.
FZF functions:
The following features are supported by translate-shell.vim:
The following requirements have to be met in order to be able to use translate-shell.vim:
If you would like to use FZF functions that provided by this plugin, you have to install FZF. You can find installation instruction here.
You can install translate-shell.vim by using any vim plugin manager.
If you doesn't have installed translate-shell in path, you can install plugin by the following command:
Plug 'echuraev/translate-shell.vim', { 'do': 'wget -O ~/.vim/trans git.io/trans && chmod +x ~/.vim/trans' }
And after it you should specify path to translate-shell by defining
g:trans_bin
variable e.g:
let g:trans_bin = "~/.vim"
If you already have installed translate-shell in your PATH then it is enough to install plugin by the following command:
Plug 'echuraev/translate-shell.vim'
Translate-shell.vim provides the following commands for translation:
:Trans [{options}]
- Translate word under cursor.:'<,'>Trans [{options}]
- Translate text in visual selection.:TransSelectDirection
- Translate word under cursor with selecting translate
direction.:'<,'>TransSelectDirection
- Translate text in visual selection with
selecting translate direction.:TransInteractive [{options}]
- Translate inserted text.:TransTerm [{options}]
- Open terminal with interactive translate-shell.
That works only in Vim 8.:TransOpenHistoryWindow
- Open file with translate history.:TransChangeDefaultDirection
- Change default direction of translating for a
session.FZF functions:
:FZFTransSelectDirection
- Translate word under cursor with selecting translate
direction.:'<,'>FZFTransSelectDirection
- Translate text in visual selection with
selecting translate direction.:FZFTransInteractive
- Translate inserted text.:FZFTransChangeDefaultDirection
- Change default direction of translating
for a session.For more convenience, you can create key mapping for these commands e.g:
inoremap <silent> <leader>t <ESC>:Trans<CR>
nnoremap <silent> <leader>t :Trans<CR>
vnoremap <silent> <leader>t :Trans<CR>
nnoremap <silent> <leader>td :TransSelectDirection<CR>
vnoremap <silent> <leader>td :TransSelectDirection<CR>
Codes of languages you can find here or run the following command:
trans -R
For more information please look at doc/trans.txt or open Vim and run :h trans
.
You can add history of your translation to Anki and learn new words. Full information you can find on wiki.
Egor Churaev egor.churaev@gmail.com