Multiple tabs in Windows and gvim - windows

I am trying to get the Edit with Vim context menu to open files in a new tab of the previously opened Gvim instance (if any).
Currently, using Regedit I have modified this key:
\HKEY-LOCAL-MACHINE\SOFTWARE\Vim\Gvim\path = "C:\Programs\Vim\vim72\gvim.exe" -p --remote-tab-silent "%*"
The registry key type is REG_SZ.
This almost works... Currently it opens the file in a new tab, but it also opens another tab (which is the active tab) the tab is labeled \W\S\--literal and the file seems to be trying to open the following file.
C:\Windows\System32\--literal
I think the problem is around the "%*" - I tried changing that to "%1" but if i do that I get an extra tab called %1.
Affected version
Vim version 7.2 (same behaviour on 7.1)
Windows vista home premium
Thanks for any help.
David.

Try setting it to: "C:\Programs\Vim \vim72\gvim.exe" -p --remote-tab-silent "%1" "%*"
See: http://www.vim.org/tips/tip.php?tip_id=1314
EDIT: As pointed out by Thomas, vim.org tips moved to: http://vim.wikia.com/
See: http://vim.wikia.com/wiki/Add_open-in-tabs_context_menu_for_Windows

You were on the right track:
HKEY-LOCAL-MACHINE\SOFTWARE\Vim\Gvim\path = "C:\Programs\Vim \vim72\gvim.exe" -p
was sufficient ... it works!!

I found the answer... The link to cream gave me some additional areas to search around.
from http://genotrance.wordpress.com/2008/02/04/my-vim-customization/ there is a vim.reg registry file that contains the following
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\Edit with Vim]
#=""
[HKEY_CLASSES_ROOT\*\shell\Edit with Vim\command]
#="\"C:\\Programs\\vim\\vim72\\gvim.exe\" -p --remote-tab-silent \"%1\" \"%*\""
[HKEY_CLASSES_ROOT\Applications\gvim.exe\shell\open\command]
#="\"C:\\Programs\\vim\\vim72\\gvim.exe\" -p --remote-tab-silent \"%1\" \"%*\""
this gives me the behaviour I want.
So I guess my original plan of editing the HKEY_LOCAL_MACHINE was just wrong.
Would also be nice to know what exactly what the "%1" and "%*" mean/ refer to.
Now... should I edit my original question, to show that I was starting off in the wrong registry area?

I would recommend trying Cream.
Cream is a set of scripts and add-ons that sit on top of gVim. Cream doesn't change the appearance of gVim, but it does change the way it behaves.
One of those behaviours is a tabbed document interface. Other behaviours are listed here. The downloads page is here.

There is an even cleaner fix using your _vimrc. Add the following line:
autocmd BufReadPost * tab ball
from http://www.vim.org/scripts/script.php?script_id=1720

Related

Open file in existing emacs frame (Windows)

