Skip to main content
edited tags
Link
Friedrich
  • 3.3k
  • 1
  • 13
  • 26
added 2 characters in body; edited tags
Source Link
Vivian De Smedt
  • 21.1k
  • 5
  • 22
  • 40

How do I use parameters within a self definedcustom command?

I want to define a global search and replace with confirmation command, something like:

command Gfr :s/<parameter1>/<parameter2>/gc

So I can type:

:Gfr foo bar

and vimVim will find all occurrences of 'foo' in the document and ask for each whether I want to replace it with 'bar'.

Googling has led me to some tantalising hints that this is possible, but no definitive answer.

How do I use parameters within a self defined command?

I want to define a global search and replace with confirmation command, something like

command Gfr :s/<parameter1>/<parameter2>/gc

So I can type

:Gfr foo bar

and vim will find all occurrences of 'foo' in the document and ask for each whether I want to replace it with 'bar'.

Googling has led me to some tantalising hints that this is possible, but no definitive answer.

How do I use parameters within a custom command?

I want to define a global search and replace with confirmation command, something like:

command Gfr :s/<parameter1>/<parameter2>/gc

So I can type:

:Gfr foo bar

and Vim will find all occurrences of 'foo' in the document and ask for each whether I want to replace it with 'bar'.

Googling has led me to some tantalising hints that this is possible, but no definitive answer.

Source Link

How do I use parameters within a self defined command?

I want to define a global search and replace with confirmation command, something like

command Gfr :s/<parameter1>/<parameter2>/gc

So I can type

:Gfr foo bar

and vim will find all occurrences of 'foo' in the document and ask for each whether I want to replace it with 'bar'.

Googling has led me to some tantalising hints that this is possible, but no definitive answer.