Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Powershell ISE + vim

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?

like image 316
bjarven Avatar asked Jan 21 '15 12:01

bjarven


3 Answers

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

like image 153
MacMartin Avatar answered Oct 19 '22 07:10

MacMartin


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.

like image 4
Sully Avatar answered Oct 19 '22 07:10

Sully


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.

like image 3
Kellen Stuart Avatar answered Oct 19 '22 07:10

Kellen Stuart