DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Vim Script For Dict.org
let g:curl_exe = "/usr/local/bin/curl"
let g:dict_url = "http://www.dict.org/bin/Dict?Form=Dict1\&Query="
let g:dict_query = "\&Strategy=*\&Database=*"
function! GetDictOrgEntries(term)
let cmd = g:curl_exe . " -s -f -S '" . g:dict_url . a:term . g:dict_query . "'"
let result = split(system(cmd), '\n')
split [DictionaryResults]
set modifiable
set noreadonly
call append(0, result)
1,/<hr>/d
%s/<\/\?[^>]\+>//g
call append(0, [ "===============================================",
\ "Dictionary Results from http://www.dict.org",
\ "===============================================",
\ "" ])
if search('\d\+ definitions found', 'n') != 0
%s/\s\+:/:/g
%s/\(\d\+\)\s\+definitions\_.\{-}for\s\+\(\w\+\)/\1 definitions found for "\2"/
g/\d\+ definitions found for/t.|s/./-/g
g/^-\+$/t.|s/^.*$//
g/^From\s\+/t.|s/./-/g
g/\d\+\s\+Moby\s\+Thesaurus/ /^\s*$/,$d
1,6center 60
1
elseif search('No definitions found', 'n') != 0
g/No definitions found/ /^\s*$/,$d
1,$center 60
endif
syntax match DictOrgTitleEqual /=\+/
syntax match DictOrgTitle /.*www.dict.org/
syntax match DictOrgUnderline /-\+/
syntax match DictOrgFromLine /^From\s\+.*/
syntax match DictOrgNumberFound /\d\+\ze definitions found for/
syntax match DictOrgDefinitionsFoundFor /\d\+ \zsdefinitions found for/
syntax match DictOrgTerm /\d\+ definitions found for \zs".*"/
highlight link DictOrgTitleEqual PreProc
highlight link DictOrgUnderline DictOrgTitleEqual
highlight link DictOrgTitle Type
highlight link DictOrgFromLine Type
highlight link DictOrgNumberFound Constant
highlight link DictOrgDefinitionsFoundFor Comment
highlight link DictOrgTerm String
set nomodified
set nomodifiable
set readonly
endfunction
command! -nargs=1 DictLookup call GetDictOrgEntries("<args>")
nmap <C-k> :call GetDictOrgEntries(expand("<cword>"))<CR>





