Skip navigation.

Log in | Sign up

photo of Yunt

云一样的梦…

只是当时已惘然

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 ,效果:

计算圆周率(π)心情不好时做这25件事

Comments

Anonymous 21. June 2006, 06:51

Anonymous writes:

是你自已写的?

yunt 21. June 2006, 08:02

哦,不,我是在hq00e那里得到的帮助!!

Anonymous 21. November 2006, 15:44

Anonymous writes:

哈,效果很不错啊,这个应该是Linux下实现的吧,Windows下可以吗?

PS:非常郁闷,宿舍的朋友都习惯了吃饭时用PPLive看新闻,所以不能安装Linux,不知道Linux下有没有PPLive这样的软件?

yunt 30. November 2006, 03:39

Anonymous 3. December 2006, 04:27

lerosua writes:

博主你好/ 你这个技巧很好/ 之前我也调用过sdcv, 不过不会打开新窗口。
这功能值得推广。所以我想在我博客上引用你这篇文章。特此通知。谢谢!
我的博客地址 http://my.donews.com/lerosua

interma 23. January 2007, 15:43

奥,真不错~

How to use Quote function:

  1. Select some text
  2. Click on the Quote link

Write a comment

Comment
(BBcode and HTML is turned off for anonymous user comments.)

If you can't read the words, press the small reload icon.


Smilies