Movatterモバイル変換


[0]ホーム

URL:


Quick links:help overview ·quick reference ·user manual toc ·reference manual toc·faq
Go to keyword (shortcut:k)
Site search (shortcut:s)
os_win32.txt  ForVim version 9.2.  Last change: 2026 Feb 14VIM REFERENCE MANUAL  by George Reillywin32Win32MS-WindowsThis file documents the idiosyncrasies of theWin32 version of Vim.TheWin32 version of Vim works on Windows 7, 8, 10 and 11.  There are bothconsole andGUI versions.If you have Windows XP or Vista then Vim 9.0 up to patch level 495 can beused.The 32 bit version also runs on 64 bitMS-Windows systems.1. Known problemswin32-problems2. Startupwin32-startup3. Restore screen contentswin32-restore4. Using the mousewin32-mouse5. Running under Windows 95win32-win956. Running under Windows 3.1win32-win3.17. Installation packagewin32-installer8.Win32 miniFAQwin32-faqAdditionally, there area number of commonWin32 andDOS items inos_dos.txt:File locationsdos-locationsUsing backslashesdos-backslashStandard mappingsdos-standard-mappingsScreen output and colorsdos-colorsFile formatsdos-file-formats:cd commanddos-:cdInterruptingdos-CTRL-BreakTemp filesdos-temp-filesShell option defaultdos-shellPowerShell defaultsdos-powershellWin32GUIgui-w32Credits:TheWin32 version was written by George V. Reilly <george@reilly.org>.The original Windows NT port was done by Roger Knobbe <RogerK@wonderware.com>.TheGUI version was made by George V. Reilly and Robert Webb.For compiling see "src/INSTALLpc.txt".win32-compilingWSLWhen using Vim onWSL (Windows Subsystem for Linux) the remarks heredo notapply,has('win32') will returnfalse then.  Incase you need to knowwhether Vimis running onWSL you can useexists('$WSLENV').==============================================================================1. Known problemswin32-problemsWhen doing file name completion, Vim also finds matches for the short filename.  But Vim will still find and use the corresponding long file name.  Forexample, if you have the long file name "this_is_a_test" with the short filename "this_i~1", the command ":e *1" will start editing "this_is_a_test".==============================================================================2. Startupwin32-startupCurrent directorywin32-curdirIf Vimis started witha single file name argument, andit hasa full path(starts with "x:\"), Vim assumesit was started from the file explorer andwill set the current directory to where that file is.  To avoid this whentypinga command to start Vim, usea forward slash instead ofa backslash.Example:vim c:\text\files\foo.txtWill change to the "C:\text\files" directory.vim c:/text\files\foo.txtWill use the current directory.Term optionwin32-termThe only kind ofterminal type that theWin32 version of Vim understandsis"win32", whichis built-in.  If you set'term' to anything else, you willprobably get very strange behavior from Vim.  Therefore Vim does not obtainthe default value of'term' from the environment variable "TERM".Terminal Colorswin32-term-colorsTheWin32 console supports 16 colors by defaultdos-colors.  From Windows 10version 1703 (Creators Update) onwards, the console supports 256 colors andtrue color (24-bit) when'termguicolors'is set and Vimis built with supportfor Virtual Terminal Processing (VTP)+vtp.Virtual Terminal Processingis automatically enabled if either the'termguicolors' optionis set or the't_Co' optionis set to 256.  Thisenables ANSIescape sequences for colors, improves rendering ofmulti-bytecharacters and enables otherterminal features in the Windows console.The actual color rendering depends on whether yourterminal supports VTP (suchas Windows Terminal or the modern Windows 10/11 console).$PATHwin32-PATHThe directory of the Vim executableis appended to $PATH.  Thisis mostly tomake "!xxd" work,asitis in the Tools menu.  Andit also means that whenexecutable() returns 1 the executable can actually be executed.Command line argumentswin32-cmdargsAnalysis ofa command line into parametersis not standardised in MS-Windows.Vim andgvim used to use different logic to parseit (before 7.4.432), and thelogic was also depended on whatit was compiled with.  Now Vim andgvim bothuse the CommandLineToArgvW()Win32 API, so they behave in the same way.The basic rules are:win32-backslashesa)A parameterisa sequence of graphic characters.      b) Parameters are separated by white space.      c)A parameter can be enclosed in doublequotes to include white space.      d)A sequence of zero or more backslashes (\) anda doublequote(")is special.  The effective number of backslashesis halved, roundeddown.  An even number of backslashes reverses the acceptability ofspaces and tabs, an odd number of backslashes producesa literaldoublequote.So:"isa special doublequote\"isa literal doublequote\\"isa literalbackslash anda special doublequote\\\"isa literalbackslash anda literal doublequote\\\\"is 2 literal backslashes anda special doublequote\\\\\"is 2 literal backslashes anda literal doublequoteetc.Example:vim "C:\My Music\freude" +"set ignorecase" +/"\"foo\\" +\"bar\\\"opens "C:\My Music\freude" and executes the line mode commands:set ignorecase; /"foo\ and /bar\"These rules are also described in thereference of the CommandLineToArgvW API:https://msdn.microsoft.com/en-us/library/windows/desktop/bb776391.aspxwin32-quotesThere are additional rules forquotes (which are not well documented).As described above,quotes insidea file name (or any other command lineargument) can be escaped witha backslash.  E.g.vim -c "echo 'foo\"bar'"Alternatively use threequotes to get one:vim -c "echo 'foo"""bar'"The quotation rules are:1.A" starts quotation.2. Another" or"" ends quotation.  If the quotation ends with"",a"is producedat theend of the quoted string.Examples, with[] around an argument:        "foo"->[foo]        "foo""-> [foo"]        "foo"bar->[foobar]        "foo"bar->[foo],[bar]        "foo""bar-> [foo"bar]        "foo""bar-> [foo"],[bar]        "foo"""bar"-> [foo"bar]==============================================================================3. Restore screen contentswin32-restoreWhen'restorescreen'is set (whichis the default), Vim will restore theoriginal contents of the console whenexiting or when executing externalcommands.  If you don't want this, use ":set nors".'restorescreen'==============================================================================4. Using the mousewin32-mouseTheWin32 version of Vim supports using the mouse.  If you havea two-buttonmouse, the middle button can be emulated by pressing both left and rightbuttons simultaneously- butnote that in theWin32 GUI, if you have the rightmouse button pop-up menu enabled (see'mouse'), you should err on the side ofpressing the left button first.mouse-usingWhen the mouse doesn't work, try disabling the "Quick Edit Mode" feature ofthe console.==============================================================================5. Running under Windows 95win32-win95windows95windows98windowsmeWindows 95/98/ME support was removed in patch 8.0.0029  If you want to useityou will need to geta version older than that.==============================================================================6. Running under Windows 3.1win32-win3.1win32swindows-3.1gui-w32swin16There wasa special version ofgvim that runs under Windows 3.1 and 3.11.Support was removed in patch 7.4.1364.==============================================================================7. Installation packagewin32-installerA simple installer forwindowsis availableathttp://www.vim.org/download.php(stable version) and nightly builds are also availableathttps://github.com/vim/vim-win32-installer/releases/The nightly builds include 32bit and 64bit builds, have most features enabledand usually also contain an extra cryptographic signed installer, so Windowswill not complain.To use the installer, simply run the exe file.  The following switches arealso supported:    gvim_<version>.exe /S           -> silent install without any dialogues    gvim_<version>.exe /D=C:\vim    -> Install into directory c:\vim                                    -> /D must be the last argument    gvim_<version>.exe /S /D=c:\vim -> silent install into c:\vimThe default installation directory can alternatively be given by setting the$VIM environment variable.==============================================================================8.Win32 miniFAQwin32-faqQ. HowdoI change the font?A. In theGUI version, you can use the'guifont' option.  Example::set guifont=Lucida_Console:h15:cDEFAULT  In the console version, you need to set the font of the console itself.   You cannotdo this from within Vim.Q. HowdoI type dead keys on Windows NT?A. Dead keys work on NT 3.51.  Just type themas you would in any other   application.   On NT 4.0, you need to make sure that the defaultlocale (set in the   Keyboard part of the Control Panel)is the sameas the currently active   locale.  Otherwise the NT code will get confused and crash!  Thisisa NT   4.0 problem, not reallya Vim problem.Q. I'm using Vim to edita symbolically linked file onaUnix NFS file server.   WhenI write the file, Vim does not "write through" the symlink.  Instead,it deletes the symbolic link and createsa new file in its place.  Why?A. On Unix, Vimis prepared for links (symbolic or hard).Abackup copy of   the original fileis made and then the original fileis overwritten.  This   assures that all properties of the file remain the same.  On non-Unix   systems, the original fileis renamed anda new fileis written.  Only the   protection bits are set like the original file.  However, this doesn't work   properly when working on an NFS-mounted file system where links and other   things exist.  The only way to fix this in the current versionis not   makingabackup file, by ":set nobackup nowritebackup"'writebackup'Q. I'm using Vim to edita file onaUnix file server through Samba.  WhenI   write the file, the owner of the fileis changed.  Why?A. Whenwritinga file Vim renames the original file, thisisabackup (incasewriting the file fails halfway).  Then the fileis writtenasa new   file.  Samba then givesit the default owner for the file system, which may   differ from the original owner.   To avoid this set the'backupcopy' option to "yes".  Vim will then makea   copy of the file for the backup, and overwrite the original file.  The   owner isn't changed then.Q. HowdoI get to see the output of ":make" while it's running?A. Basically what you needis toputa tee program that will copy its input   (the output from make) to both stdout and to the errorfile.  You can finda   copy of tee (anda number of other GNU tools)athttp://gnuwin32.sourceforge.net orhttp://unxutils.sourceforge.net   Alternatively, try the more recent Cygnus version of the GNU toolsathttp://www.cygwin.com   When youdo geta copy of tee, you'll need to add:set shellpipe=\|\ tee  to your _vimrc.Q. I'm storing files ona remote machine that works with VisionFS, and files   disappear!A. VisionFS can't handle certain dot (.) threeletter extension file names.   SCO declares this behavior required for backwards compatibility with 16bit   DOS/Windows environments.  The two commands below demonstrate the behavior:echo Hello > file.bat~dir > file.bat   The resultis that the "dir" command updates the "file.bat~" file, instead   of creatinga new "file.bat" file.  This same behavioris exhibited in Vim   when editing an existing file named "foo.bat" because the default behavior   of Vimis to createa temporary file witha '~' character appended to the   name.  When the fileis written,it winds up being deleted.   Solution: Add this command to your_vimrc file::set backupext=.temporaryQ. HowdoI change the blink rate of the cursor?A. You can't!  Thisisa limitation of the NT console.  NT 5.0is reported to   be able to set the blink rate for all consolewindowsat the same time.:!startQ. How canI asynchronously run an external command or program, or opena   document or URL with its default program?A. When using:! to run an external command, you can runit with "start".  For   example, to run notepad::!start notepad   To open "image.jpg" with the default image viewer:        :!start image.jpg   To open the folder of the current file in Windows Explorer:        :!start %:h   To open the Vimhome page with the default browser:        :!start http://www.vim.org/   Using "start" stops Vim switching to another screen, openinga new console,   or waiting for the program to complete;it indicates that you are runninga   program that does not affect the files you are editing.  Programs begun   with:!startdo not get passed Vim's open file handles, which means theydo   not have to be closed before Vim.   To avoid this special treatment, use ":! start".   There are two optional arguments (see the next Q):       /min  thewindow will be minimized       /b    no consolewindow will be opened   You can use only one of these flagsata time.A second one will be   treatedas the start of the command.windows-asynchronouslyQ. HowdoI avoid gettingawindow for programs thatI run asynchronously?A. You have three possible solutions depending on what you want:   1) You may use the /min flag in order to run program ina minimized state      with no other changes.  It will work equally for console andGUI      applications.   2) You can use the /b flag to run console applications without creatinga      consolewindow for them (GUI applications are not affected).  But you      should use this flag only if the application you run doesn't require any      input.  Otherwiseit will get an EOF error because its input stream      (stdin) would be redirected to \\.\NUL (stdout and stderr too).   3) Set the '!' flag in the'guioptions' option'go-!'.  This will make Vim      run the "start" command inside Vimsterminalwindow and not opena      console window.   Example fora console application, run Exuberant ctags:        :!start /min ctags -R .   Whenit has finished you should see file named "tags" in your current   directory.  You should notice thewindow title blinking on your taskbar.   Thisis more noticeable for commands that take longer.   Now delete the "tags" file and run this command:        :!start /b ctags -R .   You should have the same "tags" file, but this time there will be no   blinking on the taskbar.   Example foraGUI application:        :!start /min notepad        :!start /b notepad   The first command runsnotepad minimized and the second one runsit   normally.windows-iconQ.I don't like the Vim icon, canI change it?A. Yes, place your favorite icon in bitmaps/vim.ico ina directory of'runtimepath'.  For example ~/vimfiles/bitmaps/vim.ico. vim:tw=78:ts=8:noet:ft=help:norl:

Quick links:help overview ·quick reference ·user manual toc ·reference manual toc·faq


[8]ページ先頭

©2009-2026 Movatter.jp