PowerShell - Visual Studio Code - How to disable 'more' on long results?

419 Views Asked by At

I keep having to hit the enter key when the results are longer than my screen in Visual Studio Code.

Example Get-Help Remove-Item - detailed

enter image description here

How can I get all the results on the screen without having to hit enter on 'more' please?

Thanks for your help.

1

There are 1 best solutions below

0
On BEST ANSWER

Note: The following applies to all PowerShell hosts (environments), not just Visual Studio Code.

The Get-Help cmdlet itself does not perform interactive pagination (waiting for a keypress before printing the next page).

However, the built-in help function does: it (ultimately) pipes to the more.com utility (on Windows); you can inspect the function definition with $function:help.

If you're really seeing pagination with Get-Help, the implication is that a custom command is shadowing the Get-Help cmdlet (e.g., hypothetically, a Get-Help function defined in your $PROFILE file).

Use Get-Command -All Get-Help to investigate the problem: if there are multiple results, they are shown in order of precedence; that is, the effective command is shown first.


If you do want the help command to act like Get-Help - i.e. without pagination - you can define a help alias, as shown in this SuperUser answer:

New-Alias help Get-Help

Since an alias has a higher command-lookup precedence than a function (see about_Command_Precedence), the help alias effectively overrides the built-in help function.

If you put the above command in your $PROFILE file, help will act like Get-Help in all sessions (except those started with -NoProfile). Note that Visual Studio Code's PowerShell extension has its own $PROFILE file, distinct from that of PowerShell sessions in regular console windows.