You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Tries to find a text editor based on the PSEditor preference variable, the EDITOR environment variable, or your configuration for git. As a fallback it searches for Sublime, Notepad++, or Atom, and finally falls back to Notepad.
43
+
# Tries to find a text editor based on the PSEditor preference variable, the EDITOR environment variable, or your configuration for git.
44
+
# As a fallback it searches for Sublime, VSCode, Atom, or Notepad++, and finally falls back to Notepad.
36
45
#
37
-
# I have deliberately excluded PowerShell_ISE because it is a single-instance app which doesn't support "wait" if it's already running. That is, if PowerShell_ISE is already running, issuing a command like this will return immediately:
46
+
# I have deliberately excluded PowerShell_ISE because it is a single-instance app which doesn't support "wait" if it's already running.
47
+
# That is, if PowerShell_ISE is already running, issuing a command like this will return immediately:
38
48
#
39
49
# Start-Process PowerShell_ISE $Profile -Wait
40
50
[CmdletBinding()]
@@ -44,32 +54,38 @@ function Find-Editor {
44
54
# Defaults to the value of $PSEditor.Command or $PSEditor or Env:Editor if any of them are set.
Creates and edits functions (or scripts) in the session in a script editor.
163
-
180
+
Opens folders, files, or functions in your favorite code editor (configurable)
164
181
165
182
.DESCRIPTION
166
-
The Edit-Function command lets you create or edit functions in your session in your favorite text editor.
183
+
The Edit-Code command lets you open a folder, a file, or even a script function from your session in your favorite text editor.
167
184
168
185
It opens the specified function in the editor that you specify, and when you finish editing the function and close the editor, the script updates the function in your session with the new function code.
169
186
170
-
Functions are tricky to edit, because most code editors require a file, and determine syntax highlighting based on the extension of that file. Edit-Function creates a temporary file with the function code.
187
+
Functions are tricky to edit, because most code editors require a file, and determine syntax highlighting based on the extension of that file. Edit-Code creates a temporary file with the function code.
171
188
172
189
If you have a favorite editor, you can use the Editor parameter to specify it once, and the script will save it as your preference. If you don't specify an editor, it tries to determine an editor using the PSEditor preference variable, the EDITOR environment variable, or your configuration for git. As a fallback it searches for Sublime, and finally falls back to Notepad.
173
190
174
191
REMEMBER: Because functions are specific to a session, your function edits are lost when you close the session unless you save them in a permanent file, such as your Windows PowerShell profile.
175
192
176
193
.EXAMPLE
177
-
Edit-Function Prompt
194
+
Edit-Code Prompt
178
195
179
196
Opens the prompt function in a default editor (gitpad, Sublime, Notepad, whatever)
180
197
181
198
.EXAMPLE
182
-
dir Function:\cd* | Edit-Function -Editor "C:\Program Files\Sublime Text 3\subl.exe" -Param "-n -w"
199
+
dir Function:\cd* | Edit-Code -Editor "C:\Program Files\Sublime Text 3\subl.exe" -Param "-n -w"
183
200
184
-
Pipes all functions starting with cd to Edit-Function, which opens them one at a time in a new sublime window (opens each one after the other closes).
201
+
Pipes all functions starting with cd to Edit-Code, which opens them one at a time in a new sublime window (opens each one after the other closes).
# Specifies the name of a function or script to create or edit. Enter a function name or pipe a function to Edit-Function.ps1. This parameter is required. If the function doesn't exist in the session, Edit-Function creates it.
223
+
# Specifies the name of a function or script to create or edit. Enter a function name or pipe a function to Edit-Code.
224
+
# This parameter is required. If the function doesn't exist in the session, Edit-Code creates it.
# Specifies the name of a function or script to create or edit. Enter a function name or pipe a function to Edit-Function.ps1. This parameter is required. If the function doesn't exist in the session, Edit-Function creates it.
230
+
# Specifies the name of a function or script to create or edit. Enter a function name or pipe a function to Edit-Code.ps1.
231
+
# This parameter is required. If the function doesn't exist in the session, Edit-Code creates it.
# Specifies a code editor. If the editor is in the Path environment variable (Get-Command <editor>), you can enter just the editor name. Otherwise, enter the path to the executable file for the editor.
236
+
# Specifies a code editor.
237
+
# If the editor is in the Path environment variable (Get-Command <editor>), you can enter just the editor name.
238
+
# Otherwise, enter the path to the executable file for the editor.
216
239
# Defaults to the value of $PSEditor.Command or $PSEditor or Env:Editor if any of them are set.
0 commit comments