VSCode's PowerShell Terminal now offers a kind of suggestion in gray of what you might be wanting to type (presumably from the history?):
But there seems to be no way to actually accept the suggestion: pressing tab just does the normal PowerShell autocomplete (usually of a cmdlet or path).
What is this feature and can I "tab" to get the command tantilisingly shown?
For me it was Shift + RightArrow.
If you have EditMode VI enabled, then make sure to define whatever key combination you would like to use for this to SelectForwardChar. To set SelectForwardChar to Shift + RightArrow insert the following line of code into your VSCode PowerShell Profile:
Set-PSReadLineKeyHandler -Key Shift+RightArrow -Function SelectForwardChar
The key combination SHIFT + RIGHTARROW should do the trick. I hope this helps!
Related
I've recently upgraded PowerShell to version 7.3.0 version and now, when I type a command, I see its suggestions like when I'm typing pip it adds list like in this image. Or when I type start of the command it suggests its full name.
The problem is that when I press Tab it doesn't complete the command, instead it just starts listing current directories, i.e. here is an image after pressing Tab once.
Also even when I start typing the full name of the command like pip li it still shows the ending, but when pressing Tab it just does nothing.
I expected this to complete the current command with the suggestion after Tab is pressed.
I've tried to google this problem but haven't found the exact same case I have with 7.3.0 version.
Just press -> (right arrow) key
If you want to change key bindings:
source: https://devblogs.microsoft.com/powershell/announcing-psreadline-2-1-with-predictive-intellisense/
Key Bindings for Predictions
Key bindings control cursor movement and additional features within the prediction. To support users running Predictive IntelliSense on multiple platforms, key bindings are user-settable from the command line or your profile script.
PSReadLine contains functions to navigate and accept predictions. As an example, to accept a displayed prediction, PSReadLine contains functions:
AcceptSuggestion – Accept the current inline suggestion
AcceptNextSuggestionWord – Accept the next word of the inline suggestion
AcceptSuggestion is built within ForwardChar, which by default is bound to RightArrow. Pressing RightArrow accepts an inline suggestion when the cursor is at the end of the current line.
AcceptNextSuggestionWord is built within the function ForwardWord, which can be bound with Ctrl+f by Set-PSReadLineKeyHandler -Chord "Ctrl+f" -Function ForwardWord. Pressing Ctrl+f accepts the next word of an inline suggestion when the cursor is at the end of current editing line.
As a user, you can bound other keys to AcceptSuggestion and AcceptNextSuggestionWord for similar functionalities. Search for ForwardCharAndAcceptNextSuggestionWord in SamplePSReadLineProfile.ps1 for an example to make RightArrow accept the next word from inline suggestion, instead of the whole suggestion line.
List of additional suggested key bindings defined in PSReadLine SamplePSReadLineProfile.ps1
I've achieved Intellisense from the Powershell via PSReadLine, but unlike fish shell where a word from the path can be concluded by hitting Ctrl + Right Arrow, I can't find any such shortcut or solution for this issue in Powershell. If any solutions, I please welcome them.
Example :
I now want to obtain cd '.\PICS\KIRAN\' only.
In fish shell, it's the scenario where you click Ctrl + Right Arrow for 2 times and then you get the expected result.
What should I do to obtain the same result in Windows Powershell ?
Alt+F (forward)
Alt+B (backword)
VSCode's PowerShell Terminal now offers a kind of suggestion in gray of what you might be wanting to type (presumably from the history?):
But there seems to be no way to actually accept the suggestion: pressing tab just does the normal PowerShell autocomplete (usually of a cmdlet or path).
What is this feature and can I "tab" to get the command tantilisingly shown?
For me it was Shift + RightArrow.
If you have EditMode VI enabled, then make sure to define whatever key combination you would like to use for this to SelectForwardChar. To set SelectForwardChar to Shift + RightArrow insert the following line of code into your VSCode PowerShell Profile:
Set-PSReadLineKeyHandler -Key Shift+RightArrow -Function SelectForwardChar
The key combination SHIFT + RIGHTARROW should do the trick. I hope this helps!
What is the best way to select a block of code in VSCode?
Is there any shortCut, which we can use?
You've probably got this by now, but what you need to do is search the Keyboard Shortcuts for the shift+alt+arrow mappings, and swap the cursorColumnSelect commands (currently mapped to ctrl+shift+alt+arrow) with the commands that are currently mapped to the desired keys.
Depends on the language, it was already asked btw.
Check this, works with HTML and JS
Also pressing Ctrl + I + up/down arrow will select the whole next line.
You can press SHIFT and select code with arrow keys.
I know I can use F7 to display command history and I can search the history to find a command that I've typed before ( like for example :)
Get-History |select -expand commandline |sls proc
but I wonder if the is a way to use a keybord shortcut to cycle through the history (like ctrl+R does on linux console) ?
Tab completion supports searching through memory, you could type:
#proc<TAB>
to cycle through commands that match the string 'proc'. But if you're looking for a more bash like editing experience, then you want PSReadline - https://github.com/lzybkr/PSReadLine.