代码拉取完成,页面将自动刷新
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>usr_31 - Vim Documentation</title>
<meta name="Generator" content="Vim/8.0">
<meta name="plugin-version" content="vim8.0">
<meta name="syntax" content="help">
<meta name="settings" content="no_pre,use_css,expand_tabs">
<link rel="stylesheet" href="style.css" type="text/css" />
<script src="jquery.min.js" type="text/javascript"></script>
<script src="mark-current-page.js" type="text/javascript"></script>
</head>
<body>
<header>
<div class="header">
<a href="http://vim-jp.org/">vim-jp</a>
/ <a href="http://vim-jp.org/vimdoc-en/">vimdoc-en</a>
/ usr_31<br />
<a name="top"></a><h1>usr_31 - Vim Documentation</h1>
<a href="index.html">Return to main</a>
<span class="EnglishJapaneseLink">
<span class="CurrentLanguage">English</span>
</span>
</div>
</header>
<nav>
<dl>
<dt>BASIC</dt>
<dd><ul>
<li><a href="quickref.html">quickref</a></li>
<li><a href="sponsor.html">sponsor</a></li>
</ul></dd>
<dt>USER MANUAL</dt>
<dd><ul>
<li><a href="usr_toc.html">usr_toc</a></li>
</ul></dd>
<dt>Getting Started</dt>
<dd><ul>
<li><a href="usr_01.html">usr_01</a></li>
<li><a href="usr_02.html">usr_02</a></li>
<li><a href="usr_03.html">usr_03</a></li>
<li><a href="usr_04.html">usr_04</a></li>
<li><a href="usr_05.html">usr_05</a></li>
<li><a href="usr_06.html">usr_06</a></li>
<li><a href="usr_07.html">usr_07</a></li>
<li><a href="usr_08.html">usr_08</a></li>
<li><a href="usr_09.html">usr_09</a></li>
<li><a href="usr_10.html">usr_10</a></li>
<li><a href="usr_11.html">usr_11</a></li>
<li><a href="usr_12.html">usr_12</a></li>
</ul></dd>
<dt>Editing Effectively</dt>
<dd><ul>
<li><a href="usr_20.html">usr_20</a></li>
<li><a href="usr_21.html">usr_21</a></li>
<li><a href="usr_22.html">usr_22</a></li>
<li><a href="usr_23.html">usr_23</a></li>
<li><a href="usr_24.html">usr_24</a></li>
<li><a href="usr_25.html">usr_25</a></li>
<li><a href="usr_26.html">usr_26</a></li>
<li><a href="usr_27.html">usr_27</a></li>
<li><a href="usr_28.html">usr_28</a></li>
<li><a href="usr_29.html">usr_29</a></li>
<li><a href="usr_30.html">usr_30</a></li>
<li><a href="usr_31.html">usr_31</a></li>
<li><a href="usr_32.html">usr_32</a></li>
</ul></dd>
<dt>Tuning Vim</dt>
<dd><ul>
<li><a href="usr_40.html">usr_40</a></li>
<li><a href="usr_41.html">usr_41</a></li>
<li><a href="usr_42.html">usr_42</a></li>
<li><a href="usr_43.html">usr_43</a></li>
<li><a href="usr_44.html">usr_44</a></li>
<li><a href="usr_45.html">usr_45</a></li>
</ul></dd>
<dt>Making Vim Run</dt>
<dd><ul>
<li><a href="usr_90.html">usr_90</a></li>
</ul></dd>
<dt>General subjects</dt>
<dd><ul>
<li><a href="intro.html">intro</a></li>
<li><a href="index.html">help</a></li>
<li><a href="helphelp.html">helphelp</a></li>
<li><a href="vimindex.html">index</a></li>
<li><a href="tags.html">tags</a></li>
<li><a href="howto.html">howto</a></li>
<li><a href="tips.html">tips</a></li>
<li><a href="message.html">message</a></li>
<li><a href="quotes.html">quotes</a></li>
<li><a href="todo.html">todo</a></li>
<li><a href="debug.html">debug</a></li>
<li><a href="develop.html">develop</a></li>
<li><a href="uganda.html">uganda</a></li>
</ul></dd>
<dt>Basic editing</dt>
<dd><ul>
<li><a href="starting.html">starting</a></li>
<li><a href="editing.html">editing</a></li>
<li><a href="motion.html">motion</a></li>
<li><a href="scroll.html">scroll</a></li>
<li><a href="insert.html">insert</a></li>
<li><a href="change.html">change</a></li>
<li><a href="indent.html">indent</a></li>
<li><a href="undo.html">undo</a></li>
<li><a href="repeat.html">repeat</a></li>
<li><a href="visual.html">visual</a></li>
<li><a href="various.html">various</a></li>
<li><a href="recover.html">recover</a></li>
</ul></dd>
<dt>Advanced editing</dt>
<dd><ul>
<li><a href="cmdline.html">cmdline</a></li>
<li><a href="options.html">options</a></li>
<li><a href="pattern.html">pattern</a></li>
<li><a href="map.html">map</a></li>
<li><a href="tagsrch.html">tagsrch</a></li>
<li><a href="quickfix.html">quickfix</a></li>
<li><a href="windows.html">windows</a></li>
<li><a href="tabpage.html">tabpage</a></li>
<li><a href="syntax.html">syntax</a></li>
<li><a href="spell.html">spell</a></li>
<li><a href="diff.html">diff</a></li>
<li><a href="autocmd.html">autocmd</a></li>
<li><a href="filetype.html">filetype</a></li>
<li><a href="eval.html">eval</a></li>
<li><a href="channel.html">channel</a></li>
<li><a href="fold.html">fold</a></li>
</ul></dd>
<dt>Special issues</dt>
<dd><ul>
<li><a href="print.html">print</a></li>
<li><a href="remote.html">remote</a></li>
<li><a href="term.html">term</a></li>
<li><a href="digraph.html">digraph</a></li>
<li><a href="mbyte.html">mbyte</a></li>
<li><a href="mlang.html">mlang</a></li>
<li><a href="arabic.html">arabic</a></li>
<li><a href="farsi.html">farsi</a></li>
<li><a href="hebrew.html">hebrew</a></li>
<li><a href="russian.html">russian</a></li>
<li><a href="ft_ada.html">ft_ada</a></li>
<li><a href="ft_sql.html">ft_sql</a></li>
<li><a href="hangulin.html">hangulin</a></li>
<li><a href="rileft.html">rileft</a></li>
</ul></dd>
<dt>GUI</dt>
<dd><ul>
<li><a href="gui.html">gui</a></li>
<li><a href="gui_w32.html">gui_w32</a></li>
<li><a href="gui_x11.html">gui_x11</a></li>
</ul></dd>
<dt>Interfaces</dt>
<dd><ul>
<li><a href="if_cscop.html">if_cscop</a></li>
<li><a href="if_lua.html">if_lua</a></li>
<li><a href="if_mzsch.html">if_mzsch</a></li>
<li><a href="if_perl.html">if_perl</a></li>
<li><a href="if_pyth.html">if_pyth</a></li>
<li><a href="if_tcl.html">if_tcl</a></li>
<li><a href="if_ole.html">if_ole</a></li>
<li><a href="if_ruby.html">if_ruby</a></li>
<li><a href="debugger.html">debugger</a></li>
<li><a href="workshop.html">workshop</a></li>
<li><a href="netbeans.html">netbeans</a></li>
<li><a href="sign.html">sign</a></li>
</ul></dd>
<dt>Versions</dt>
<dd><ul>
<li><a href="vi_diff.html">vi_diff</a></li>
<li><a href="version4.html">version4</a></li>
<li><a href="version5.html">version5</a></li>
<li><a href="version6.html">version6</a></li>
<li><a href="version7.html">version7</a></li>
<li><a href="version8.html">version8</a></li>
</ul></dd>
<dt>Remarks about specific systems</dt>
<dd><ul>
<li><a href="os_390.html">os_390</a></li>
<li><a href="os_amiga.html">os_amiga</a></li>
<li><a href="os_beos.html">os_beos</a></li>
<li><a href="os_dos.html">os_dos</a></li>
<li><a href="os_mac.html">os_mac</a></li>
<li><a href="os_mint.html">os_mint</a></li>
<li><a href="os_msdos.html">os_msdos</a></li>
<li><a href="os_os2.html">os_os2</a></li>
<li><a href="os_qnx.html">os_qnx</a></li>
<li><a href="os_risc.html">os_risc</a></li>
<li><a href="os_unix.html">os_unix</a></li>
<li><a href="os_vms.html">os_vms</a></li>
<li><a href="os_win32.html">os_win32</a></li>
</ul></dd>
<dt>Standard plugins</dt>
<dd><ul>
<li><a href="pi_getscript.html">pi_getscript</a></li>
<li><a href="pi_gzip.html">pi_gzip</a></li>
<li><a href="pi_logipat.html">pi_logipat</a></li>
<li><a href="pi_netrw.html">pi_netrw</a></li>
<li><a href="pi_paren.html">pi_paren</a></li>
<li><a href="pi_tar.html">pi_tar</a></li>
<li><a href="pi_vimball.html">pi_vimball</a></li>
<li><a href="pi_zip.html">pi_zip</a></li>
</ul></dd>
<dt>Filetype plugins</dt>
<dd><ul>
<li><a href="pi_spec.html">pi_spec</a></li>
</ul></dd>
<dt>Others</dt>
<dd><ul>
<li><a href="vim_faq.html">vim_faq</a></li>
</ul></dd>
</dl>
</nav>
<article class="Vimdoc VimdocJa">
<div id='vimCodeElement'>
<a class="Constant" href="usr_31.html" name="usr_31.txt">usr_31.txt</a> For <span class="Identifier">Vim version 8.0.</span> Last change: 2007 May 08<br>
<br>
VIM USER MANUAL - by Bram Moolenaar<br>
<br>
Exploiting the GUI<br>
<br>
<br>
Vim works well in a terminal, but the GUI has a few extra items. A file<br>
browser can be used for commands that use a file. A dialog to make a choice<br>
between alternatives. Use keyboard shortcuts to access menu items quickly.<br>
<br>
<a class="Identifier" href="usr_31.html#31.1">31.1</a> The file browser<br>
<a class="Identifier" href="usr_31.html#31.2">31.2</a> Confirmation<br>
<a class="Identifier" href="usr_31.html#31.3">31.3</a> Menu shortcuts<br>
<a class="Identifier" href="usr_31.html#31.4">31.4</a> Vim window position and size<br>
<a class="Identifier" href="usr_31.html#31.5">31.5</a> Various<br>
<br>
Next chapter: <a class="Identifier" href="usr_32.html">usr_32.txt</a> The undo tree<br>
Previous chapter: <a class="Identifier" href="usr_30.html">usr_30.txt</a> Editing programs<br>
Table of contents: <a class="Identifier" href="usr_toc.html">usr_toc.txt</a><br>
<br>
<span class="PreProc">==============================================================================</span><br>
<a class="Constant" href="usr_31.html#31.1" name="31.1">31.1</a> The file browser<br>
<br>
When using the File/Open... menu you get a file browser. This makes it easier<br>
to find the file you want to edit. But what if you want to split a window to<br>
edit another file? There is no menu entry for this. You could first use<br>
Window/Split and then File/Open..., but that's more work.<br>
Since you are typing most commands in Vim, opening the file browser with a<br>
typed command is possible as well. To make the split command use the file<br>
browser, prepend "browse":<br>
<br>
<div class="helpExample"> :browse split</div>
<br>
Select a file and then the ":split" command will be executed with it. If you<br>
cancel the file dialog nothing happens, the window isn't split.<br>
You can also specify a file name argument. This is used to tell the file<br>
browser where to start. Example:<br>
<br>
<div class="helpExample"> :browse split /etc</div>
<br>
The file browser will pop up, starting in the directory "/etc".<br>
<br>
The ":browse" command can be prepended to just about any command that opens a<br>
file.<br>
If no directory is specified, Vim will decide where to start the file<br>
browser. By default it uses the same directory as the last time. Thus when<br>
you used ":browse split" and selected a file in "/usr/local/share", the next<br>
time you use a ":browse" it will start in "/usr/local/share" again.<br>
This can be changed with the <a class="Type" href="options.html#'browsedir'">'browsedir'</a> option. It can have one of three<br>
values:<br>
<br>
last Use the last directory browsed (default)<br>
buffer Use the same directory as the current buffer<br>
current use the current directory<br>
<br>
For example, when you are in the directory "/usr", editing the file<br>
"/usr/local/share/readme", then the command:<br>
<br>
<div class="helpExample"> :set browsedir=buffer<br>
:browse edit</div>
<br>
Will start the browser in "/usr/local/share". Alternatively:<br>
<br>
<div class="helpExample"> :set browsedir=current<br>
:browse edit</div>
<br>
Will start the browser in "/usr".<br>
<br>
<span class="Todo">Note</span>:<br>
To avoid using the mouse, most file browsers offer using key presses<br>
to navigate. Since this is different for every system, it is not<br>
explained here. Vim uses a standard browser when possible, your<br>
system documentation should contain an explanation on the keyboard<br>
shortcuts somewhere.<br>
<br>
When you are not using the GUI version, you could use the file explorer window<br>
to select files like in a file browser. However, this doesn't work for the<br>
":browse" command. See <a class="Identifier" href="pi_netrw.html#netrw-browse">netrw-browse</a>.<br>
<br>
<span class="PreProc">==============================================================================</span><br>
<a class="Constant" href="usr_31.html#31.2" name="31.2">31.2</a> Confirmation<br>
<br>
Vim protects you from accidentally overwriting a file and other ways to lose<br>
changes. If you do something that might be a bad thing to do, Vim produces an<br>
error message and suggests appending ! if you really want to do it.<br>
To avoid retyping the command with the !, you can make Vim give you a<br>
dialog. You can then press "OK" or "Cancel" to tell Vim what you want.<br>
For example, you are editing a file and made changes to it. You start<br>
editing another file with:<br>
<br>
<div class="helpExample"> :confirm edit foo.txt</div>
<br>
Vim will pop up a dialog that looks something like this:<br>
<br>
+-----------------------------------+<br>
| |<br>
| ? Save changes to "bar.txt"? |<br>
| |<br>
| YES NO CANCEL |<br>
+-----------------------------------+<br>
<br>
Now make your choice. If you do want to save the changes, select "YES". If<br>
you want to lose the changes for ever: "NO". If you forgot what you were<br>
doing and want to check what really changed use "CANCEL". You will be back in<br>
the same file, with the changes still there.<br>
<br>
Just like ":browse", the ":confirm" command can be prepended to most commands<br>
that edit another file. They can also be combined:<br>
<br>
<div class="helpExample"> :confirm browse edit</div>
<br>
This will produce a dialog when the current buffer was changed. Then it will<br>
pop up a file browser to select the file to edit.<br>
<br>
<span class="Todo">Note</span>:<br>
In the dialog you can use the keyboard to select the choice.<br>
Typically the <span class="Special"><Tab></span> key and the cursor keys change the choice.<br>
Pressing <span class="Special"><Enter></span> selects the choice. This depends on the system<br>
though.<br>
<br>
When you are not using the GUI, the ":confirm" command works as well. Instead<br>
of popping up a dialog, Vim will print the message at the bottom of the Vim<br>
window and ask you to press a key to make a choice.<br>
<br>
<div class="helpExample"> :confirm edit main.c</div>
<span class="PreProc">Save changes to "Untitled"?</span><br>
<span class="PreProc">[Y]es, (N)o, (C)ancel: </span><br>
<br>
You can now press the single key for the choice. You don't have to press<br>
<span class="Special"><Enter></span>, unlike other typing on the command line.<br>
<br>
<span class="PreProc">==============================================================================</span><br>
<a class="Constant" href="usr_31.html#31.3" name="31.3">31.3</a> Menu shortcuts<br>
<br>
The keyboard is used for all Vim commands. The menus provide a simple way to<br>
select commands, without knowing what they are called. But you have to move<br>
your hand from the keyboard and grab the mouse.<br>
Menus can often be selected with keys as well. This depends on your<br>
system, but most often it works this way. Use the <span class="Special"><Alt></span> key in combination<br>
with the underlined letter of a menu. For example, <span class="Special"><A-w></span> (<span class="Special"><Alt></span> and w) pops<br>
up the Window menu.<br>
In the Window menu, the "split" item has the p underlined. To select it,<br>
let go of the <span class="Special"><Alt></span> key and press p.<br>
<br>
After the first selection of a menu with the <span class="Special"><Alt></span> key, you can use the cursor<br>
keys to move through the menus. <span class="Special"><Right></span> selects a submenu and <span class="Special"><left></span> closes<br>
it. <span class="Special"><Esc></span> also closes a menu. <span class="Special"><Enter></span> selects a menu item.<br>
<br>
There is a conflict between using the <span class="Special"><Alt></span> key to select menu items, and<br>
using <span class="Special"><Alt></span> key combinations for mappings. The <a class="Type" href="options.html#'winaltkeys'">'winaltkeys'</a> option tells Vim<br>
what it should do with the <span class="Special"><Alt></span> key.<br>
The default value "menu" is the smart choice: If the key combination is a<br>
menu shortcut it can't be mapped. All other keys are available for mapping.<br>
The value "no" doesn't use any <span class="Special"><Alt></span> keys for the menus. Thus you must use<br>
the mouse for the menus, and all <span class="Special"><Alt></span> keys can be mapped.<br>
The value "yes" means that Vim will use any <span class="Special"><Alt></span> keys for the menus. Some<br>
<span class="Special"><Alt></span> key combinations may also do other things than selecting a menu.<br>
<br>
<span class="PreProc">==============================================================================</span><br>
<a class="Constant" href="usr_31.html#31.4" name="31.4">31.4</a> Vim window position and size<br>
<br>
To see the current Vim window position on the screen use:<br>
<br>
<div class="helpExample"> :winpos</div>
<br>
This will only work in the GUI. The output may look like this:<br>
<br>
<span class="PreProc">Window position: X 272, Y 103</span><br>
<br>
The position is given in screen pixels. Now you can use the numbers to move<br>
Vim somewhere else. For example, to move it to the left a hundred pixels:<br>
<br>
<div class="helpExample"> :winpos 172 103</div>
<br>
<span class="Todo">Note</span>:<br>
There may be a small offset between the reported position and where<br>
the window moves. This is because of the border around the window.<br>
This is added by the window manager.<br>
<br>
You can use this command in your startup script to position the window at a<br>
specific position.<br>
<br>
The size of the Vim window is computed in characters. Thus this depends on<br>
the size of the font being used. You can see the current size with this<br>
command:<br>
<br>
<div class="helpExample"> :set lines columns</div>
<br>
To change the size set the <a class="Type" href="options.html#'lines'">'lines'</a> and/or <a class="Type" href="options.html#'columns'">'columns'</a> options to a new value:<br>
<br>
<div class="helpExample"> :set lines=50<br>
:set columns=80</div>
<br>
Obtaining the size works in a terminal just like in the GUI. Setting the size<br>
is not possible in most terminals.<br>
<br>
You can start the X-Windows version of gvim with an argument to specify the<br>
size and position of the window:<br>
<br>
<div class="helpExample"> gvim -geometry {width}x{height}+{x_offset}+{y_offset}</div>
<br>
<span class="Special">{width}</span> and <span class="Special">{height}</span> are in characters, {x_offset} and {y_offset} are in<br>
pixels. Example:<br>
<br>
<div class="helpExample"> gvim -geometry 80x25+100+300</div>
<br>
<span class="PreProc">==============================================================================</span><br>
<a class="Constant" href="usr_31.html#31.5" name="31.5">31.5</a> Various<br>
<br>
You can use gvim to edit an e-mail message. In your e-mail program you must<br>
select gvim to be the editor for messages. When you try that, you will<br>
see that it doesn't work: The mail program thinks that editing is finished,<br>
while gvim is still running!<br>
What happens is that gvim disconnects from the shell it was started in.<br>
That is fine when you start gvim in a terminal, so that you can do other work<br>
in that terminal. But when you really want to wait for gvim to finish, you<br>
must prevent it from disconnecting. The "-f" argument does this:<br>
<br>
<div class="helpExample"> gvim -f file.txt</div>
<br>
The "-f" stands for foreground. Now Vim will block the shell it was started<br>
in until you finish editing and exit.<br>
<br>
<br>
DELAYED START OF THE GUI<br>
<br>
On Unix it's possible to first start Vim in a terminal. That's useful if you<br>
do various tasks in the same shell. If you are editing a file and decide you<br>
want to use the GUI after all, you can start it with:<br>
<br>
<div class="helpExample"> :gui</div>
<br>
Vim will open the GUI window and no longer use the terminal. You can continue<br>
using the terminal for something else. The "-f" argument is used here to run<br>
the GUI in the foreground. You can also use ":gui -f".<br>
<br>
<br>
THE GVIM STARTUP FILE<br>
<br>
When gvim starts, it reads the gvimrc file. That's similar to the vimrc file<br>
used when starting Vim. The gvimrc file can be used for settings and commands<br>
that are only to be used when the GUI is going to be started. For example,<br>
you can set the <a class="Type" href="options.html#'lines'">'lines'</a> option to set a different window size:<br>
<br>
<div class="helpExample"> :set lines=55</div>
<br>
You don't want to do this in a terminal, since its size is fixed (except for<br>
an xterm that supports resizing).<br>
The gvimrc file is searched for in the same locations as the vimrc file.<br>
Normally its name is "~/.gvimrc" for Unix and "$VIM/_gvimrc" for MS-Windows.<br>
The $MYGVIMRC environment variable is set to it, thus you can use this command<br>
to edit the file, if you have one:<br>
<br>
<div class="helpExample"> :edit $MYGVIMRC</div>
<br>
If for some reason you don't want to use the normal gvimrc file, you can<br>
specify another one with the "-U" argument:<br>
<br>
<div class="helpExample"> gvim -U thisrc ...</div>
<br>
That allows starting gvim for different kinds of editing. You could set<br>
another font size, for example.<br>
To completely skip reading a gvimrc file:<br>
<br>
<div class="helpExample"> gvim -U NONE ...</div>
<br>
<span class="PreProc">==============================================================================</span><br>
<br>
Next chapter: <a class="Identifier" href="usr_32.html">usr_32.txt</a> The undo tree<br>
<br>
Copyright: see <a class="Identifier" href="usr_01.html#manual-copyright">manual-copyright</a> vim:tw=78:ts=8:ft=help:norl:<br>
</div>
</article>
<footer>
<a href="#top">Return to the top</a> - <a href="index.html">Return to main</a>
<span class="EnglishJapaneseLink">
<span class="CurrentLanguage">English</span>
</span>
<br />
<div style="text-align:right;">
Hosted by <a href="https://github.com/vim-jp/vimdoc-en">vimdoc-en project</a><br />
If you met any problem, please report it to <a href="https://github.com/vim-jp/vimdoc-en/issues">issue</a>.<br />
</div>
</footer>
<!--<script src="js/check-referrer.js" type="text/javascript"></script>-->
</body>
</html>
<!-- vim:set ts=8 sts=2 sw=2 tw=0 et: -->
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。