Go to Japanese character

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Go to Japanese character

bob beckett-2
I have created a Japanese-English vocabulary list for my personal use.

Oftentimes I want to go to the first non-ASCII character in a line.

Can anyone suggest a way to accomplish this? Maybe a remapping?

Thanks

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Go to Japanese character

Eike Rathke-3
Hi bob,

On Thursday, 2015-11-19 11:20:26 -0800, bob beckett wrote:

> Oftentimes I want to go to the first non-ASCII character in a line.

/[^ -~]

Searches for a character not in the range from 0x20 space to 0x7E tilde.
Assuming you don't use control characters or 0x7F delete ;-)

  Eike

--
OpenPGP/GnuPG encrypted mail preferred in all private communication.
Key "ID" 0x65632D3A - 2265 D7F3 A7B0 95CC 3918  630B 6A6C D5B7 6563 2D3A
Better use 64-bit 0x6A6CD5B765632D3A here is why: https://evil32.com/
Care about Free Software, support the FSFE https://fsfe.org/support/?erack
Use LibreOffice! https://www.libreoffice.org/

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Go to Japanese character

bob beckett-2
In reply to this post by bob beckett-2
On Thursday, November 19, 2015 at 1:38:00 PM UTC-8, bob beckett wrote:
> I have created a Japanese-English vocabulary list for my personal use.
>
> Oftentimes I want to go to the first non-ASCII character in a line.
>
> Can anyone suggest a way to accomplish this? Maybe a remapping?
>
> Thanks

Sorry it took so long to reply.

Thank you for your suggestion. Unfortunately, it finds all non-ASCII characters in the entire file, and it does not move the cursor to the first Japanese (i.e. non-ASCII) character in the current line.

What I envisioned was some kind of modification of the f(ind) command. But I can't figure it out.

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Go to Japanese character

Random832
On 2015-11-23, bob beckett <[hidden email]> wrote:
> Thank you for your suggestion. Unfortunately, it finds all non-ASCII
> characters in the entire file, and it does not move the cursor to the first
> Japanese (i.e. non-ASCII) character in the current line.

And does what with them, highlights them? Also, It should move the cursor to
the next Japanese character after the cursor, whether it is on the current line
or not. If the highlighting is the only problem, you can run :nohls to clear
it.

Since even the original command was long enough that you would probably want to
put it in a mapping, this can easily be added:

nnoremap f<C-x> /[^ -~]<CR>:nohls<CR>

Obviously if there are none on the current line after the cursor it won't act
exactly like 'f', but it's not clear why you are trying to do this in that
case.

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Go to Japanese character

Charles E Campbell Jr
In reply to this post by bob beckett-2
bob beckett wrote:

> On Thursday, November 19, 2015 at 1:38:00 PM UTC-8, bob beckett wrote:
>> I have created a Japanese-English vocabulary list for my personal use.
>>
>> Oftentimes I want to go to the first non-ASCII character in a line.
>>
>> Can anyone suggest a way to accomplish this? Maybe a remapping?
>>
>> Thanks
> Sorry it took so long to reply.
>
> Thank you for your suggestion. Unfortunately, it finds all non-ASCII characters in the entire file, and it does not move the cursor to the first Japanese (i.e. non-ASCII) character in the current line.
>
> What I envisioned was some kind of modification of the f(ind) command. But I can't figure it out.
>
Modify Bob's suggestion:  /^[^ -~]  (ie. line beginning with non-ascii)

Or, if you're using utf-8:

/^[\u30A0-\u319f]     for katakana
/^[\u3040-\u309f]     for hiragana
[^[\u3040-\u319f]     for either katakana or hiragana (since they're
right next to one another in the utf-8 glyph table)

Regards,
Chip Campbell

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Go to Japanese character

Tony Mechelynck
On Mon, Nov 23, 2015 at 8:24 PM, Charles E Campbell
<[hidden email]> wrote:

> bob beckett wrote:
>> On Thursday, November 19, 2015 at 1:38:00 PM UTC-8, bob beckett wrote:
>>> I have created a Japanese-English vocabulary list for my personal use.
>>>
>>> Oftentimes I want to go to the first non-ASCII character in a line.
>>>
>>> Can anyone suggest a way to accomplish this? Maybe a remapping?
>>>
>>> Thanks
>> Sorry it took so long to reply.
>>
>> Thank you for your suggestion. Unfortunately, it finds all non-ASCII characters in the entire file, and it does not move the cursor to the first Japanese (i.e. non-ASCII) character in the current line.
>>
>> What I envisioned was some kind of modification of the f(ind) command. But I can't figure it out.
>>
> Modify Bob's suggestion:  /^[^ -~]  (ie. line beginning with non-ascii)
>
> Or, if you're using utf-8:
>
> /^[\u30A0-\u319f]     for katakana
> /^[\u3040-\u309f]     for hiragana
> [^[\u3040-\u319f]     for either katakana or hiragana (since they're
> right next to one another in the utf-8 glyph table)
>
> Regards,
> Chip Campbell

However, due to a limitation in Vim search (just slightly above 256
characters IIRC) it is not possible to search for just any character
anywhere in the whole kanji range — except by the above-mentioned
"anything but" method, which may give false positives. It is even
possible (if you use UTF-8) to exclude the whole of Latin1 (not just
7-bit us-ascii) by searching on
    /^[^\x01-\xff]
Or without the ^ outside the [ ] to find non-Latin1 characters even
when not at the start of a line. But you can't exclude much more than
that due to that Vim limitation.

Best regards,
Tony.

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Go to Japanese character

Benjamin R. Haskell-8
In reply to this post by bob beckett-2
On Mon, Nov 23, 2015 at 10:45 AM, bob beckett <[hidden email]> wrote:
On Thursday, November 19, 2015 at 1:38:00 PM UTC-8, bob beckett wrote:
> I have created a Japanese-English vocabulary list for my personal use.
>
> Oftentimes I want to go to the first non-ASCII character in a line.
>
> Can anyone suggest a way to accomplish this? Maybe a remapping?
>
> Thanks

Sorry it took so long to reply.

Thank you for your suggestion. Unfortunately, it finds all non-ASCII characters in the entire file, and it does not move the cursor to the first Japanese (i.e. non-ASCII) character in the current line.

What I envisioned was some kind of modification of the f(ind) command. But I can't figure it out.

The third parameter to the search function (`:h search()`) is the last line on which to consider a match, and it begins its search at the current cursor position.  So, the following should do what you want:

" ;; = jump to the first non-ASCII char past the cursor on the current line
nn <silent> ;; :cal search('[^\x20-\x7e]', '', line('.'))<CR>

" same thing, but slightly different concept of "ASCII char"
nn <silent> ;; :cal search('[^\x00-\xFF]', '', line('.'))<CR>

It also has the advantage of not messing with the `@/` register (hence no need for `:nohls`).

-- 
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Go to Japanese character

bob beckett-2
In reply to this post by bob beckett-2
On Thursday, November 19, 2015 at 1:38:00 PM UTC-8, bob beckett wrote:
> I have created a Japanese-English vocabulary list for my personal use.
>
> Oftentimes I want to go to the first non-ASCII character in a line.
>
> Can anyone suggest a way to accomplish this? Maybe a remapping?
>
> Thanks

Ben

Your suggestion works perfectly. Thanks a lot.

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.