Friday, December 28, 2018

Re: repeat insert characters until end of line or getting the last col in a buffer?

On 2018-12-28 12:14, tony wrote:
> Is there a way to insert a repeat of characters to the width of a
> buffer?

It may depend on how you determine the width of the buffer.

You might mean your 'textwidth' setting, or you might mean your
terminal's (or gvim-window's) $COLUMNS setting.

> But if the repeat count is the terminal buffer width, is there a
> quick way to determine that or a variable of the last column?

There's not a quick-to-easily-type way, but you can do the math once
and then create a mapping to do the rest for you, or do them all in
one go:

:%s/$/\=repeat('X', &tw?&tw-strlen(getline('.')):&columns-strlen(getline('.')))

(this appends the character "X"). It assumes that if you have a
'textwidth' set, you want to use that; if you have it unset, it uses
your terminal-width as stored in 'columns'

-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.
For more options, visit https://groups.google.com/d/optout.

No comments: