My Opera is closing 3rd of March
photo of Yunt

云一样的梦…

只是当时已惘然

Subscribe to RSS feed

Vim中使用Stardict

今天看到有人用emacs配合sdcv(stardict CLI版)写了个在其中查词的功能,
效果不错,因为不用emacs,所以就写了个在vim中使用的!
gvim下的挺完美的,因为vim里没有calltip的功能所以只能分割窗口了……
具体如下:

在~/.gvimrc中加入这些:
function Mybln()
    let expl=system('sdcv -n ' .
          \ v:beval_text .
          \ '|fmt -cstw 40')
    return expl
  endfunction

  set bexpr=Mybln()
  set beval

效果如下,鼠标放在单词上显示!

在~/.vimrc中加入这些:
function! Mydict()
  let expl=system('sdcv -n ' .
        \  expand("<cword>"))
  windo if
        \ expand("%")=="diCt-tmp" |
        \ q!|endif
  25vsp diCt-tmp
  setlocal buftype=nofile bufhidden=hide noswapfile
  1s/^/\=expl/
  1
endfunction
nmap F :call Mydict()<CR>

在单词上使用Shift+f ,效果: