Loading ...
Sorry, an error occurred while loading the content.

RE: Chinese dictionary tool

Expand Messages
  • Bill West
    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
    Message 1 of 3 , Jan 30, 2006
    • 0 Attachment
      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@...]
      Sent: Friday, January 27, 2006 8:49 PM
      To: A. J. Mechelynck
      Cc: Bill West; vim@...
      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
    Your message has been successfully submitted and would be delivered to recipients shortly.