Figure 1 -- It's hard to tell if your highlighted text includes an unwanted training space. |
This issue is especially nefarious when it comes to troubleshooting: a typical visual check won't catch text that includes a trailing space versus the expected value (no trailing space).
What to do? Windows' clipboard is simply performing the one simple task it was created to do. We can't make the Windows clipboard smarter but we can substitute in a smarter option...
The Sneaky Trailing Space: Hard to Spot
Even in a serious admin tool like SQL Server Management Studio trailing spaces can't be detected from simply looking at read-only results. You either need to craft a SQL query to filter for results with trailing spaces (this is probably the best way) or view a table in edit mode and highlight each value to see which value exhibits a bit of extra highlighting following the text.
Figure 2 shows a database read-only view and an edit view for the same table. It's apparent how trailing spaces can easily go undetected.
Figure 2: SQL Server Management Studio -- Can you spot the trailing space? Even with "Manager" selected the highlighted trailing space is not overly apparent. |
Figure 3: DNN Security Role Names Trailing spaces are allowed (?!?) |
What's the Fix?
Ok, point made: trailing spaces are bad and Windows' copy-and-paste feature (i.e., the clipboard) does nothing to help me avoid them. Fortunately we are not required to stick with the default clipboard. Enter the Outertech Clipboard Manager. Like most other 3rd party clipboard alternatives the Clipboard Manager saves multiple recent copies -- your 20 most recent copies, in fact. Unlike most other clipboard alternatives, though, Clipboard Manager also provides the option to automatically trim trailing spaces. Aha!
Figure 4: The Outertech Clipboard Manager (free) allows you to automatically remove trailing spaces in your copy-and-paste operations. |
To be fair there are two downsides to this free tool. First, this clipboard alternative only works for text-based content. That means you're still stuck with CTRL-V for pasting images. The second downside is that you need to get used to using a different key for pasting. On the other hand, the program allows you to pick your own key combination so you do have options (except for overriding the default CTRL-V paste command -- Windows won't let you reassign that).
One excellent feature is the ability to define permanent ("sticky") clips. That is, besides your 20 most recent copied items, you can also predefine up to 20 more items that are always ready to be pasted. You can also have the program remove any carriage returns / line breaks from copied links that span multiple lines. Those of you who have been confounded by this in the past know what I'm talking about. The rest of you have just been lucky.
Summary
Switching to a trailing-space-trimming-clipboard-tool still won't solve the trailing space issue as it won't address trailing spaces added from other people/systems. It will, however, help *you* to avoid being responsible for propagating unwanted trailing spaces.
No comments:
Post a Comment