Re: one input to many lines

2006-05-03 Thread Tim Chase

Thanks a lot Tim. You is right about what I meant. To make it more clear,
here are the rows.
.
.
i1 0 9 180   /*this is the 420 line number*/
.
i2 0 17.1 220   /*430*/
.
i3 + 7.875 365 /*710*/

the numbers in question are 180, 220 and 365.
No tested your code yet. I'll give a try tomorrow.

[cut some of the bottom posting]

where [action] is

s/\%4c\d\+/=submatch(0)+10/e


It looks like your columns are delimiter-based (using 
whitespace), rather than columns based on physical/character 
position.  That would change the previously-mentioned 
[action] so that it becomes something like


s/^\(\S\+\s\+\)\{3\}\zs\(\d\+\)/=submatch(2)+10/e

You might have to tweak it a bit, but it *should* do the trick.

If you want some help deciphering it, it's easy enough to 
explain any of the process, if you'd like.


-tim

PS:  Your reply came only to me.  It's best to Reply to 
All in your mailer so that the whole list gets copied in on 
the reply.  That way, you access the collective brain which 
is a whole lot smarter than my solitary brain.  You also 
have their time.  Fortunately, I check my email fairly 
regularly, but in the event I was on holiday, you'd be 
waiting for just me rather than getting a reply from anybody 
on the list that had an answer.








one input to many lines

2006-05-02 Thread marcelo
Hi. My name is Marcelo I'm new in this list and in VIM. My question is about
one input to many lines and columns in just one render (evaluation,
returns ...) For example, if i have a table of numbers and need add 10 for
the forth columns in the 420, 530 and 710 lines. Could you point any script,
code, theme to read,...
Thanks in advance,
Marcelo



Re: one input to many lines

2006-05-02 Thread Tim Chase

Hi. My name is Marcelo I'm new in this list and in VIM.


Welcome!


My question is about one input to many lines and
columns in just one render (evaluation, returns ...) For
example, if i have a table of numbers and need add 10 for
 the forth columns in the 420, 530 and 710 lines. Could
you point any script, code, theme to read,...


I'm not sure I fully understand what you're getting at here, 
but I'll give a try (your English is a heckuva lot better 
than my Portugese).


It sounds like you want to add 10 to either

-numbers on each row of a file, where those numbers are 
found at columns 420, 530, and 710


or

-numbers found in column 4 of a table, but only make the 
changes on certain line numbers


I *think* you mean the second rather than the first 
interpretation.  You also don't specify whether they're 
character-columns (in which case, adding 10 could bump the 
number up to an additional column), if they're positional 
columns (such as column #4 starts at character 21 in the 
line), or delimited columns (such as with a CSV file).


My first thought would be (totally untested)

:g/./if '420,430,710'=~'\'.line(.).'\'| [action] |endif

where [action] is

s/\%4c\d\+/=submatch(0)+10/e

This *should* do [action] on each of the lines in the 
comma-separated list.  An ugly hack, but it looks like it 
should work.


As for the [action], this is where it would need 
clarification regarding what defines a column.


Some sample data of the rows in question might help sort out 
that matter.


Hope this helps.  If you have further questions, feel free 
to ask.


-tim