SlickEdit Community

SlickEdit Product Discussion => SlickEdit® => Topic started by: dbbd on September 21, 2010, 02:18:18 pm

Title: highlighting trailing spaces
Post by: dbbd on September 21, 2010, 02:18:18 pm
I'd like to highlight trailing spaces (use some color different from background for all spaces before end of line)

I cannot figure out how to do that with slick.
(I'm an old emacs user)

Title: Re: highlighting trailing spaces
Post by: ScottW, VP of Dev on September 21, 2010, 03:04:39 pm
No, I don't think we have an option for that. Is there some reason you are keeping trailing spaces around? Why not just delete them? There is an option under File  Options > Save to "Strip trailing spaces".
Title: Re: highlighting trailing spaces
Post by: dbbd on September 21, 2010, 08:42:41 pm
I'm working on an existing code base with hundreds of thousands of lines.
I do not want to create huge diffs since the version control is a dinosaur (clearcase) and people are upset when I create full file diffs.
I'd like to manually fix only areas I work on anyway, so highlighting trailing spaces is very helpful.
In emacs I use a regexp to do that. I tried to use the symbol highlighting in slick, and added a regexp,
but seems it does not really work that way.

How about a general purpose regexp highlighting feature, that can be used for various ad-hoc purposes?
kind of a semi-permanent search pattern?

Title: Re: highlighting trailing spaces
Post by: David_O on September 21, 2010, 09:07:40 pm
Try Ctrl+F to bring up the Find tab of the Find and Replace tool window.  Put

   [ \t]*$

in the Search for text box.  Pick whatever is appropriate for your needs in the Look in box.  In the Search options section of the tab, click Use and pick 'Regular Expression (UNIX)'.  Also click on the Highlight all matches options box.

You could also do this from the command line with the following:

  /[ \t]*$/U*#

Let us know if this does not give you what you need.

Title: Re: highlighting trailing spaces
Post by: chrisant on September 22, 2010, 09:56:53 am
You might be interested in this macro (  It strips trailing whitespace only from modified lines on save.

SlickEdit tends to leave trailing whitespace on edited lines (an example is if you split a line just after whitespace), and it doesn't have a way to highlight trailing whitespace.  This appears to be because a lot of people work in small teams with code bases that are fully under their control, and configure their editors to always trim trailing whitespace.  Of course that is extremely problematic in large teams or diverse code bases, but the only other option in SlickEdit is to never strip, but since the only way SlickEdit manages trailing whitespace is unilaterally at save via an option (but not dynamically while editing) it ends up meaning that SlickEdit adds to the trailing whitespace pollution.


Another editor I use has _before_command_ and _after_command_ hooks, which enabled me to write a macro in that editor to dynamically strip trailing whitespace as I edit, and only in the lines I've edited.

SlickEdit does not have these hooks, so the closest thing I was able to achieve in SlickEdit was the macro above.  It's not ideal, but it is a good enough solution that I don't whine much about it.  :)  Those two hooks sure would be handy, though.  The first thing I would do is port a macro (written by me, no copyright issues) that automatically fixes the indentation of the current line after the cursor moves off of it, if the line was edited.
Title: Re: highlighting trailing spaces
Post by: dbbd on September 26, 2010, 07:36:54 am
Thanks for all the answers.

What I ended up doing, is change the symbol coloring background of space (without enabling symbol coloring), and enable view->spaces.
Now all my spaces a a bit darker than regular background (I use a similar trick for tabs in Makefiles).