Motions in visual(line|block)

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Motions in visual(line|block)

Max Dyckhoff
I've noticed that using some motions - specifically "i{" and suchlike -
will cancel a visual line/block and turn it into regular visual mode
instead, which is rather annoying. Is this intentional, or a bug?

I should just mention that my new favourite command is "=a{", which
makes me smile every time I use it, and which really annoys my Visual
Studio using colleagues.

Chairs!
--
Max Dyckhoff
AI Engineer
Bungie Studios

Reply | Threaded
Open this post in threaded view
|

Re: Motions in visual(line|block)

Bram Moolenaar

Max Dyckhoff wrote:

> I've noticed that using some motions - specifically "i{" and suchlike -
> will cancel a visual line/block and turn it into regular visual mode
> instead, which is rather annoying. Is this intentional, or a bug?

"i{" is not a motion command but an object selection command.  It
changes both the start and end of the selection.  This mostly also
requires a characterwise selection.  You could use "[{" for a similar
motion command.

> I should just mention that my new favourite command is "=a{", which
> makes me smile every time I use it, and which really annoys my Visual
> Studio using colleagues.

Enjoy!

--
A)bort, R)etry, P)lease don't bother me again

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
Reply | Threaded
Open this post in threaded view
|

Re: Motions in visual(line|block)

Scott LaBounty
In reply to this post by Max Dyckhoff
Max,

OK, I'll bite. What does "=a{" do? The "=" is a format, and the "{"
moves to the start of a class (at least that's what is does in the ruby
file I tested this on). So, what's the "a" do in this command? Lord
knows, anything that annoys my Visual Studio colleagues is all right
with me.

Scott LaBounty
Nexa Technologies, Inc.

Max Dyckhoff wrote:

> I've noticed that using some motions - specifically "i{" and suchlike -
> will cancel a visual line/block and turn it into regular visual mode
> instead, which is rather annoying. Is this intentional, or a bug?
>
> I should just mention that my new favourite command is "=a{", which
> makes me smile every time I use it, and which really annoys my Visual
> Studio using colleagues.
>
> Chairs!
> --
> Max Dyckhoff
> AI Engineer
> Bungie Studios
>
>
>
>  

Reply | Threaded
Open this post in threaded view
|

Re: Motions in visual(line|block)

Stewart Johnson-2
I didn't know either, but from my testing it seems to do something like:

"move to the start of the current scope and format (indent) everything
in the current scope."

at least that's what it seems to do for me. ;-)

On 7/14/06, Scott LaBounty <[hidden email]> wrote:

> Max,
>
> OK, I'll bite. What does "=a{" do? The "=" is a format, and the "{"
> moves to the start of a class (at least that's what is does in the ruby
> file I tested this on). So, what's the "a" do in this command? Lord
> knows, anything that annoys my Visual Studio colleagues is all right
> with me.
>
> Scott LaBounty
> Nexa Technologies, Inc.
>
> Max Dyckhoff wrote:
> > I've noticed that using some motions - specifically "i{" and suchlike -
> > will cancel a visual line/block and turn it into regular visual mode
> > instead, which is rather annoying. Is this intentional, or a bug?
> >
> > I should just mention that my new favourite command is "=a{", which
> > makes me smile every time I use it, and which really annoys my Visual
> > Studio using colleagues.
> >
> > Chairs!
> > --
> > Max Dyckhoff
> > AI Engineer
> > Bungie Studios
> >
> >
> >
> >
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Motions in visual(line|block)

Scott LaBounty
Stewart,

It looked like it was supposed to do something like that, but nothing
seemed to happen with my Ruby file. I'll give it a shot in a C++ file
and see what happens there. I still can't figure out what the "a" is
doing though.

Scott

Stewart Johnson wrote:

> I didn't know either, but from my testing it seems to do something like:
>
> "move to the start of the current scope and format (indent) everything
> in the current scope."
>
> at least that's what it seems to do for me. ;-)
>
> On 7/14/06, Scott LaBounty <[hidden email]> wrote:
>> Max,
>>
>> OK, I'll bite. What does "=a{" do? The "=" is a format, and the "{"
>> moves to the start of a class (at least that's what is does in the ruby
>> file I tested this on). So, what's the "a" do in this command? Lord
>> knows, anything that annoys my Visual Studio colleagues is all right
>> with me.
>>
>> Scott LaBounty
>> Nexa Technologies, Inc.
>>
>> Max Dyckhoff wrote:
>> > I've noticed that using some motions - specifically "i{" and
>> suchlike -
>> > will cancel a visual line/block and turn it into regular visual mode
>> > instead, which is rather annoying. Is this intentional, or a bug?
>> >
>> > I should just mention that my new favourite command is "=a{", which
>> > makes me smile every time I use it, and which really annoys my Visual
>> > Studio using colleagues.
>> >
>> > Chairs!
>> > --
>> > Max Dyckhoff
>> > AI Engineer
>> > Bungie Studios
>> >
>> >
>> >
>> >
>>
>>
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Motions in visual(line|block)

