-
Notifications
You must be signed in to change notification settings - Fork 64
/
Add_Remove-RemarkedText.ps1
117 lines (58 loc) · 1.91 KB
/
Add_Remove-RemarkedText.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
Function Add-RemarkedText
{
<#
.Synopsis
This function will add a remark # character to beginning of line
.Description
This function will add a remark character # to selected text in the ISE.
These are comment characters, and is great when you want to comment out
a section of PowerShell code.
.Example
Add-RemarkedText
adds the comment / remark character to beginning of each selected line
.Notes
NAME: Add-RemarkedText
AUTHOR: ed wilson, msft
LASTEDIT: 05/16/2013
KEYWORDS: Windows PowerShell ISE, Scripting Techniques
HSG: wes-5-18-13
.Link
Http://www.ScriptingGuys.com
#Requires -Version 2.0
#>
$text = $psISE.CurrentFile.editor.selectedText
foreach ($l in $text -split [environment]::newline)
{
$newText += "{0}{1}" -f ("#" + $l),[environment]::newline
}
$psISE.CurrentFile.Editor.InsertText($newText)
} #End function add-remarkedtext
Function Remove-RemarkedText
{
<#
.Synopsis
This function will remove a remark # character to beginning of line
.Description
This function will remove a remark character # to selected text in the ISE.
These are comment characters, and is great when you want to clean up a
previously commentted out section of PowerShell code.
.Example
Remove-RemarkedText
Removes the comment / remark character to beginning of each selected line
.Notes
NAME: Add-RemarkedText
AUTHOR: ed wilson, msft
LASTEDIT: 05/16/2013
KEYWORDS: Windows PowerShell ISE, Scripting Techniques
HSG: wes-5-18-13
.Link
Http://www.ScriptingGuys.com
#Requires -Version 2.0
#>
$text = $psISE.CurrentFile.editor.selectedText
foreach ($l in $text -split [environment]::newline)
{
$newText += "{0}{1}" -f ($l -replace '#',''),[environment]::newline
}
$psISE.CurrentFile.Editor.InsertText($newText)
} #End function remove-remarkedtext