Powershell ISE + vim
Asked Answered
T

3

6

Is it possible to make Powershell ISE behave like vim with some vim-like editing mode or plugin?

In netbeans I'm using jVi, and in Visual Studio I'm using VsVim, is there something similar for PowerShell ISE?

Or should I drop Powershell ISE altogether and just use vim + powershell command line?

Tabanid answered 21/1, 2015 at 12:44 Comment(4)
I would like to say that you are comparing apples to oranges. PowerShell ISE is not a text editor it is meant for scripting. It uses Intellisense and tab completion for path, commands, properties, etc.Stressful
Yeah I guess you're right. I'm pretty new to PowerShell ISE. I just wanted to be able to do familiar navigating when I'm writing those scripts. Like hjkl and so forth.Tabanid
Someone told me once to just use the damn arrow keys. Again, they told me .... not you. If this helps here are some keyboard shortcuts. A bunch are obivous but it could be useful.Stressful
serverfault.com/questions/36991/…. There is not definitive for what you want but this has been discussed once in the past. Sorry about the answer I misinterpreted the question.Stressful
H
4

I may be misunderstanding the question, but the closest I've come to getting vim-like ability while using PS ISE is to install gvim74 for Windows, and create this function:

function vim 
{ 
    if ($args)
    { 
        start-process 'C:\Program Files (x86)\Vim\vim74\vim.exe' $args
    }
    else
    { 
        start-process 'C:\Program Files (x86)\Vim\vim74\vim.exe'
    }
}

Unfortunately, ISE does not play nicely with console input, so the best I can get is starting vi in a new PS window. Not perfect, but I get my ability to "vim fileToEdit", which I do A LOT in non-Windows world.

Humorist answered 22/1, 2015 at 21:19 Comment(0)
J
4

The last weaks i searched for a way to use psISE in combination with vim (i found out its possible but hard for me to code without the ISE-comfort) In the end i created a function/submenu in the ISE that:

  • With a keyboard-shortcut ([AltGr]+[v]) starts vim with the current file and waits for the process to end
  • When I'm finished editing in vim and saved the file its removed from the ISE
  • And loaded again (bacause in v3 there is no file "refreshing")

# one-line $psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add("edit with Vim",{$cur=$psISE.CurrentFile; saps "C:\Program Files (x86)\vim\vim74\gvim.exe" $cur.FullPath -wait; $psise.currentpowershelltab.files.remove($cur); $psISE.currentpowershelltab.files.add($cur.fullpath) },'Ctrl+Alt+v')

You have to save it first or it will not be removed
(maybe you add the $psise.CurrentFile.Save()-function)
(for permanent ISE-changes you have to put it into the $profile...)

*saps --> start-process alias

Jacquiline answered 26/5, 2015 at 12:4 Comment(0)
C
3

The best thing I've found is VSCode with the PowerShell and VIM plugin installed. The Powershell plugin used to be a lot worse than ISE, but recently the Intellisense has gotten much cleaner.

Chunchung answered 24/1, 2019 at 15:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.