Friday, January 28, 2011

Re: Indpendant position marks for scripts ?

Ben Schmidt <mail_ben_schmidt@yahoo.com.au> [11-01-29 06:24]:
> On 29/01/11 3:42 PM, meino.cramer@gmx.de wrote:
> >
> >Hi,
> >
> >I want to process a text with script.
> >The text contains of two regions:
> >The first region contains of lines beginning with keyword_a
> >and the second one start with keyword_b.
> >I want to sort the first region using sort with pattern_a and
> >after that I want to sort the second region with pattern_b.
> >
> >I can set the start of the forst sort with
> >
> > : /keyword_a
> >
> >in the script. But I dont know how to limit the range of the first
> >sort so that only lines starting with keyword_a are sorted using
> >pattern_a. Same goes for the second region...
>
> Try something like
>
> :0/^a/,/^\(a\)\@!/sort
>
> It means loosely:
>
> : - perform an ex command
> 0 - from before the beginning of the file
> /^keyword_a/ - find a line beginning with 'keyword_a'
> , - and operate until
> / - we find
> ^ - the beginning of a line
> \(keyword_a\)\@! - where 'keyword_a' doesn't match
> /sort - with the sort command
>
> Ben.
>
>
>
> --
> 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
>

Hi Ben,

GREAT! Thanks a lot! That helps me much!

Best regards,
mcc

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

Re: Indpendant position marks for scripts ?

On 29/01/11 3:42 PM, meino.cramer@gmx.de wrote:
>
> Hi,
>
> I want to process a text with script.
> The text contains of two regions:
> The first region contains of lines beginning with keyword_a
> and the second one start with keyword_b.
> I want to sort the first region using sort with pattern_a and
> after that I want to sort the second region with pattern_b.
>
> I can set the start of the forst sort with
>
> : /keyword_a
>
> in the script. But I dont know how to limit the range of the first
> sort so that only lines starting with keyword_a are sorted using
> pattern_a. Same goes for the second region...

Try something like

:0/^a/,/^\(a\)\@!/sort

It means loosely:

: - perform an ex command
0 - from before the beginning of the file
/^keyword_a/ - find a line beginning with 'keyword_a'
, - and operate until
/ - we find
^ - the beginning of a line
\(keyword_a\)\@! - where 'keyword_a' doesn't match
/sort - with the sort command

Ben.

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

Indpendant position marks for scripts ?

Hi,

I want to process a text with script.
The text contains of two regions:
The first region contains of lines beginning with keyword_a
and the second one start with keyword_b.
I want to sort the first region using sort with pattern_a and
after that I want to sort the second region with pattern_b.

I can set the start of the forst sort with

: /keyword_a

in the script. But I dont know how to limit the range of the first
sort so that only lines starting with keyword_a are sorted using
pattern_a. Same goes for the second region...


Best regards and thank you very much for any help in advance!
Have a nice weekend!
mcc

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

Re: Typing numbers

> [*] you can add more than one character, so if you wanted, you could
> get fancy with something like
>
> 40i-=<esc>
>
> to get a nice row of 80 characters like "-=-=-=-...=-=-=-=" but again you then
> have to do the math and divide down. Not grievous, but I can count the real-world
> times I've done that on one hand.

Or you can start taking down a receipt number without pushing i, as I
did last week. I typed 1011 before realising it hadn't appeared on the
screen. So then I pushed i and typed the whole 13-digit number, and when
I hit <Esc> I got 1011 copies of it, all running together as I had typed
no spaces or newlines or anything. Brilliant! There's 12 KB right there!

Was that too off-topic?

Ben.

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

Re: Typing numbers

On Fri, Jan 28, 2011 at 11:12:10PM EST, Ben Schmidt wrote:

> Hehe. Since we're sharing...If I were fixing 'rememberiing', I probably
> would have done:
>
> /ii<Enter>x
>
> No need to count, and no need to watch what I'm doing to know when to
> stop repeatedly pushing something either. I do this a lot. If I see an
> error on the screen, I just use / to quickly jump to it, or at least to
> something 'unique' in its near vicinity,

Yeah.. that's why I love sticking those pseudo-ellipses all over my
prose.

> and then fix it. Sometimes I don't type enough to get me straight
> there, and need an n or two, but that still tends to be quicker for me
> than moving around by repeating other movement keys. YMMV.

