Tuesday, September 21, 2010

Re: to or till (f or t) a non-ascii character

On Wed, 22 Sep 2010, Ramana Kumar wrote:

> I have set up some abbreviations to turn certain ASCII strings into
> appropriate Unicode counterparts, for example from '==>' to '=>'. This
> works wonderfully.

From equals, equals, greater-than, to equals, greater-than? Must be
something about the web interface.


> One problem, however, is when I now have a Unicode character sitting
> in my buffer, I can't jump to it easily using the insert-mode 't' and
> 'f' commands. Is there any way I could do this? The best for me would
> be if I could do a 't=' and have it count occurrences of '=>' among
> the things to jump to, since I originally typed '=' to get that
> character.

Personally, I find external-to-Vim methods for entering Unicode
characters to be much better. For example, in order to get what I think
your arrow is (=>) in all X11 programs (including Vim under a terminal
emulator and Gvim), by typing <Compose> + <equal> + <equal> +
<greater-than> (where <Compose> = <CapsLock>), I can add this line to
~/.XCompose:

<equal> <equal> <greater> : =>

Granted, it's less portable (in terms of non-X11 environments), and can
be a pain to set up initially, but it's worth the effort if you find
yourself using non-keyboard characters frequently.

Just wanted to mention the option. In case it's not practical, keep
reading.


> A related but different issue is getting those characters into the
> command line buffer, for example if I want to search for a a string
> containing Unicode characters. My abbreviations won't work in that
> buffer... is there a way to get them to work?

If you use :abbrev, rather than :iabbrev, they'll work in command-line
mode, too. (Doesn't help for 't'/'f')


> Or what about yanking/putting text between the main buffer and the
> command buffer?

You might try 'q:'. For the longest time, I found it incredibly
annoying when I would mistype my preferred 'quit' mechanism and end up
in this bizarre 'Ex' mode. But now I use it all the time.

:help q:

If you want one of your special characters in that command-line, you can
navigate to it, and there are at least two quick ways to yank the
character under the cursor.

1) type 'vy' (no quotes) [ == enter visual mode, yank the current visual
selection of one character ]

or 2) 'yl' [ == yank + {motion} where {motion} is from the cursor to one
character to the right of the cursor, excluding that character ].

Then in the 'q:' window, you can 'p' (for 'put') it.

I can't quite figure out a way to use => with 't'. But, perhaps the next
best thing (depending on your use-case) is the '*' search. If you
navigate to put the cursor above the => through other means
(word/sentence/paragraph movement), you can easily get to the next one
by pressing asterisk above it.

--
Best,
Ben

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment