Quick fix to add "+="

Bernhard Reiter bernhard at alpha1.csd.uwm.edu
Sat Apr 17 00:57:37 EDT 1999


Your editor is your friend:

Just use a macro in your favorite editor, which grabs the left
word of the curser postion and expands it into
	<word>=<word>+
Trigger the macro with "+=" and you type excactly what you
always type, just the result is more python like.

For vim, the following does the trick (without the special word matching caps
new vim versions provide. the ":noh is for people using hlsearch in 
vim 5.x version.)


:map!^[:s/\([a-zA-Z_][a-zA-Z0-9_]*\)$/\1=\1+/^M:noh^MA

	Bernhard


On Fri, 16 Apr 1999 22:12:48 -0400, Fuming Wang <fmwang at mediaone.net> wrote:
>I have searched dejanews. They don't like the "+=" characters. Could you
>be more specific about how to modify the interpreter? I desperate
>here.:)

>Blake Winton wrote:
>> On Fri, 16 Apr 1999 17:26:44 -0400, Fuming Wang <fmwang at mediaone.net> wrote:
>> >Any one knows a quick fix to add "+=" function. I am really getting
>> >tired of typing long names twice.
>> 
>> += has been left out of the language for a good reason, and thus it's
>> probably not likely that there's an easy way to add it.  I think you
>> will have to recompile the interpreter to get it to do what you want,
>> and even then, I don't think that you really want what it would do.




More information about the Python-list mailing list