Wednesday, November 3, 2021

Re: Control-V :w : how to write single character?

On 2021-11-03 12:36, L A Walsh wrote:
> I wanted to write out an unclear character that my
> cursor was over, so I tried to go into character VISUAL
> selection mode by pressing Ctl-v, then ':w! /tmp/ch'.
> Instead of the single character at the cursor, I got
> the whole line. I also tried with a lower case 'v'.

The ex ":w" command is linewise, regardless of what visual-mode you
were in, so you'll get the whole line.

> How would I write out only the 1 character I had selected?

You might try yanking it and then using the writefile() command

:help writefile()

to write that register out to a file:

:call writefile(@", '/tmp/ch', 'b')

As a further alternative, you might investigate the "ga" &
"g8" commands

:help g8
:help ga

which will tell you further information about the particular
character under the cursor.

Hope this helps,

-tim








--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20211103145444.47507a56%40bigbox.attlocal.net.

No comments:

Post a Comment