knowledge-database (beta)

Current group: comp.editors

How to bind certain -input- in VIM

How to bind certain -input- in VIM  
Mitzfar at hotmail.com
 Re: How to bind certain -input- in VIM  
Mitzfar at hotmail.com
 Re: How to bind certain -input- in VIM  
Shawn Corey
 Re: How to bind certain -input- in VIM  
Mitzfar at hotmail.com
 Re: How to bind certain -input- in VIM  
Shawn Corey
 Re: How to bind certain -input- in VIM  
Christian Prior
 Re: How to bind certain -input- in VIM  
Mitzfar at hotmail.com
From:Mitzfar at hotmail.com
Subject:How to bind certain -input- in VIM
Date:1 Jan 2005 12:57:27 -0800
Hi,

I am using Vim as a tool for programming with g++ .
What I would like to do is the following, suppose you are writing a
function

void
Foo(int gnam)
{
//Lots of amazing stuff here :)
}


And because of -some- reason, you decide to change the variable gnam,
then you will have to change every occurrence of this variable gnam
throughout
the entire function.

One can be smart and use something like :%s/gnam/mang/g or something to
that effect
but what I would like is that gnam is allready associated with every
local occurrence of it throughout the entire function.
So that if I was going to the function heading, Foo(int gnam) and if I
would change gnam manually over there, that automatically all the other
variables -gnam-, locally within Foo, are changed as well.
Anybody a brilliant idea, pointers as how to pull this off ?

Regards.
From:Mitzfar at hotmail.com
Subject:Re: How to bind certain -input- in VIM
Date:1 Jan 2005 14:25:19 -0800
Yes indeed that is a way to do it,
but it is not what I meant .
I really mean some script that entails when changing the formal
parameters of
a certain function, that also all of it's use throughout that function
will be modified as well.
Again, you gave a good solution but I was looking for something more
advanced than that. :)

Thank you very much for your reply.

Regards.
From:Shawn Corey
Subject:Re: How to bind certain -input- in VIM
Date:Sun, 02 Jan 2005 08:55:44 -0500
What you are describing is a macro. See:
:help map
You can set them up in your resource file so they will be available
every time you start vim. See:
:help vimrc

--- Shawn

Mitzfar@hotmail.com wrote:
> Yes indeed that is a way to do it,
> but it is not what I meant .
> I really mean some script that entails when changing the formal
> parameters of
> a certain function, that also all of it's use throughout that function
> will be modified as well.
> Again, you gave a good solution but I was looking for something more
> advanced than that. :)
>
> Thank you very much for your reply.
>
> Regards.
>
From:Mitzfar at hotmail.com
Subject:Re: How to bind certain -input- in VIM
Date:2 Jan 2005 09:27:29 -0800
Hi Shawn,

Thank you for your reply, however even though I am a bit familiar with
'map'
I don't see how I can use it for my problem.
The closest solution I have encountered to solve my problem is
abbreviations. If there was a way for me to customize them to function
only
locally within a C++ function, that would be a nice step forward I
guess.

Regards.
From:Shawn Corey
Subject:Re: How to bind certain -input- in VIM
Date:Sun, 02 Jan 2005 12:59:51 -0500
Then perhaps what you want is a filter. See:
:help filter
:help !
This let's you send one or more lines from Vim to a separate program.
This program reads the lines from stdin and writes to stdout. Vim
replaces the lines with the output.

I have a filter called sub (I work in Perl) which takes a subroutine
prototype and creates a standard header for it. For example:

$success = foobar( $a, $b, $c );

becomes:

# --------------------------------------
# $success = foobar( $a, $b, $c );
# TBD
sub foobar($$$){
my $a = shift @_;
my $b = shift @_;
my $c = shift @_;
my $success = '';

return $success;
}



--- Shawn

Mitzfar@hotmail.com wrote:
> Hi Shawn,
>
> Thank you for your reply, however even though I am a bit familiar with
> 'map'
> I don't see how I can use it for my problem.
> The closest solution I have encountered to solve my problem is
> abbreviations. If there was a way for me to customize them to function
> only
> locally within a C++ function, that would be a nice step forward I
> guess.
>
> Regards.
>
From:Christian Prior
Subject:Re: How to bind certain -input- in VIM
Date:1 Jan 2005 21:49:06 GMT
Mitzfar@hotmail.com schrieb:
> So that if I was going to the function heading, Foo(int gnam) and if I
> would change gnam manually over there, that automatically all the other
> variables -gnam-, locally within Foo, are changed as well.

Just mark the whole function in visual mode first, then :s...?


--
Christian Prior
http://christianprior.de
From:Mitzfar at hotmail.com
Subject:Re: How to bind certain -input- in VIM
Date:4 Jan 2005 22:45:56 -0800
Wow, that is really cool.

I could use something like that for my header files.

Yet, even though with some manipulation like that, I guess it will get
the
job done, but it is not exactly like --binding-- variables with one
and another. I will most certainly look closer into that matter to
applicate it to
my needs.

Thank you very much.
   

Copyright © 2006 knowledge-database   -   All rights reserved