Matthew Winn
In reply to this post by Scott LaBounty
On Fri, Jul 14, 2006 at 06:48:57AM -0700, Scott LaBounty wrote:
> OK, I'll bite. What does "=a{" do? The "=" is a format, and the "{"
> moves to the start of a class (at least that's what is does in the ruby
> file I tested this on). So, what's the "a" do in this command?

"a{" selects the nearest {...} block to the cursor.  You can see the
effect if you type "va{".

> Lord knows, anything that annoys my Visual Studio colleagues is all right
> with me.

Leaning over their shoulders while they're coding and saying "you could
do that in three lines with Perl" often does the trick.  Or you could
watch them for a while and then say "Oh, you use the cursor keys when
editing. How ... quaint."

Giggling every time you walk past them works too.

--
Matthew Winn ([hidden email])
Reply | Threaded
Open this post in threaded view
|

Re: Motions in visual(line|block)

Scott LaBounty
Matthew,

Got it. I was just looking at motion.txt (which I should have done in
the first place) and just found that section. Amazing, I've been using
vi/vim for ~20 years and there's still tons of stuff to find.

I like the "How ... quaint". If fact, I'm off to try it now!

Scott

Matthew Winn wrote:

> On Fri, Jul 14, 2006 at 06:48:57AM -0700, Scott LaBounty wrote:
>  
>> OK, I'll bite. What does "=a{" do? The "=" is a format, and the "{"
>> moves to the start of a class (at least that's what is does in the ruby
>> file I tested this on). So, what's the "a" do in this command?
>>    
>
> "a{" selects the nearest {...} block to the cursor.  You can see the
> effect if you type "va{".
>
>  
>> Lord knows, anything that annoys my Visual Studio colleagues is all right
>> with me.
>>    
>
> Leaning over their shoulders while they're coding and saying "you could
> do that in three lines with Perl" often does the trick.  Or you could
> watch them for a while and then say "Oh, you use the cursor keys when
> editing. How ... quaint."
>
> Giggling every time you walk past them works too.
>
>  

Reply | Threaded
Open this post in threaded view
|

RE: Motions in visual(line|block)

Max Dyckhoff
In reply to this post by Scott LaBounty
Bram: thank you for your explanation, I still have a lot to learn about
different terminology in vim. Every time I learn something new like
this, a whole avenue of new ways to work opens up, which really excites
me.