I'm using Emacs 24.3 on Windows 8. I want to be able to right-click a file and select "Edit with Emacs" and have the file open in an existing emacs frame. All steps I have done so far are listed below. Most of it was taken direction from the Emacs documentation page for Windows.
The following are the registry keys I used to add "Edit with Emacs" to my context menu:
[HKEY_CLASSES_ROOT\*\shell]
[HKEY_CLASSES_ROOT\*\shell\openwemacs]
#="&Edit with Emacs"
[HKEY_CLASSES_ROOT\*\shell\openwemacs\command]
#="C:\\Portable Software\\emacs-24.3\\bin\\emacsclientw.exe -n \"%1\""
[HKEY_CLASSES_ROOT\Directory\shell\openwemacs]
#="Edit &with Emacs"
[HKEY_CLASSES_ROOT\Directory\shell\openwemacs\command]
#="C:\\Portable Software\\emacs-24.3\\bin\\emacsclientw.exe --alternate-editor=\"C:\\Portable Software\\emacs-24.3\\bin\\runemacs.exe\" -n \"%1\""
I also set the ALTERNATE_EDITOR environment variable to C:\\path\\to\\runemacs.exe
At the beginning of my .emacs I have added the following code per this answer.
(require 'server)
(or (server-running-p)
(server-start))
Adding that got rid of the "server already running" error when opening a second file, but it still opens in a new frame.
So what am I missing to get emacs to open new files in the existing frame?
I accidentally figured this out while trying to fix synctex with SumatraPDF. It would appear that in addition to the ALTERNATE_EDITOR environment variable pointing to runemacs.exe, you must also create an EMACS_SERVER_FILE environment variable that points to the server file (mine was stored in the .emacs.d\server directory). Once I did that, files that I tell to Open with Emacs opened in the existing frame rather than creating their own.
This worked for me.
Create C:\Program Files\runemacs.bat with the following contents:
#echo off
:: Set the path to where the Emacs binaries are
set binpath=C:\Program Files\emacs-26.1-x86_64\bin
:: If no arg is given edit this file
if "%~1"=="" (
set filename="C:\Program Files\runemacs.bat"
) else (
set filename="%~1"
)
:: Run Emacsclient
"%binpath%\emacsclientw.exe" --no-wait --alternate-editor="%binpath%\runemacs.exe" %filename%
And open all files via C:\Program Files\runemacs.bat instead of C:\Program Files\emacs-26.1-x86_64\bin\runemacs.exe.
It seems that emacsclient is failing to connect with the server and starting a new instance of emacs each time. You may need to unblock something in any software firewall you have installed.

"edit" not a valid command in cmd.exe?

I'm trying to create a .cfg file for bcc32 compiler and I'm following the instructions. I have installed correctly and placed an environment path as instructed but when I type "edit bcc32.cfg" into the command prompt it says that edit isn't a valid command? What am I supposed to do?
You could also create a .bat file, edit.bat, to replace the 16-bit edit program (removed because x64 windows flavors won't run it) which would launch your favorite editor.
#echo off
notepad %1
#echo on
This is what I wound up doing as a simple patch so I could carry on the way I always had for the most part. Just type:
edit myfile.ext
in the command prompt to use it.
Note: notepad is not my favorite editor - this is just an example that will work with stock windows.
Note 2: #echo off and #echo on are shown for clarity. You may also shorten this by omitting the echo statements and simply placing the # before the command to be silenced.
#notepad %1
I just use notepad (since they took out the edit command) from the command window like so:
C:\Borland\BCC55\bin> notepad bcc32.cfg
The file will open in notepad for editing. When you've finished editing the file, save it and you're done.
I have found this works for seeing in-window text of a complete file, on a 64bit machine. Once your path is set in cmd prompt, type the word type... followed by "filename" do you see how I used the quotes around the filename only!
type "filename"
You type it just like this (changing filename for your files name) and you will be able to see the entire file text in the cmd window. Not sure how to edit from here on but maybe someone can figure it out from here and tell me.
Assuming you're using Windows 7 (where edit.exe and edlin.exe have been removed):
Use powershell.exe instead of cmd - thereby edit will be available via command line.
Take a look at: http://en.wikipedia.org/wiki/Windows_PowerShell
simple answer....
if your using an old version of windows (xp e.t.c...) you would be able to use edit
but since your using new version of windows, Microsoft has updated and removed the commands that they think are not relevant e.g.. (msg, edit) depending if its a bit32 bit64 or bit82...

Windows shell add item to context menu when click on blank part of folder

Sorry if this has been asked before, I've been looking around and it's hard to find what I want.
I know how to add a context menu item to a folder like so:
[HKEY_CLASSES_ROOT\Folder\shell\console2]
#="Open Console2 Here"
[HKEY_CLASSES_ROOT\Folder\shell\console2\command]
#="C:\\Program Files\\Console\\console.exe -d \"\"%1\"\""
but, that only works for right clicking on a folder. I want it so that you can be inside the folder, and click a blank part of that folder and get the context menu item as well. I also tried HKEY_CLASSES_ROOT\Directory\shell as well, but it does the same.
I figured out the answer. The folder is actually Directory\Background, you have to add the empty string value of NoWorkingDirectory into it, and the %1 in the command becomes a %V
[HKEY_CLASSES_ROOT\Directory\Background\shell\console2]
#="Open Console2 Here"
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\Directory\Background\shell\console2\command]
#="C:\\Program Files\\Console\\console.exe -d \"\"%V\"\""
Source:
saviert's comment at http://www.howtogeek.com/howto/windows-vista/make-command-prompt-here-always-display-for-folders-in-windows-vista#comment-57856
Console2 rocks. I added an 'Cmd here (Console2)' item to my explorer context menu.
Save the text below in a file named open-console2.reg then open it to import it to the Windows registry.
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\console2]
#="Cmd here (Console2)"
"NoWorkingDirectory"=""
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\console2\command]
#="\"C:\\Program Files (x86)\\Console2\\Console.exe\" -d \"%V\"\\"
Bonus 'bash here' item (assumes you have a Console2 tab named 'bash').
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\console2_bash]
#="Bash here (Console2)"
"NoWorkingDirectory"=""
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\console2_bash\command]
#="\"C:\\Program Files (x86)\\Console2\\Console.exe\" -t Bash -d \"%V\"\\"
I think the relevant part of the TortoiseSVN installer is here. Perhaps you can figure out all the necessary registry keys from that.
None of the above worked for me.
But this does (tested on Windows 7 Pro x64):
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Folder\shell\Open console here\command]
#="u:\\users\\dave\\data\\bin\\Console2\\Console.exe cmd -r \"/k pushd %L\""
Replace the path with the path to your copy of console.exe (of course).
#Ben Voigt mentioned TortoiseSVN, you can also see WinMerge shell extension source code, or at last: create your own extension from scratch; I wanted to do something like this for XP but I have lots of other stuff to do now.
As a workaround, you can just open a folder in XP, and then select View->Explorer Bar->Folders, to have folder tree on left, and then you're able to right-click the folder (active folder gets hightlighted automatically).
Here it is if you prefer MinGW.
#!/bin/sh
reg add 'HKCR\Directory\Background\shell\sh' -d 'Open Bash window here'
reg add 'HKCR\Directory\Background\shell\sh\command' \
-d 'C:\MinGW\msys\1.0\bin\sh.exe -l'
printf 'cd -' >> ~/.profile
superuser.com/a/387273
According to my personal experience of Windows XP (SP3), you can open Console2 inside the current directory with a context menu entry using the following .reg file:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Folder\shell\console2]
#="Console2 Here"
[HKEY_CLASSES_ROOT\Folder\shell\console2\command]
#="C:\Program Files\Console\console.exe -d \"%1\""
If you look at the key value inside regedit.exe , you should see:
C:\Program Files\Console\console.exe -d "%1"
instead of:
C:\Program Files\Console\console.exe -d ""%1""
The latter would open Console2 in its default start directory.
This can be achieved in XP as well.
First open the program Run with the Windows key + R,
and type Regedit in the textbox.
Press Enter.
In the Registry open the Key : HKEY_CLASSES_ROOT
and then : *
You will now see a key called : shell
Rightclick on shell and point to New.
Click in de menu on Key.
Now type a name of your choice which you want to appear in the Rightclick menu.
Rightclick on the name you chose, again point to New and click Key.
Now type : command
Click on command and in the right pane of the Registry doubleclick on (Default).
In the textbox Value Data, type the path to an application you want to open via the chosen name in the rightclick menu.
For example : "C:\Program Files\CCleaner\CCleaner.exe"
Then type after the path : %1,
and leave a space between the end of the path and %1
It should look like this :
"C:\Program Files\CCleaner\CCleaner.exe" %1
This way, it's possible to open any kind of application you want.
There's only one drawback,
you have to rightclick another file to see the chosen name with which you can open the application.
When you rightclick a folder this will not work.

