Post reply

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.
Name:
Email:
Subject:
Message icon:

Verification:
Type the letters shown in the picture
Listen to the letters / Request another image

Type the letters shown in the picture:
What is the last letter in the word "SlickEdit":
How many LETTERS are in the following? "a1b2c3":
Which number is missing?  "12345689":

shortcuts: hit alt+s to submit/post or alt+p to preview


Topic Summary

Posted by: Graeme
« on: April 20, 2022, 10:53:55 AM »

Maybe the select all problem is because the cursor is at the end of the file.  Try adding a begin_select() call at the start to move the cursor to the start of the selection.

On my machine, a line containing only a comment doesn't actually get deleted - but the comment does get deleted, leaving a blank line.  I'm using Windows 11.

If the // is immediately preceded by a non whitespace character the comment doesn't get deleted  - I don't know why this is.  Also it doesn't seem to allow for // in a string.

I have a couple of suggestions.  If I record a macro to search for any character (search string is set to . and reg expression enabled) and select colour coding of "comment" it finds the start of the next comment - if it's not already in a comment.  If I record a macro doing this I get the following

_command last_recorded_macro() name_info(','VSARG2_MACRO|VSARG2_MARK|VSARG2_REQUIRES_EDITORCTL)
{
   _macro('R',1);
   if (find('.',"LIPCC,,")) stop();
}

The search function you're using can also search for comments.

There's also a macro you can call to tell if the cursor is in a comment
_in_comment()
and it can distinguish between block comment and line comment.
I notice that Ctrl Z undo manages to undo all changes in one go with your current method.  If you change to some manually looping code, Ctrl Z might undo one by one - I don't know.
Posted by: kniped1
« on: April 19, 2022, 07:01:14 PM »

This macro removes all line comments (//) from the selected text. If the line is only a comment, it removes the entire line.

On a side note, in my current implementation of this macro, it works when I manually select a block of text, but it doesn't seem to work when I use select all. Does anyone know why that might be?