Skip to content

Instantly share code, notes, and snippets.

@ninmonkey
Created July 10, 2026 16:35
Show Gist options
  • Select an option

  • Save ninmonkey/bec316176e699e6eec36e4707e4d3cff to your computer and use it in GitHub Desktop.

Select an option

Save ninmonkey/bec316176e699e6eec36e4707e4d3cff to your computer and use it in GitHub Desktop.
EditFunc - Jump to profile functions in Vs Code.ps1
function EditFunc {
<#
.SYNOPSIS
Finds where a function is defined, opens it in vs code -- and jumps to the line number it starts on
.example
gcm prompt | EditFunc
#>
[CmdletBinding()]
param(
[Parameter(ValueFromPipeline)]
$Command
)
begin {
$binCode = Get-Command 'code' -CommandType Application -ea 'stop' -TotalCount 1
}
process {
$sb = (Get-Command $Command).ScriptBlock
$fullName = Get-Item -ea 'stop' $sb.File
$codeArgs = @(
'--goto'
'"{0}:{1}:{2}"' -f @(
$fullName
$sb.Ast.Extent.StartLineNumber
$sb.Ast.Extent.StartColumnNumber
)
)
& $binCode @codeArgs
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment