Saturday, November 28, 2015

Re: Go to Japanese character

On Mon, Nov 23, 2015 at 10:45 AM, bob beckett <sealbeam01@gmail.com> 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 vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment