Vim Tips Wiki
Register
We recommend that you log in before editing. This will allow other users to leave you a message about your edit, and will let you track edits via your Watchlist. Creating an account is quick and free.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 105: Line 105:
 
You need to escape a double quote (and a backslash) in a ref file because that is how the syntax was designed. It allows RegEdit to differentiate between these characters entered as data vs as entered as delimiters. Same as the percent sign in batch files.
 
You need to escape a double quote (and a backslash) in a ref file because that is how the syntax was designed. It allows RegEdit to differentiate between these characters entered as data vs as entered as delimiters. Same as the percent sign in batch files.
 
ArtK Oct 14, 2014
 
ArtK Oct 14, 2014
:Sure, I understand the concept of escaping. But why is the escape character '\' here? In .bat files you use ^ to escape anything, and backslash normally doesn't do anything special. So what's special about "reg add"? --[[User:Fritzophrenic|Fritzophrenic]] ([[User talk:Fritzophrenic|talk]]) 18:30, October 14, 2014 (UTC)
 
 
-------
 
-------
 
Whoa! Lots of inaccurate and misleading statements here. Some corrections and clarifications:
 
Whoa! Lots of inaccurate and misleading statements here. Some corrections and clarifications:
:I don't think anything is actually inaccurate here, see my responses below. Maybe we need to retool which portions get emphasis. Please let us know what you think. --[[User:Fritzophrenic|Fritzophrenic]] ([[User talk:Fritzophrenic|talk]]) 18:30, October 14, 2014 (UTC)
 
   
 
File association definitions are are stored under registry keys in two (virtual) hives: HKLM and HKU. Specifically, HKLM\Software\Classes\ and HKCU\Software\Classes\ plus HKCU\...\FileExts\:
 
File association definitions are are stored under registry keys in two (virtual) hives: HKLM and HKU. Specifically, HKLM\Software\Classes\ and HKCU\Software\Classes\ plus HKCU\...\FileExts\:
   
