Wikia

Vim Tips Wiki

Changes: Associate files with no extension to Vim under Windows

Edit

Back to page

(Change <tt> to <code>, perhaps also minor tweak.)
(merge in content from VimTip279)
 
Line 11: Line 11:
 
|category2=Windows
 
|category2=Windows
 
}}
 
}}
For Windows users that use file associations to [[Launch_files_in_new_tabs_under_Windows|automatically launch files in Vim]], a gem I've found is, in a command prompt window:
+
For Windows users that use [[Windows file associations]] to [[Launch_files_in_new_tabs_under_Windows|automatically launch files in Vim]], a gem I've found is, in a command prompt window:
   
 
<pre>
 
<pre>
Line 23: Line 23:
 
You may need to logout and log back in before this will take effect.
 
You may need to logout and log back in before this will take effect.
   
==Comments==
+
{{RegistryWarning}}
This doesn't seem to work for me.
+
You can also use the Windows Registry to set up the extensionless file association. For example, by importing the following registry file (adjust for correct Vim version):
   
I've set ftype:
+
<pre>
C:\>ftype | grep txtfile
+
Windows Registry Editor Version 5.00
txtfile="C:\Program Files\Vim\vim71\gvim.exe"
+
[HKEY_CLASSES_ROOT\.]
  +
[HKEY_CLASSES_ROOT\.\shell]
  +
[HKEY_CLASSES_ROOT\.\shell\open]
  +
[HKEY_CLASSES_ROOT\.\shell\open\command]
  +
@="\"C:\\Vim\\vim61\\gvim.exe\" \"%1\""
  +
</pre>
   
Then I set assoc:
+
==See also==
C:\>assoc | grep .=txt
+
*[[VimTip279]] for automatically launching Vim for files which may have an extension but have no file association.
.=txtfile
 
   
This method does work for file extensions (.abcd) but not for extension-less files, I still get the "Open with ..." dialog.
+
==Comments==
 
What does work for me is:
 
C:\>assoc *=txtfile
 
 
I'm not a Windows expert, but AFAIK this is the correct method for associating files without an extension.
 
 
Does anyone know how these two are different?
 
 
[[User:Carpetsmoker|Carpetsmoker]] 18:00, 13 April 2008 (UTC)
 
----
 
 
: I log out and back in and it does work, pfffft, Windows O.o [[User:Carpetsmoker|Carpetsmoker]] 18:36, 13 April 2008 (UTC)
 
 
----
 
I'm on vista, the .= method worked for me right away, without the need to log off.
 

Latest revision as of 16:57, November 12, 2012

Tip 1301 Printable Monobook Previous Next

created 2006 · complexity basic · author John Little · version 5.7


For Windows users that use Windows file associations to automatically launch files in Vim, a gem I've found is, in a command prompt window:

assoc .=txtfile

Where txtfile has been defined as a file type that is opened with Vim. See VimTip1003, and try ftype /? at the command prompt.

This will cause files with no extension (e.g. "Makefile") to open automatically in Vim.

You may need to logout and log back in before this will take effect.

WARNING: Editing your Windows registry may cause unintended side effects that render your system inoperable. Although this tip has worked in the past for some people, there is no guarantee that it will work for you. Use with caution, and at your own risk.

You can also use the Windows Registry to set up the extensionless file association. For example, by importing the following registry file (adjust for correct Vim version):

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.]
[HKEY_CLASSES_ROOT\.\shell]
[HKEY_CLASSES_ROOT\.\shell\open]
[HKEY_CLASSES_ROOT\.\shell\open\command]
@="\"C:\\Vim\\vim61\\gvim.exe\" \"%1\""

See alsoEdit

  • VimTip279 for automatically launching Vim for files which may have an extension but have no file association.

CommentsEdit

Around Wikia's network

Random Wiki