Hehe.. That's the problem about giving examples just to make a point:
contrary to f/F/t/T, that I really don't like all that much.. I use
/string a lot to move the cursor around the buffer.. Especially since
it's a standard mechanism with many other applications.. so now you
mention it.. that's more often than not what I would normally do..

Spoilsport.. :-)

cj

P.S. Not to mention that I would in most cases not even have noticed the
typo in the first place and spellchecking would have had to take care of
it for me..

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

Re: Typing numbers

On 01/28/2011 09:53 PM, Chris Jones wrote:
> On Fri, Jan 28, 2011 at 05:35:02PM EST, Tim Chase wrote:
>> This breaks when using t/T with ";" to repeat the motion as it just finds
>> the same one you just found. I have to break down and count for those :)
>
> Another reason why I don't use t/T (and don't care much for f/F either).

Eh, for the most part, the t/T/f/F work much like my brain on the
matter: "go forward to character X".. The only gotcha is
repeated attempt to use t/T with ";". With f/F it works fine.

> There's only so much can fit under my skull.

I can sympathize -- there are corners I rarely touch and see crop
occasionally to think "that would be really useful if I could
remember it at the times I need it" (the recent attempt was
learning the bash "!" expansions...poof, gone)

> 'i''s.. What would I really gain by counting 1, 2, 3.. it's the 3rd 'i'

Yeah, I'll often fall back do using f/F and then moving back one
character or reinserting whatever character I removed by
overshooting.

>> 80I-<esc>
>
> I vaguely remembered that there was a better way
[snip]
> One nice touch about the above sequence and makes it really elegant is
> the upper case 'I' because you can type it regardless of where the
> cursor is located on the current line: after you hit<Esc>, the cursor
> sits on the last of your inserted dashes, which means that you just need
> to type 'a' to switch to insert mode with the cursor on the first
> character following the last dash and 'Enter' to separate your line of
> dashes and the previous contents of the line and move down any ensuing
> text.

it works with i, I, gI, a, and A...on a blank line, it doesn't
make a difference as they all behave the same, inserting [count]
characters[*] at the defined location and leaving the cursor at
the end. With pre-existing content and leading whitespace, there
are subtle differences. However they all make sense depending on
what you want to do.

-tim

[*] you can add more than one character, so if you wanted, you
could get fancy with something like

40i-=<esc>

to get a nice row of 80 characters like "-=-=-=-...=-=-=-=" but
again you then have to do the math and divide down. Not
grievous, but I can count the real-world times I've done that on
one hand.


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

Re: Typing numbers

> There's only so much can fit under my skull.. and I prefer to stick with
> a limited subset of keyboard actions that may not be the quickest and
> most efficient for all occasions.. but that I can use without hesitation
> or incurring any overhead rememberiing. Namely that if the cursor is at
> the beginning of the line above and I want to get to the '..ii..' typo
> in 'rememberiing.', I find it considerably more effective when all is
> told to just hit 'w' till I get to the beginning of the word
> 'rememberiing'.. and either hit llll.. or hit 'e' to get to the end of
> the word and then 'hh' followed by 'x' to delete the last of the two
> 'i''s.. What would I really gain by counting 1, 2, 3.. it's the 3rd 'i'
> I want to remove.. or wait a minute.. is it the second..? Huh..
>
> Now I'm aware that I could also jump to the next sentence and work
> backward.. and there are probably other ways to get to that extra 'i' in
> fewer keystrokes than my clumsy approach, but all in all, I much prefer
> sticking to wwww.. or eeee.. and occasionally bbb.. etc. because it
> would take me longer to produce the 'find the third i' or 'jump to next
> sentence' key sequence than typing three or four (five or six..) 'w''s
> in succession.

Hehe. Since we're sharing...If I were fixing 'rememberiing', I probably
would have done:

/ii<Enter>x

No need to count, and no need to watch what I'm doing to know when to
stop repeatedly pushing something either. I do this a lot. If I see an
error on the screen, I just use / to quickly jump to it, or at least to
something 'unique' in its near vicinity, and then fix it. Sometimes I
don't type enough to get me straight there, and need an n or two, but
that still tends to be quicker for me than moving around by repeating
other movement keys. YMMV.

Ben.

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