[prev in list] [next in list] [prev in thread] [next in thread]
List: vim
Subject: RE: Chinese dictionary tool
From: "Bill West" <wjwest () CLEMSON ! EDU>
Date: 2006-01-30 21:41:20
Message-ID: 008d01c625e5$f5b11700$4f0e7f82 () DGWQ9X51
[Download RAW message or body]
Thanks Tony and Gerald for your replies!
In the off chance that anyone might find this useful, here is the solution I
came up with.
The first function greps all of the words in the dictionary that _start
with_ the copied characters.
The second function greps all of the words that _contain_ the copied
characters.
--Bill
fun! Findzi()
exec(':grep " ' . @x . '" e:/cedict/cedict_ts.u8')
if v:shell_error == 0
bp
copen
exe ":normal \<c-w>w"
endif
endfun
fun! Findanyzi()
exec(':grep ' . @x . ' e:/cedict/cedict_ts.u8')
if v:shell_error == 0
bp
copen
exe ":normal \<c-w>w"
endif
endfun
:map <F6> <Esc>:normal "xyl<CR>
:map <F2> <Esc>:normal 2"xyl<CR>
:map <F3> <Esc>:normal 3"xyl<CR>
:map <F4> <Esc>:normal 4"xyl<CR>
:map <F5> <Esc>:normal 5"xyl<CR>
:map <F7> <Esc> <c-w>w
:map <F8> <Esc>:w<CR>:call Findzi()<CR><CR>
:map <F9> <Esc>:w<CR>:call Findanyzi()<CR><CR>
-----Original Message-----
From: Gerald Lai [mailto:laige@eecs.oregonstate.edu]
Sent: Friday, January 27, 2006 8:49 PM
To: A. J. Mechelynck
Cc: Bill West; vim@vim.org
Subject: Re: Chinese dictionary tool
On Fri, 27 Jan 2006, A. J. Mechelynck wrote:
> Bill West wrote:
[snip]
>> First, how do I grab the character under the cursor. Even better,
>> how do I grab the character before the cursor, under the cursor, and
>> immediately following the cursor.
>
> After ":normal yl" you get the character under the cursor into the
> unnamed register, which can then be accessed with the "variable name" @"
> (or sometimes @@). You can use any other register of your choice, e.g.
> after ':normal "xyl' you see the character under the cursor in @x
>
> If you move the cursor first, the above method grabs the character at
> the new cursor location, e.g., ":normal 5hyl" grabs the 5th character
> before the cursor (if there is one). Similarly, ":normal y3l" grabs
> (IIUC) the three characters starting at the cursor.
[snip]
Another way of doing it (without involving registers) is the following.
Echo character under cursor
:echo getline(".")[col(".") - 1]
Echo characters before, under & after cursor
:echo strpart(getline("."), col(".") - 2, 3)
Hope this helps.
--
Gerald
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic