How do I set vim as the external editor in FarManager, and pass full path names?
I'm trying to configure VIM as my external editor in the far file manager. I want to be able to select multiple items in a folder, some being directories, and have their full paths passed to the vim command line.
Update: To clarify exactly what I want to do. I want to be able to select multiple files in a panel like so:
and have vim opened like this:
"C:\Program Files\Vim\vim73\vim.exe" c:\src\TalkMaterials "c:\src\abba 1.txt" "c:\src\abba 3.txt"
This would open all the files in different buffers.
Solution 1:
I have found the solution that does exactly what you are asking for. But it requires the plug-in FarNet and its module PowerShellFar:
http://code.google.com/p/farnet/
They also need .NET 2.0+ and Windows PowerShell 2.0 installed. This is already the case on Windows 7 but earlier Windows versions are not so lucky. Besides, PowerShell 2.0 is only for Windows XP SP 3 and above (not even SP 2).
If you are not yet scared then here is the trick. In the external editor command we call PowerShellFar through its command line prefix ">:"
>: & vim @(Get-FarPath -Selected) #
That's it. It works, I have tried it (not with vim, though, I do not have one). It is fast, it does not start PowerShell each time; the core is loaded once when Far starts.
Note: The last '#' in the command is a little PowerShellFar convention: to not add to the persistent command history commands with '#' in the end. This command is for opening the external editor, it is written once and we do not want it to pollute the history of other commands typed manually.
P.S. I am the author of both FarNet and PowerShellFar, just in case. They are open source, mature and robust. I would recommend them in any case, as far as you use Far Manager and recent Windows has all the prerequisites for these tools.
Solution 2:
The closest I can come is vim !& this creates the following command line
"C:\Program Files\Vim\vim73\vim.exe" TalkMaterials "abba 1.txt" "abba 3.txt"
That seems to work just fine, but I'd like full paths passed to vim anyway. Before accepting my own answer, I'd like to see if there is a way to pass all the full paths to vim.