horizontal range, kindof

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
BPJ
Reply | Threaded
Open this post in threaded view
|

horizontal range, kindof

BPJ
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

--
--
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: horizontal range, kindof

Tumbler Terrall
On Monday, June 27, 2016 at 6:12:47 AM UTC-5, BPJ wrote:

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

--
--
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.
BPJ
Reply | Threaded
Open this post in threaded view
|

Re: horizontal range, kindof

BPJ

Mind the reply to!
Den 27 jun 2016 17:53 skrev "Tumbler Terrall" <[hidden email]>:
>
> On Monday, June 27, 2016 at 6:12:47 AM UTC-5, BPJ wrote:
> > 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
>
> 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.

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.

--
--
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: horizontal range, kindof

Jacky Liu
On Tuesday, June 28, 2016 at 6:11:42 PM UTC+8, BPJ wrote:

> Mind the reply to!
>
> Den 27 jun 2016 17:53 skrev "Tumbler Terrall" <[hidden email]>:
>
> >
>
> > On Monday, June 27, 2016 at 6:12:47 AM UTC-5, BPJ wrote:
>
> > > 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
>
> >
>
> > 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.
>
> 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.

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.





--
--
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: horizontal range, kindof

Gary Johnson-4
In reply to this post by BPJ
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

--
--
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: horizontal range, kindof

Charles E Campbell Jr
In reply to this post by BPJ
BPJ wrote:

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

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