Scott: As someone else mentioned, it basically formats the current scope
(including the opening and closing braces). Often when I am writing code
I manage to break the auto indenting (missing brackets at the end of
conditionals, etc) and rather than going around and indenting each line
correctly I just write the code in a poorly formatted way and then do
=a{ at the end to clean it all up.

Things like a( work as well. I have no idea what Ruby syntax is like,
but if scope isn't marked by {} then it won't work! :)

My manager (also an AI Engineer) regularly gets annoyed when he is
watching me write some code and I manage to do things in vi ridiculously
fast. It seems like I'm even managing to convert some other people here
to using it; I was approached by another engineer last week and asked if
I thought vim would increase his productivity. Needless to say I said
yes immediately.

Max

> -----Original Message-----
> From: Scott LaBounty [mailto:[hidden email]]
> Sent: Friday, July 14, 2006 6:49 AM
> To: [hidden email]
> Subject: Re: Motions in visual(line|block)
>
> Max,
>
> OK, I'll bite. What does "=a{" do? The "=" is a format, and the "{"
> moves to the start of a class (at least that's what is does in the
ruby
> file I tested this on). So, what's the "a" do in this command? Lord
> knows, anything that annoys my Visual Studio colleagues is all right
> with me.
>
> Scott LaBounty
> Nexa Technologies, Inc.
>
> Max Dyckhoff wrote:
> > I've noticed that using some motions - specifically "i{" and
suchlike -
> > will cancel a visual line/block and turn it into regular visual mode
> > instead, which is rather annoying. Is this intentional, or a bug?
> >
> > I should just mention that my new favourite command is "=a{", which
> > makes me smile every time I use it, and which really annoys my
Visual

> > Studio using colleagues.
> >
> > Chairs!
> > --
> > Max Dyckhoff
> > AI Engineer
> > Bungie Studios
> >
> >
> >
> >

Reply | Threaded
Open this post in threaded view
|

Re: Motions in visual(line|block)

Karl Guertin
On 7/14/06, Max Dyckhoff <[hidden email]> wrote:
> I was approached by another engineer last week and asked if
> I thought vim would increase his productivity. Needless to say I said
> yes immediately.

I find that the key advantage of using vim is not necessarily the
speed with which you edit, but the reduction in mental noise when
working. You spend less time moving a cursor around and more time
focusing on coding, which is the entire point. My personal favorite
command is ct"
Reply | Threaded
Open this post in threaded view
|

RE: Motions in visual(line|block)

Max Dyckhoff
I am a fan of "ct*" as well, my only problem being having to count how
many occurrences of a letter there are until the one I want. I typically
will just do a single "ct*" and then repeat it with ".".

What I find more useful is "ci{" and "da{", given that I will often
yank/put a full function somewhere and just want to change a small
portion of the name and all the body, or write a function somewhere and
then cut/put it in the correct file and also a copy in the header file,
before deleting the body to just leave the declaration.

I agree though, it is massively wonderful not to have to use the mouse
or repeated pageup/arrow keys to position the cursor where I want to
write code. I generally just think where I want the cursor, and a couple
of button presses later it is there. The main thing which speeds me up
is the auto-insert stuff though, things like <C-X><C-L> and then a quick
modification of a part of the line in question.

Go vim!

Max


> -----Original Message-----
> From: Karl Guertin [mailto:[hidden email]]
> Sent: Friday, July 14, 2006 11:37 AM
> To: Max Dyckhoff
> Cc: [hidden email]
> Subject: Re: Motions in visual(line|block)
>
> On 7/14/06, Max Dyckhoff <[hidden email]> wrote:
> > I was approached by another engineer last week and asked if
> > I thought vim would increase his productivity. Needless to say I
said
> > yes immediately.
>
> I find that the key advantage of using vim is not necessarily the
> speed with which you edit, but the reduction in mental noise when
> working. You spend less time moving a cursor around and more time
> focusing on coding, which is the entire point. My personal favorite
> command is ct"
Reply | Threaded
Open this post in threaded view
|

Re: Motions in visual(line|block)

A.J.Mechelynck
In reply to this post by Scott LaBounty
Scott LaBounty wrote:
> Stewart,
>
> It looked like it was supposed to do something like that, but nothing
> seemed to happen with my Ruby file. I'll give it a shot in a C++ file
> and see what happens there. I still can't figure out what the "a" is
> doing though.
>
> Scott
[...]

The "a" is the English article "a / an" where the "i" is the adjective
"inner". Both apply to object selection commands. So =a{ is "format a
{-block" while i{ is "select inner {-block". Similarly for daw (delete a
word), ciW (change inner WORD), etc. The difference with "a" and "i" is
that the former includes the whitespace on one side of the object, the
latter doesn't.

See ":help objects".


Best regards,
Tony.
Reply | Threaded
Open this post in threaded view
|

Re: Motions in visual(line|block)

A.J.Mechelynck
In reply to this post by Matthew Winn
Matthew Winn wrote:

> On Fri, Jul 14, 2006 at 06:48:57AM -0700, Scott LaBounty wrote:
>> OK, I'll bite. What does "=a{" do? The "=" is a format, and the "{"
>> moves to the start of a class (at least that's what is does in the ruby
>> file I tested this on). So, what's the "a" do in this command?
>
> "a{" selects the nearest {...} block to the cursor.  You can see the
> effect if you type "va{".
>
>> Lord knows, anything that annoys my Visual Studio colleagues is all right
>> with me.
>
> Leaning over their shoulders while they're coding and saying "you could
> do that in three lines with Perl" often does the trick.  Or you could
> watch them for a while and then say "Oh, you use the cursor keys when
> editing. How ... quaint."
>
> Giggling every time you walk past them works too.
>

I use the cursor keys quite a lot in Vim myself. But I hardly ever touch
the mouse there. So I'd suggest s/cursor keys/mouse/ :-)


Best regards,
Tony.