How do you make a file writable from vim in windows?

How do I make a file writable from Vim on a Windows machine? I currently manually go find the file in explorer, open it's properties and uncheck readonly. I would like to be able to do this more quickly.
It seems attrib is the Windows shell command to modify file attributes.
See :!attrib /?
:!attrib -R %should remove the Read only property on the file. (It is working here the [RO] flag is modified in my status bar).
You will be prompted to reload the file (if you don't have autoread set) : don't ! and then save with :w!
(Rereading your question I am not sure that the Read only flag is your issue there because :w! should work anyway. )
Maybe I am missing something but :w! works for me.
Use :saveas C:\Users\your_user_name\Desktop\temp.txt and use explorer to copy it to its original location with UAC.

How to open a file in Eclipse AND jump to a specific line?

I can open a file in exclipse, but is there any syntax to jump to a specific line?
VI can do this by
vi -c LINE filename
Not exactly the right answer, but for Java file, you can use the package explorer, or the outline view, useful to select a group of lines) and open the file to the line matching a Java element (class, method, variable, ...)
Once the file is already opened, CTRL+L is the way to go to a line of the currently edited file, as Adi mentions in the comment.
Finally fixed!!
On Windows:
eclipsec.exe -name Eclipse --launcher.openFile %USERPROFILE%\workspace\MyClass.java:50
On Linux/Mac:
eclipse -name Eclipse --launcher.openFile ~/workspace/MyClass.java:50
Only tested on MARS:
Preferences > Keys > "Open from Clipboard"
Assign key binding.
Copy i.e. log entry in format Main.java:1
Press chosen key binding
voilĂ 
In latest Version [Oxygen] key was ctrl+shift+v
CTRL+SHIFT+R (Open Resource) or CTRL+SHIFT+T (Open Type, for classes only)
Type the name / the start of the name / the first letters of a camel case name
CTRL+L (Go to line)
Hmm. For me it works on Windows as simple as
eclipse.exe path\filename.ext:42
(I was actually looking for a consistent solution across IDEs.
Pycharm offers pycharm.exe path:number as well but it does not seem to work :/)
Try
eclipse.exe file.txt:22
for newer versions of eclipse, and
eclipse.exe file.txt+178
for older ones.
Continuing from #raho's response, the complete menu path is:
Window -> Preferences -> General -> Keys
This won't work on c++ as far as I can tell.
(I'm using Oxygen 4.7.1a)

Resources