****************************************************************************
Quick customized-installation tutorial for setting up gVim on Windows
Tested only on Windows 10, but it should work on all versions of Windows.
Please suggest improvements if you have helpful ideas to benefit others.
****************************************************************************
============================================================================
1. Download the gvim80-586.exe installer from the canonical site:
http://www.vim.org/download.php/
============================================================================
2. Doubleclick on gvim80-586.exe and select the type of install
The default list of checked settings is:
[x]Vim executables and runtime files
[x]Vim console program (vim.exe)
[ ]Create .bat files for command line use
[x]Create icons on the desktop
[x]Add vim to the start menu
[x]Add an edit-with-vim context menu entry
[x]Create a _vimrc if it doesn't exist
[x]Create plugin directories in HOME or VIM
[ ]Create plugin directriesa in VIM
[ ]VisVim extension for MS Visual Studio
[x]Native Language Support
If desired, change those default checked settings to:
[x]Vim executables and runtime files
[x]Vim console program (vim.exe)
[x]Create .bat files for command line use
[x]Create icons on the desktop
[x]Add vim to the start menu
[x]Add an edit-with-vim context menu entry
[x]Create a _vimrc if it doesn't exist
[x]Create plugin directories in HOME or VIM
[ ]Create plugin directriesa in VIM
[ ]VisVim extension for MS Visual Studio
[ ]Native Language Support
Explanation of changes:
- Creating batch files allows vim to be run easily in a command window.
- Native language support isn't all that useful for English speakers.
============================================================================
3. The program will default to installing in C:\Program Files (x86)\Vim
I installed it into C:\app\editor\txt\vim instead.
Note: The default may depend on your operating system.
Note: Use whatever directory structure makes sense to you.
Note that the installer is in the category of misbehaving (IMHO) in that
it creates *multiple* levels of hierarchy, e.g., if you install into:
C:\app\editor\txt\vim
What you end up with is:
C:\app\editor\txt\vim\vim80\
and
C:\app\editor\txt\vim\vimfiles\
and
C:\app\editor\txt\vim\_vimrc
============================================================================
4. By default, 3 desktop shortcuts are created:
a. gVim 8.0
Default Target = "C:\Program Files (x86)\Vim\vim80\gvim.exe"
Default Startin = %HOMEDRIVE%%HOMEPATH%
b. gVim Easy 8.0
Default Target = "C:\Program Files (x86)\Vim\vim80\gvim.exe" -y
Default Startin = %HOMEDRIVE%%HOMEPATH%
c. gVim Read only 8.0
Default "C:\Program Files (x86)\Vim\vim80\gvim.exe" -R
Default Startin = %HOMEDRIVE%%HOMEPATH%
I delete the latter two & put the remaining shortcut in the menus:
A. Right click on the desktop "gVim 8.0" > SendTo > Heterodox Start Menu
B. Right click on the desktop "gVim 8.0" > SendTo > Cascade Start Menu
C. As desired, organize "gVIM 8.0" for your Orthodox Start Menu
Note: The default may depend on your operating system.
Note: See separate notes for setting up menus using the SendTo feature.
============================================================================
5. Test the command-line feature to test the batch-file option:
Run a quick test in a command window:
Start > cmd > [Enter] > vim foo
Note that setting the batch file option will create the following files:
%windir%\{evim,gview,gvim,gvimdiff,view,vim,vimdiff,vimtutor}.bat
============================================================================
6. Make gVim the default for editing *.txt text files.
a. Create a sample text file, e.g., C:\tmp\fname.txt
b. RMB on fname.txt > Open with > Choose another app >
Other options > More apps > (scroll down to select)
"VI Improved - a Text Editor"
[x]Always use this app to open .txt files
Notice the "Settings" method does not work because there is no
option for setting vim as the default editor for text files.
A. Start > Settings > Apps > Default apps >
Choose default apps by file type
Change from ".txt ==> Notepad"
Your only choices are:
a. Notepad
b. Registry Editor Utility
c. Wordpad
d. Look for an app in the store
Note: RMB=== right mouse button
Note: The sequence may depend on your operating system.
============================================================================
7. If desired, fix the unsightly ungainly turd files proliferation problem.
Start > cmd > [Enter]
copy c:\app\editor\txt\vim\_vimrc c:\app\editor\txt\vim\_vimrc.orig
mkdir c:\tmp\turd\vim\directory
mkdir c:\tmp\turd\vim\backup
mkdir c:\tmp\turd\vim\undo
vim c:\app\editor\txt\vim\_vimrc
Add the following lines to the beginning of _vimrc:
set directory=c:\\tmp\turd\vim\directory//,%TMP%,C:\WINDOWS\Temp//,$HOME,.
set backupdir=c:\\tmp\turd\vim\backup//,%TMP%,C:\WINDOWS\Temp//,$HOME,.
set undodir=c:\\tmp\turd\vim\undo//,%TMP%,C:\WINDOWS\Temp//,$HOME,.
============================================================================
9. Test turd file dynamics (by creating, editing & changing files).
a. Open the three locations in separate Windows file explorer windows:
c:\tmp\turd\vim\directory
c:\tmp\turd\vim\backup
c:\tmp\turd\vim\undo
b. Create, edit, and change a test file to note how turd files react:
RMB > New > Text Document >
c:\app\editor\txt\vim\New Text Document.txt
c. Doubleclick "New Text Document.txt" & observe turd file changes.
directory
Ephemeral %-swp-named swap lock file created when you edit a text file.
fname=C%%app%editor%txt%vim%New Text Document.txt.swp
backup
Persistent ~-named file when you save a text file.
fname=New Text Document.txt~
undo
Persistent %-named txt file when you save changes to a text file.
fname=C%%app%editor%txt%vim%New Text Document.txt
============================================================================
10. If desired, set gVim to edit extensionless files when doubleclicked.
Create this registry file & import into the registry;
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:\\app\\editor\\txt\\vim\\vim80\\gvim.exe\" \"%1\""
Note: If desired, set Notepad to edit extensionless files instead:
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:\\Windows\\System32\\NOTEPAD.EXE\" \"%1\""
============================================================================
11. If desired, edit or remove the RMB context menu added by the installer.
If you have CCleaner installed, then run
CCleaner: Tools > Startup > Context Menu >
- Enabled = Change Yes to No (if desired)
- Key = File
- Program = gvim
- Publisher = Tianmiao Hu's Developer Studio
- File = C:\app\editor\txt\vim\vim80\gvimext.dll
Note: I checked the Windows task scheduler where no tasks were added.
a. Open an admin command window or powershell using normal procedures.
b. Then start the task scheduler using either this method:
%windir%\system32\control.exe
System and Security > Administrative Tools > TASk Scheduler
Or use this method to open the task scheduler as admin:
%windir%\system32\taskschd.msc /s
c. Select the "Task Scheduler Library" entry (top left)
d. Check for any tasks set up by the installer
(There were none when I checked today.)
----------------------------------------------------------------------------
12. If desired, check the setup in the default _vimrc file:
Start > Run > cmd > [Enter]
vim c:\app\editor\txt\vim\_vimrc
Make sure _vimrc sources mswin.vim which maps the ^v to the paste.
(Otherwise you need to use control+q on Windows instead of control+v.)
For example, normally you'd use control+v in this circumstance:
:%s/xxx/&<control-v><return>/g
But if the mapping of control+v isn't set, then you have to use this:
:%s/abc/&<control-q><return>/g
NOTE: the syntax is, roughly:
: === begin command
% === for the whole file
s === search
/ === for
abc ==== the characters abc
/ === then
/&<control-v><return> === replace it plus add a carriage return
/ === do that
g === for as many times as you see abc in any given line
----------------------------------------------------------------------------
Please test and suggest improvements so that everyone benefits.
----------------------------------------------------------------------------
--
Tested today only on WIndows 10 but I've been installing gVIM on all
versions of Windows over the decades so it should work, with minor changes,
on all Windows platforms.