When I try to edit a file with Vim 7.1 from Windows PowerShell, Vim
seems to require a full path to the file. For instance, if I'm in "H:\My
Documents\WindowsPowerShell" and I type "vim profile.ps1" or even "vim
.\profile.ps1" I find myself editing "H:\profile.ps1".
This behavior is apparently unique to PowerShell; in CMD and CSH Vim
lets me use relative paths the way one would expect. Is there a way to
adjust Vim (or PowerShell!) to let me use relative paths when calling
Vim from PowerShell?
--
David
Stardate 7530.7
Here's a function you can put into your $profile so that you can pipe into
vim (e.g., "dir c:\ | vim") and which may also help get around the relative
path issue:
function vim ( $path = $null )
{
$vimpath = 'C:\Progra~1\Vim\vim71\vim.exe'
if ($path -ne $null) {invoke-expression "$vimpath $path"}
elseif ( $input.movenext() )
{
$input.reset()
$input | out-string | out-file "$env:TEMP\vimtempfile.txt"
invoke-expression "$vimpath $env:TEMP\vimtempfile.txt"
remove-item "$env:TEMP\vimtempfile.txt"
}
else { invoke-expression "$vimpath" }
}
Cheers,
Jason
------------------------------------------------------
PowerShell Training at SANS Conferences
http://www.WindowsPowerShellTraining.com
------------------------------------------------------
Well repeat your example above - but now once vim has started call
Vims ":pwd" command. The output should be "H:\My
Documents\WindowsPowerShell" ! If not them powershell just might be
powerfull but it certainly is not propper shell.
Martin
--
mailto://kris...@users.sourceforge.net
Ada programming at: http://ada.krischik.com
Thanks, Jason. That works!
--
David
Stardate 7531.1
Er, well, mostly. I'll have to tweak it to allow Vim's command-line
parameters.
--
David
Stardate 7531.1
Er, well, mostly. I'll have to tweak it to allow Vim's command-line
The $path expression gets ugly with spaces?
if I do this
>vim "C:\program files\test bin\config.txt"
It won't envoke with the right file name.
"Jason" <nos...@nospam.com> wrote in message
news:%231MUWDX...@TK2MSFTNGP05.phx.gbl...
Aha! I found the answer: doskey!
I stuck these lines in my PowerShell profile:
doskey /exename=powershell.exe vim="&"
$env:programfiles\vim\vim71\vim.exe $*
doskey /exename=powershell.exe gvim="&"
$env:programfiles\vim\vim71\gvim.exe $*
David
Stardate 7617.2