Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable PSReadline support in the integrated console (syntax highlighting, keyboard navigation) #535

Closed
daviwil opened this issue Mar 14, 2017 · 133 comments
Assignees
Milestone

Comments

@daviwil
Copy link
Contributor

daviwil commented Mar 14, 2017

PSReadline is not supported in the integrated console at this time. A non-trivial amount of work is needed to make PowerShell Editor Services and PSReadline play nicely together so this could take some time.

Features this will enable:

  • Ctrl+Arrow keys, etc (keyboard navigation of the input line)
  • Syntax highlighting of input text
  • Multi-line text input (writing a function definition in the console across multiple lines)
@daviwil daviwil added the Issue-Enhancement A feature request (enhancement). label Mar 14, 2017
@daviwil daviwil added this to the Backlog milestone Mar 14, 2017
@dotps1
Copy link

dotps1 commented Mar 14, 2017

i was going to request this yesterday but i got distracted.

@cobdev
Copy link

cobdev commented Mar 17, 2017

Thank you!

@Liquidmantis
Copy link

Hopefully this will include PSReadline's Vi EditMode and ViModeIndicator. I found this issue while searching for a way to get vi mode working.

@gwojan
Copy link

gwojan commented Jul 4, 2017

Um, @daviwil, when did PSReadline start working in the VSCode PowerShell terminal window? I just opened the terminal and noticed my PSReadline history was available. A quick Set-PSReadlineOption -EditMode Vi and I'm in hog heaven!

Is there something I should be watching for? I guess I should mention: Windows 10 Anniversary Update, PowerShell 5.1, VSCode 1.13.1, PowerShell addin 1.4.1...

@rkeithhill
Copy link
Contributor

PSReadline support in the PowerShell terminal is a VSCode feature. What isn't implemented yet is PSReadline support in the PowerShell Integrated Console.

@daviwil
Copy link
Contributor Author

daviwil commented Jul 5, 2017

Hey Greg, unfortunately you're just seeing PSReadLine work inside of plain powershell.exe in the integrated terminal. As Keith mentions, it doesn't currently work in the PowerShell Integrated Console yet. I've started working on that last week though so I expect to have some progress soon!

@gwojan
Copy link

gwojan commented Jul 5, 2017

Thanks @daviwil and @rkeithhill! I guess I need to start playing with the Integrated Console because I'm sure I knew it was there. It will be great to have PSReadline support because that one particular feature is why I abandoned the ISE a long time ago. I'm such a lousy typist I need all the help I can get. ;-)

@daviwil daviwil removed this from the June 2017 milestone Jul 11, 2017
@GlitterHorn
Copy link

Is Ctrl+Backspace supposed to be working with PSReadLine support in the latest preview build?

@rkeithhill
Copy link
Contributor

Try putting this in your VSCode specific profile - (Microsoft.VSCode_profile.ps1):

Set-PSReadLineKeyHandler -Chord 'Ctrl+w' -Function BackwardKillWord
Set-PSReadLineKeyHandler -Chord 'Alt+D' -Function KillWord
Set-PSReadLineKeyHandler -Chord 'Ctrl+@' -Function MenuComplete

@GlitterHorn
Copy link

Try putting this in your VSCode specific profile - (Microsoft.VSCode_profile.ps1):

Set-PSReadLineKeyHandler -Chord 'Ctrl+w' -Function BackwardKillWord
Set-PSReadLineKeyHandler -Chord 'Alt+D' -Function KillWord
Set-PSReadLineKeyHandler -Chord 'Ctrl+@' -Function MenuComplete

Thanks - I had to put this in Microsoft.PowerShell_profile.ps1, but it worked!

$profile is set to that file according to VSCode's terminal.

@rkeithhill
Copy link
Contributor

Sorry, I thought you were trying out the PSRL support in the PowerShell Integrated Console which does load the VSCode profile. The profile you put this in will load in both the PSIC and the regular integrated terminal. But it will also load this into any PowerShell console. You might want to fire up a PowerShell console and make sure backspace still works as you expect.

@GlitterHorn
Copy link

I have ConPTY set up with the VSCode extension, if that makes any difference. I changed that after seeing somewhere (github issue, probably) that I should use ConPTY to have keyboard shortcuts like this.

@rkeithhill
Copy link
Contributor

Cool. Well if you wind up with issues in the external PowerShell console, you could conditionally invoke the above script like so:

if ($env:TERM_PROGRAM -eq "vscode") {
    Set-PSReadLineKeyHandler -Chord 'Ctrl+w' -Function BackwardKillWord
    Set-PSReadLineKeyHandler -Chord 'Alt+D' -Function KillWord
    Set-PSReadLineKeyHandler -Chord 'Ctrl+@' -Function MenuComplete    
}

There is also a $env:TERM_PROGRAM_VERSION that might come in handy.

@Jaykul
Copy link

Jaykul commented Mar 19, 2019

Still. Waiting.

@JustinGrote
Copy link
Collaborator

@Jaykul you can use it in the powershell preview module that was published, unless you're waiting on something else?

@rfoust
Copy link

rfoust commented Mar 21, 2019

@JustinGrote The preview module doesn't show up as an available module on code-insiders, fwiw.

@TylerLeonhardt
Copy link
Member

@rfoust it should. They both pull from the same marketplace.

Search for "PowerShell" and look down the list. I remember seeing it about half way down the page.

@rfoust
Copy link

rfoust commented Mar 21, 2019

Oh you're right, there it is. Not sure why I didn't see it last night. :)

@SydneyhSmith
Copy link
Collaborator

Closing as PSReadLine is now available in the PowerShell Preview extension, tracking that PSReadLine is not available in the main PowerShell Extension here #1793

@iampeterdaniels
Copy link

After updating to the non-preview powershell extension v 2020.1.0 and vscode 1.42.1, I have lost syntax highlighting in the integrated console. The actual code editor is working fine. Any ideas?

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Feb 29, 2020
@JustinGrote
Copy link
Collaborator

@iampeterdaniels non-preview extension doesn't have PSReadline, you have to use the preview extension for psreadline functionality (which includes syntax highlighting, special characters, etc.)

@iampeterdaniels
Copy link

Thank you, Justin. Not sure why I thought the PSReadline 2.0 release somehow translated into it being in the non-preview extension.

@JustinGrote
Copy link
Collaborator

@iampeterdaniels the current preview extension should roll into stable very soon, they're trying to target it for the PS7 release which will probably drop sometime this week or next.

@max-programming
Copy link

For some reason, my Ctrl + Backspace still does not work in VS Code with Powershell integrated terminal.

Tried both Powershell V5 and V7.

Any fix on that?

@ghost
Copy link

ghost commented Nov 11, 2022

Thank you for your comment, but please note that this issue has been closed for over a week. For better visibility, consider opening a new issue with a link to this instead.

@starball5
Copy link

starball5 commented Sep 21, 2023

Is running multiple selected lines in the same commandline command supported now? I'm trying to find where the discussion from microsoft/vscode#9715 and #1607 (comment) continues and can't find it. Is there a dedicated issue ticket covering it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests