horizontal range, kindof

56 views
Skip to first unread message

BPJ

unread,
Jun 27, 2016, 7:12:47 AM6/27/16
to vim...@googlegroups.com
I'm trying to do a substitution in a 'horizontal/virtual column range'.

I have an ASCII table where the columns are separated by tab
characters (for now). I want to wrap the contents (which contain
space (U+0020) and \S characters, being of unequal length of
course!) of some specific table columns in asterisks (think
Markdown emphasis). I thought I could use a range and \%v to
match the text between two screen virtual columns and then use an
expression with substitute() to wrap instances of \T\+
inside the matched screen column range, something like

'a,'b s/\%13v.*\%46v/\=substitute(submatch(0),'\T\+','*&*','g')/

but apparently I've misunderstood \%v because I get no match.
So what is the right way to do this? I'm not looking forward to
changing three columns on some 70 lines manually!

/bpj

Tumbler Terrall

unread,
Jun 27, 2016, 11:52:44 AM6/27/16
to vim_use, b...@melroch.se

What are you trying to match with "\T"? Because as far as I can tell that
matches the letter "t". If you're looking to match tabs, that would be "\t".
The case does make a difference.

BPJ

unread,
Jun 28, 2016, 6:11:42 AM6/28/16
to Tumbler Terrall, vim_use

Mind the reply to!

It was intended to  match anything but a tab, but I see now that that escape isn't supported by Vim. Anyway I ended up writing an external filter in Perl, since the needed steps turned out to be somewhat more complicated than I first thought: I needed to leave some Pandoc footnote marks outside the emphasis.

Jacky Liu

unread,
Jun 28, 2016, 7:57:59 AM6/28/16
to vim_use, kingdom...@gmail.com, b...@melroch.se
a backslash inside a pair of single quotes represents a backslash, literally. Look into usr_41.txt and search for "single quote".

:echo '\t' == "\t"

would results in 0, which means False.

If you want a tab character you would have to put \t in double quotes.





Gary Johnson

unread,
Jun 28, 2016, 12:10:05 PM6/28/16
to vim_use
On 2016-06-28, BPJ wrote:

> It was intended to  match anything but a tab, but I see now that that escape
> isn't supported by Vim.

This will match any character but a tab:

[^\t]

Regards,
Gary

Charles E Campbell

unread,
Jan 30, 2017, 8:48:36 PM1/30/17
to vim...@googlegroups.com
You might be able to make use of vis.vim
(http://www.drchip.org/astronaut/vim/index.html#VIS) where you define a
region using visual-block mode (ctrl-v, move) and a :B command.

You might find Christian Brabandt's nrrwregion plugin of use (search for
it on http://vim.sf.net).

Regards,
Chip Campbell
Reply all
Reply to author
Forward
0 new messages