HKLM\Software\Classes\ defines associations for the local machine, i.e., ''all users'' (unless overridden by HKCU definitions)
+
HKLM\Software\Classes\ defines associations for the local machine, i.e., [[all users]] (unless overridden by HKCU definitions)
:Yes, this was mentioned in the [[#User-specific file associations]] section. This is the place the ftype and assoc commands modify. Where does this need clarification? Do you want to see this in the intro and [[#How it works]] sections? --[[User:Fritzophrenic|Fritzophrenic]] ([[User talk:Fritzophrenic|talk]]) 18:30, October 14, 2014 (UTC)
 
   
HKCU\Software\Classes\ defines associations for the ''current logged on user''.
+
HKCU\Software\Classes\ defines associations for the [[current logged on user]].
:Yes, this is the entire point of the [[#User-specific file associations]] section. Do you think that section needs more prominence? --[[User:Fritzophrenic|Fritzophrenic]] ([[User talk:Fritzophrenic|talk]]) 18:30, October 14, 2014 (UTC)
 
   
HCR is an ''alias'' for HKLM\Software\Classes\. It is ''not'' a copy. It is ''not'' ambiguous. It is ''not'' a merging of anything. It ''is'' simply a shorthand way of directly referring to a subset of HKLM (HKLM\Software\Classes\).
+
HCR is an [[alias]] for HKLM\Software\Classes\. It is [[not]] a copy. It is [[not]] ambiguous. It is [[not]] a merging of anything. It [[is]] simply a shorthand way of directly referring to a subset of HKLM (HKLM\Software\Classes\).
:Experimentation shows that HCR includes entries for both HKLM and HKCU definitions. I agree it is not a copy...but it certainly seems to be a merging of some kind. Do you know where to find documentation on how this alias works? What happens if you create something here, does it get stored in HKLM or HKCU? --[[User:Fritzophrenic|Fritzophrenic]] ([[User talk:Fritzophrenic|talk]]) 18:30, October 14, 2014 (UTC)
 
   
Similarly, HKCU is an ''alias'' for a ''subset'' of HKU (HKU\S-1-5-21-...\) - the currently logged on user account. Again, just a shorthand name. (Each user account has a unique S-1-5-21-... key under HKU so HKCU is unique for each user.)
+
Similarly, HKCU is an [[alias]] for a [[subset]] of HKU (HKU\S-1-5-21-...\) - the currently logged on user account. Again, just a shorthand name. (Each user account has a unique S-1-5-21-... key under HKU so HKCU is unique for each user.)
:Good to know. I don't think that's very useful information for this tip, however...I don't think that much detail is needed in knowing how to set up file associations in HKCU. Do you disagree? --[[User:Fritzophrenic|Fritzophrenic]] ([[User talk:Fritzophrenic|talk]]) 18:30, October 14, 2014 (UTC)
 
   
 
In addition, HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\ contains all the user account created definitions managed via "Explorer\Tools\Folder Options\File Types". These include, for example, application created entries when you install an app for a single user or when you allow your browser to set itself as the default browser.
 
In addition, HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\ contains all the user account created definitions managed via "Explorer\Tools\Folder Options\File Types". These include, for example, application created entries when you install an app for a single user or when you allow your browser to set itself as the default browser.
:OK, good to know. Where does this tie-in to double-clicking to open a file? Is it worth mentioning in this tip? Is there an easy editor or configuration tool for this outside the registry? We should include it if it is useful, especially if it provides an easy alternative to registry hacking. --[[User:Fritzophrenic|Fritzophrenic]] ([[User talk:Fritzophrenic|talk]]) 18:30, October 14, 2014 (UTC)
 
   
When a file reference is double clicked, Windows first looks in HKCU for any file association definitions for that specific file extent. ''If and only if'' no definition exists in HKCU for the requested ''verb'' (Open, Edit, Print, etc), does Windows look in HCR for its info.
+
When a file reference is double clicked, Windows first looks in HKCU for any file association definitions for that specific file extent. [[If and only if]] no definition exists in HKCU for the requested [[verb]] (Open, Edit, Print, etc), does Windows look in HCR for its info.
:I don't think HCR works the way you think it does. Right now on my system, in HCR, I have a "sourcecode" entry (with various open/edit verbs defined). "sourcecode" does ''not'' exist in HKLM\Software\Classes; here the entries skip right from "SoundRec" to "SPCFile". On the other hand, in HKCU\Software\Classes, "sourcecode" is present. So, obviously HCR includes entries from HKCU\Software\Classes.
 
:On the other hand, in HCR, "sourcecode" is surrounded "SoundRec" and "SPCFile" just like in HKLM\Software\Classes. But HKCU\Software\Classes has "Software" and "stylesheet" surrounding the "sourcecode" entry. Thus, HCR also obviously includes entries from HKLM. HCR is ''definitely'' merging the two locations in some fashion. I just don't know the details as to how. --[[User:Fritzophrenic|Fritzophrenic]] ([[User talk:Fritzophrenic|talk]]) 18:30, October 14, 2014 (UTC)
 
   
Consequently, ASSOC and FTYPE are totally useless for managing user specific file associations. These utilities operate ''only'' on ''HCR'' keys (and require admin rights to change entries). Also, FTYPE only operates on the command key for the "open" verb (...\shell\open\command\); it cannot set or reset any other verb command key.
+
Consequently, ASSOC and FTYPE are totally useless for managing user specific file associations. These utilities operate [[only]] on [[HCR]] keys (and require admin rights to change entries). Also, FTYPE only operates on the command key for the "open" verb (...\shell\open\command\); it cannot set or reset any other verb command key.
:Yes, I agree. That's why we have a separate section on [[#User-specific associations]], and also [[#Associating Vim with other actions]]. But since most computers probably have only a few users, and this doesn't involve manually hacking the registry, and since alternate verbs are less common than "double-click to open": ftype and assoc are probably good to mention first. Do we need to emphasize that more in the section about ftype and assoc? --[[User:Fritzophrenic|Fritzophrenic]] ([[User talk:Fritzophrenic|talk]]) 18:30, October 14, 2014 (UTC)
 
   
 
This is just the tip of the iceberg regarding file associations. The next level is all of the "OpenWith" mechanisms for many-to-one and one-to-many associations. For more info, see SuperUser post[http://superuser.com/questions/204354/how-do-i-get-ftype-assoc-to-match-windows-explorer/814400#814400], do a Google search[http://www.google.com/search?as_q=windows&as_epq=file+association] or browse the registry with RegEdit (if you don't change anything, it is safe to look. Create a check point first to be doubly safe.)
 
This is just the tip of the iceberg regarding file associations. The next level is all of the "OpenWith" mechanisms for many-to-one and one-to-many associations. For more info, see SuperUser post[http://superuser.com/questions/204354/how-do-i-get-ftype-assoc-to-match-windows-explorer/814400#814400], do a Google search[http://www.google.com/search?as_q=windows&as_epq=file+association] or browse the registry with RegEdit (if you don't change anything, it is safe to look. Create a check point first to be doubly safe.)
   
 
ArtK Oct 14, 2014
 
ArtK Oct 14, 2014
 
:This tip is the result of hours of fiddling with the registry and Google searching, and ''it works''. So please don't assume proper searching was not done first. If this were easy, well-documented, or if Windows had a built-in UI, we may not have needed a tip in the first place. I'm sure there is more to the story about file associations, this is only an attempt to document the process SOMEWHERE because it isn't easy to find this information. Especially as it relates to something as user-specific as a preferred text editor.
 
 
:The top few Google hits for 'Windows "file associations"' all talk about using the GUI tools in Windows to set an "open with" program. This is all well and good, but programs like Vim often need to pass various command-line arguments along with the file to be useful. Can this be done with the "open with" GUIs?
 
 
:Thanks for the SuperUser link, that gives some good detail, especially about the FileExts area. But you should certainly look into the HKEY_CLASSES_ROOT again, I think you're incorrect there. --[[User:Fritzophrenic|Fritzophrenic]] ([[User talk:Fritzophrenic|talk]]) 18:30, October 14, 2014 (UTC)
 
   
 
-------
 
-------
Please note that all contributions to the Vim Tips Wiki are considered to be released under the CC-BY-SA
Cancel Editing help (opens in new window)