Topic: Delete Word macros (1 of 3), Read 34 times, 2 File Attachments
Conf: VEDIT Macro Library
From: Walt Pattinson
Date: Monday, August 15, 2005 06:51 PM

I wanted a different function of DEL_NEXT_WORD and DEL_PREV_WORD, and thanks to Christian, I created the following macros.

The DEL_NEXT_WORD macro will
1) delete word starting at the cursor forward
2) Select following whitespace (using WORD_SEP chars)
3) Stop deleting at EOL (EOL is deleted separately)
4) If currently in whitespace, only deletes the whitespace.

DEL_PREV_WORD is of course the reverse, removing WS then the word.

 
Delete Previous Word
  Delete Next Word

 


Topic: Delete Word macros (2 of 3), Read 30 times
Conf: VEDIT Macro Library
From: Christian Ziemski
Date: Tuesday, August 16, 2005 04:47 PM


On 8/15/2005 6:51:55 PM, Walt Pattinson wrote:
>I wanted a different function of DEL_NEXT_WORD and DEL_PREV_WORD
>I created the following macros

Nice ones! Easier to understand than my version...

One tip:

In DELPWORD.VDM you wrote

char(-1)
....
if (At_Eol) // If already at EOL reached, delete and stop
{
char(-1) // 2 chars
del_char(2)
Return
}


This way you are jumping between the CR and LF at EoL. And then you delete both bytes.
That may work in DOS-Format text files with CR/LF but will fail e.g. in UNIX-Format text files with only a LF.

You should try to use the value of "Newline_Chars" to determine the number of chars in a "newline" (See also in chapter "File Types").

And you should try to avoid jumping in between a CR/LF. It often leads to strange errors (tested by myself ;-)
Better work with if(At_BoL) a bit earlier here instead of first doing a char(-1) and then a if(At_EOL).

Christian

 


Topic: Delete Word macros (3 of 3), Read 29 times
Conf: VEDIT Macro Library
From: Walt Pattinson
Date: Wednesday, August 17, 2005 06:28 PM

>>I wanted a different function of DEL_NEXT_WORD and DEL_PREV_WORD
>>I created the following macros
>
>Nice ones! Easier to understand than my
>version...

Thanks

>
>One tip:
>
>In DELPWORD.VDM you wrote
>char(-1)
>....
>if (At_Eol) // If already at EOL
>reached, delete and stop
>{
> char(-1) // 2 chars
> del_char(2)
> Return
>}
>
>This way you are jumping between the CR
>and LF at EoL. And then you delete both
>bytes.
>That may work in DOS-Format text files
>with CR/LF but will fail e.g. in
>UNIX-Format text files with only a LF.

Yep. I couldn't figure out how to tell the composition of the EOL.

>You should try to use the value of
>"Newline_Chars" to determine the number
>of chars in a "newline" (See also in
>chapter "File Types").

Ahhh, thanks. Not enough digging into the help system I guess.

>And you should try to avoid jumping in
>between a CR/LF. It often leads to
>strange errors (tested by myself ;-)
>Better work with if(At_BoL) a bit
>earlier here instead of first doing a
>char(-1) and then a if(At_EOL).

Makes sense. Thanks for the tip.

Walt