Is it possible to "define" a regular expression so that it remembered
(.vimrc?) and i can just refer to the name of the regexp rather than
type the whole thing, eg. something like:
define myregexp = '^ *[1-9][0-9]\{3}-[A-Z0-9\-]*\. *$'
and then in command line i just do:
:g/myregexp/s//something
Well, you can ":let" your regexp into a register (or variable),
and then use control+R to insert that register (or control+R
followed by "=" where you can type the name of the register).
Thus, in your vimrc, you'd have something like this
(untested...escaping may be off)
let @x = '^ \+[1-9][0-9]\{3}-[-A-Z0-9]*. \+$'
and then you can type
:%s/<control+R followed by "x">/something
or alternatively, if you put it in a named regexp:
let thing='^ \+[1-9][0-9]\{3}-[-A-Z0-9]*. \+$'
you can then use
:%s/<control+R, "=", "thing", enter>/something
(in both cases, the stuff in the "<...>" are instructions for
inserting the value you want).
The former method (using a register) is faster, but consumes one
of your named registers.
Another option would be to do something like
:cnoremap <f4> ^ \+[1-9][0-9]\{3}-[-A-Z0-9]*. \+$
(again, not 100% sure on the levels of escaping needed). This
would allow you to just hit <f4> and have it be typed for you.
Three different ways to do it, each with their own plusses and
minuses. :)
-tim