Using Powershell ISE's intellisense in other terminal - powershell

I'm a big fan of powershell ISE as a terminal. It has intellisense and syntax highlighting built in the shell and I just use it instead of the regular shell for everyday commands.
I would like to use Visual Studio Code instead, because the editor is much more powerfull and has support for a whole lot of languages and format. However the integrated shell is you basic Powershell terminal : no intellisense, no coloring (even with Powershell 5 installed on my computer).
Is there any way to add intellisense and coloring to my terminal, or use ISE's terminal in VSCode? or is there a plugin somewhere adressing these issues?

The integrated PowerShell terminal on Visual Studio Code does have intellisense, so I'm unclear what you require here, are you sure it's not set to cmd.exe instead ?
On another note, follow this setup guide. In case you haven't already installed the PowerShell Extension.

Related

PowerShell 5.1 in Visual Studio code behaves strangly

When using PowerShell in VS code and working interactivly, often when I highlight some code and run it then it does not print anything in the terminal. Then I simply restart The "PowerShell Integrated Console" (by pushing the trash can) and it then works again.
It is quite annoying. My ADS also acts like this. Is this a general problem with PowerShell with VS Code or is it my computer?
My VS Code version is 1.68.0. My PowerShell version is 5.1.19041.1682. And the version of the PowerShell extension is v2022.5.1

Copied-and-pasted tab characters not recognized by Powershell

Powershell ignores tab characters in copied-and-pasted code snippets. This is annoying because I like to write my Python code with single tabs instead of quadruple spaces, and in testing I frequently copy and paste snippets in to test them.
So far I've been using other terminals like Cygwin that properly address pasted tabs, but it would be more convenient for me to use Powershell. How can it be made to address these pasted tabs correctly?
The MWE is to copy and paste anything with a tab into Powershell. For example,
test
appears in Powershell as
>>> test
with no indentation. I've copied and pasted from both Notepad and Notepad++ with the same effect; I'm not using any formatted word processors or anything like that.
Caveat: The next section only applies to PowerShell's own interactive prompt. Different rules may apply to external programs launched from PowerShell that present their own interactive prompt, such as python and, preferably, ipython - see the bottom section for considerations specific to these programs.
Preserving tabs on pasting directly into PowerShell's interactive prompt:
Note: Strictly speaking, when it does work, tabs are converted to 4 spaces each on pasting.
Only works when all of the following prerequisites are met:
When running PowerShell (Core) 7+ (as opposed to Windows PowerShell)
When pasting via Ctrl-V rather than via right-click (the latter emulates typing and therefore triggers tab completion).
When running in one of the following console environments:
Regular console window (conhost.exe)
Windows Terminal
Note:
Does not work in Visual Studio Code's integrated terminal (which seemingly always emulates typing in PowerShell).
Haven't tried third-party consoles such as Cygwin and ConEmu.
Notably, this categorically excludes Windows PowerShell (where a tab ends up as ^I).
Preserving tabs on pasting into the interactive python / ipython REPL, from PowerShell or cmd.exe:
Note:
ipython provides a superior REPL experience compared to python.
Unlike the above, the following also applies to launching from Windows PowerShell, as well as from cmd.exe.
When it works, pasted tabs are converted to 4 spaces, except where noted otherwise.
ipython
Regular console windows (conhost.exe):
Works, with Ctrl-V only.
Windows Terminal:
Works, with Ctrl-V only.
Visual Studio Code's integrated terminal:
Does NOT work (strips tabs).
python
Regular console windows (conhost.exe):
Works, with both Ctrl-V and right-click, as long as Filter clipboard contents on paste is turned OFF on the Options tab of the console window's Properties dialog; pastes actual tabs.
Windows Terminal:
Works, with right-click only(!); pastes actual tabs.
Visual Studio Code's integrated terminal:
Works.
The only way I was able to make this work was by using Windows Terminal. Which is a new terminal application built by Microsoft that supports a bunch of new features.
I don't know the technical reasons why, but it appears it supports pasting both tabs and spaces appropriately, without loss or conversion into the Python CLI REPL.
I tested this using Windows Terminal while running Windows PowerShell, PowerShell Core 7+ and Command Prompt, while running the Python CLI and all supported pasting tabs.
You can install Windows Terminal through a number of sources...Windows Store, Binary download, WinGet, Choco, etc.
Here's the github repo with instructions on various ways to install.
https://github.com/microsoft/terminal
In general, control-v is better for pasting characters than right-click. Note control-v has to be bound to psreadline's paste function (so no emacs mode). Here's an example with an a and an em dash (0x2013). Right click will only paste the a.
a–

Is it possible to run code in Visual Studio Code without a shell?

My school has blocked cmd and Powershell due to security concerns. Unfortunately for me, this prevents VSC from running code! I love using VSC, so I'm wondering if there's any way I can continue to use it without the powershell or cmd terminals.

Powershell ISE variable highlighter

Is there any add-ons for Powershell ISE where you can highlight any occurrence of the variable or any word? Something like Sublime Text has?
The ISE doesn't have support for add-ons, but Visual Studio Code does (and there's lots of good ones). It also has much better built-in syntax highlighting and Git support (if Git is installed). You'll need to install the PowerShell extension from the "extension marketplace" (just search for "PowerShell"). Also, Microsoft has said that they're not planning to continue maintenance of ISE, so VS Code is probably what you should be using to write PowerShell.
The ISE was not highlighting any keywords/syntaxes, for me the issue was with the file extension, the PS script file extension was inadvertently set to .ps, when I renamed it to have .ps1 extension, all the syntax highlighting revived. Hope this helps others.

Using "Visual Studio code" with interactive Powershell window like Powershell ISE

I'm new to Visual Studio code so thanks in advance for the help.
I often use the PowerShell ISE with an interactive PowerShell window. I open it, type a few commands, then run a script (such as opening a PowerShell session with Office 365) and then type a few more commands.
Is there any way to do the same thing with Visual Studio code? I see a way to run scripts and debug them but not have them complete but the PowerShell window still stay around so I can continue working.
Decided to convert to answer, since this is a bit too much for comments:
Go to settings > user settings and change "terminal.integrated.shell.windows" to:
"C:\\WINDOWS\\Sysnative\\WindowsPowerShell\\v1.0\\powershell.exe",
Ctrl + Shift + ` opens the terminal. Using the + button on the terminal window you can launch additional powershell instances.
Also there's an extension that allows for launching several different terminals under the same VSCode process (cmd,powershell,bash,etc). Minor nuance, shells are being started with the same permissions VSCode has, but you can re-elevate once inside the shell.
References:
https://code.visualstudio.com/docs/editor/integrated-terminal
https://code.visualstudio.com/docs/customization/userandworkspace
https://github.com/Microsoft/vscode/issues/10893
Edit: but I would say its not really convenient, terminal takes away too much space on the screen (well, unless you have like 2k or 4k display), so I use powershell + vscode.