Hi Wallace,
I am not aware of any shortcut key that would move cursor to the last
character (ignoring whitespace) at the end of the line.
As for the macro, here it is. It basically does regex find/replace on
current file:
Option Strict Off
Option Explicit Off
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports EnvDTE90a
Imports EnvDTE100
Imports System.Diagnostics
Public Module UtilityMacros
Sub RemoveWhitespaceAtEndOfLines()
DTE.Find.PatternSyntax =
vsFindPatternSyntax.vsFindPatternSyntaxRegExpr
DTE.Find.Action = vsFindAction.vsFindActionReplaceAll
DTE.Find.FindWhat = ":b+$"
DTE.Find.ReplaceWith = ""
DTE.Find.Target = vsFindTarget.vsFindTargetCurrentDocument
DTE.Find.MatchCase = False
DTE.Find.MatchWholeWord = False
DTE.Find.MatchInHiddenText = False
DTE.Find.ResultsLocation = vsFindResultsLocation.vsFindResultsNone
If (DTE.Find.Execute() = vsFindResult.vsFindResultNotFound) Then
DTE.StatusBar.Text = "Not found any trailing whitespaces"
Else
DTE.StatusBar.Text = "Removed all trailing whitespaces"
End If
End Sub
End Module
On 29 June 2012 12:02, Wallace Turner <[email protected]> wrote:
> Jano,
> Initially i thought you mean the trailing whitespace at the *end* of the
> file, and thought that was seriously OCD (which is a feature in my books!)
>
> however re-reading I now know what you mean and YES it bothers me all the
> time... in fact, can you please send me your macro?
>
> Is the main annoyance that when you press the 'End' key the cursor doesnt
> go the end of the text, rather than the end of the line? If yes, is there a
> shortcut key that goes to the last character on the line? (in VS, not vi
> please) :)
>
> Wal
>
>
> On 29/06/2012 5:55 PM, Jano Petras wrote:
>
> Well, I do have one usage of macros - to strip off trailing whitespace
> from all lines in a code file. I have mapped it to Ctrl-W and using it all
> the time.
>
> Is there a built-in command that can do this now? If not, I will be
> affected, and will need to do something about it.
>
> Are any of you guys using something similar to perform this? Or hanging
> whitespace at the end of lines does not bother you ?
>
>
> Cheers,
> jano
>
>
> On 28 June 2012 08:56, Arjang Assadi <[email protected]> wrote:
>
>> FYI Evryone who uses macros, they are gone from VS 11 since less than 1%
>> of people were using them:
>>
>> http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/d8410838-085b-4647-8c42-e31b669c9f11/
>>
>> But as one of the posts pointed out they were being used by super users
>> that most likely would turn off the usage data gathering features.
>>
>> Regards
>>
>> Arjang
>>
>
>
>
>