代码拉取完成,页面将自动刷新
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>develop - 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>
/ develop<br />
<a name="top"></a><h1>develop - 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="develop.html" name="develop.txt">develop.txt</a> For <span class="Identifier">Vim version 8.0.</span> Last change: 2017 Jul 31<br>
<br>
<br>
<span class="Identifier">VIM REFERENCE MANUAL by Bram Moolenaar</span><br>
<br>
<br>
Development of Vim. <a class="Constant" href="develop.html#development" name="development">development</a><br>
<br>
This text is important for those who want to be involved in further developing<br>
Vim.<br>
<br>
1. Design goals <a class="Identifier" href="develop.html#design-goals">design-goals</a><br>
2. Coding style <a class="Identifier" href="develop.html#coding-style">coding-style</a><br>
3. Design decisions <a class="Identifier" href="develop.html#design-decisions">design-decisions</a><br>
4. Assumptions <a class="Identifier" href="develop.html#design-assumptions">design-assumptions</a><br>
<br>
See the file README.txt in the "src" directory for an overview of the source<br>
code.<br>
<br>
Vim is open source software. Everybody is encouraged to contribute to help<br>
improving Vim. For sending patches a context diff "diff -c" is preferred.<br>
Also see <span class="Constant"><a href="http://vim.wikia.com/wiki/How_to_make_and_submit_a_patch">http://vim.wikia.com/wiki/How_to_make_and_submit_a_patch</a></span>.<br>
<br>
<span class="PreProc">==============================================================================</span><br>
1. Design goals <a class="Constant" href="develop.html#design-goals" name="design-goals">design-goals</a><br>
<br>
Most important things come first (roughly).<br>
<br>
<span class="Todo">Note</span> that quite a few items are contradicting. This is intentional. A<br>
balance must be found between them.<br>
<br>
<br>
<span class="Statement">VIM IS... VI COMPATIBLE </span><a class="Constant" href="develop.html#design-compatible" name="design-compatible">design-compatible</a><br>
<br>
First of all, it should be possible to use Vim as a drop-in replacement for<br>
Vi. When the user wants to, he can use Vim in compatible mode and hardly<br>
notice any difference with the original Vi.<br>
<br>
Exceptions:<br>
- We don't reproduce obvious Vi bugs in Vim.<br>
- There are different versions of Vi. I am using Version 3.7 (6/7/85) as a<br>
reference. But support for other versions is also included when possible.<br>
The Vi part of POSIX is not considered a definitive source.<br>
- Vim adds new commands, you cannot rely on some command to fail because it<br>
didn't exist in Vi.<br>
- Vim will have a lot of features that Vi doesn't have. Going back from Vim<br>
to Vi will be a problem, this cannot be avoided.<br>
- Some things are hardly ever used (open mode, sending an e-mail when<br>
crashing, etc.). Those will only be included when someone has a good reason<br>
why it should be included and it's not too much work.<br>
- For some items it is debatable whether Vi compatibility should be<br>
maintained. There will be an option flag for these.<br>
<br>
<br>
<span class="Statement">VIM IS... IMPROVED </span><a class="Constant" href="develop.html#design-improved" name="design-improved">design-improved</a><br>
<br>
The IMproved bits of Vim should make it a better Vi, without becoming a<br>
completely different editor. Extensions are done with a "Vi spirit".<br>
- Use the keyboard as much as feasible. The mouse requires a third hand,<br>
which we don't have. Many terminals don't have a mouse.<br>
- When the mouse is used anyway, avoid the need to switch back to the<br>
keyboard. Avoid mixing mouse and keyboard handling.<br>
- Add commands and options in a consistent way. Otherwise people will have a<br>
hard time finding and remembering them. Keep in mind that more commands and<br>
options will be added later.<br>
- A feature that people do not know about is a useless feature. Don't add<br>
obscure features, or at least add hints in documentation that they exist.<br>
- Minimize using CTRL and other modifiers, they are more difficult to type.<br>
- There are many first-time and inexperienced Vim users. Make it easy for<br>
them to start using Vim and learn more over time.<br>
- There is no limit to the features that can be added. Selecting new features<br>
is one based on (1) what users ask for, (2) how much effort it takes to<br>
implement and (3) someone actually implementing it.<br>
<br>
<br>
<span class="Statement">VIM IS... MULTI PLATFORM </span><a class="Constant" href="develop.html#design-multi-platform" name="design-multi-platform">design-multi-platform</a><br>
<br>
Vim tries to help as many users on as many platforms as possible.<br>
- Support many kinds of terminals. The minimal demands are cursor positioning<br>
and clear-screen. Commands should only use key strokes that most keyboards<br>
have. Support all the keys on the keyboard for mapping.<br>
- Support many platforms. A condition is that there is someone willing to do<br>
Vim development on that platform, and it doesn't mean messing up the code.<br>
- Support many compilers and libraries. Not everybody is able or allowed to<br>
install another compiler or GUI library.<br>
- People switch from one platform to another, and from GUI to terminal<br>
version. Features should be present in all versions, or at least in as many<br>
as possible with a reasonable effort. Try to avoid that users must switch<br>
between platforms to accomplish their work efficiently.<br>
- That a feature is not possible on some platforms, or only possible on one<br>
platform, does not mean it cannot be implemented. [This intentionally<br>
contradicts the previous item, these two must be balanced.]<br>
<br>
<br>
<span class="Statement">VIM IS... WELL DOCUMENTED </span><a class="Constant" href="develop.html#design-documented" name="design-documented">design-documented</a><br>
<br>
- A feature that isn't documented is a useless feature. A patch for a new<br>
feature must include the documentation.<br>
- Documentation should be comprehensive and understandable. Using examples is<br>
recommended.<br>
- Don't make the text unnecessarily long. Less documentation means that an<br>
item is easier to find.<br>
<br>
<br>
<span class="Statement">VIM IS... HIGH SPEED AND SMALL IN SIZE </span><a class="Constant" href="develop.html#design-speed-size" name="design-speed-size">design-speed-size</a><br>
<br>
Using Vim must not be a big attack on system resources. Keep it small and<br>
fast.<br>
- Computers are becoming faster and bigger each year. Vim can grow too, but<br>
no faster than computers are growing. Keep Vim usable on older systems.<br>
- Many users start Vim from a shell very often. Startup time must be short.<br>
- Commands must work efficiently. The time they consume must be as small as<br>
possible. Useful commands may take longer.<br>
- Don't forget that some people use Vim over a slow connection. Minimize the<br>
communication overhead.<br>
- Items that add considerably to the size and are not used by many people<br>
should be a feature that can be disabled.<br>
- Vim is a component among other components. Don't turn it into a massive<br>
application, but have it work well together with other programs.<br>
<br>
<br>
<span class="Statement">VIM IS... MAINTAINABLE </span><a class="Constant" href="develop.html#design-maintain" name="design-maintain">design-maintain</a><br>
<br>
- The source code should not become a mess. It should be reliable code.<br>
- Use the same layout in all files to make it easy to read <a class="Identifier" href="develop.html#coding-style">coding-style</a>.<br>
- Use comments in a useful way! Quoting the function name and argument names<br>
is NOT useful. Do explain what they are for.<br>
- Porting to another platform should be made easy, without having to change<br>
too much platform-independent code.<br>
- Use the object-oriented spirit: Put data and code together. Minimize the<br>
knowledge spread to other parts of the code.<br>
<br>
<br>
<span class="Statement">VIM IS... FLEXIBLE </span><a class="Constant" href="develop.html#design-flexible" name="design-flexible">design-flexible</a><br>
<br>
Vim should make it easy for users to work in their preferred styles rather<br>
than coercing its users into particular patterns of work. This can be for<br>
items with a large impact (e.g., the <a class="Type" href="options.html#'compatible'">'compatible'</a> option) or for details. The<br>
defaults are carefully chosen such that most users will enjoy using Vim as it<br>
is. Commands and options can be used to adjust Vim to the desire of the user<br>
and its environment.<br>
<br>
<br>
<span class="Statement">VIM IS... NOT </span><a class="Constant" href="develop.html#design-not" name="design-not">design-not</a><br>
<br>
- Vim is not a shell or an Operating System. It does provide a terminal<br>
window, in which you can run a shell or debugger. E.g. to be able to do<br>
this over an ssh connection. But if you don't need a text editor with that<br>
it is out of scope (use something like screen or tmux instead).<br>
A satirical way to say this: "Unlike Emacs, Vim does not attempt to include<br>
everything but the kitchen sink, but some people say that you can clean one<br>
with it. ;-)"<br>
To use Vim with gdb see: <span class="Constant"><a href="http://www.agide.org">http://www.agide.org</a></span> and <span class="Constant"><a href="http://clewn.sf.net">http://clewn.sf.net</a></span>.<br>
- Vim is not a fancy GUI editor that tries to look nice at the cost of<br>
being less consistent over all platforms. But functional GUI features are<br>
welcomed.<br>
<br>
<span class="PreProc">==============================================================================</span><br>
2. Coding style <a class="Constant" href="develop.html#coding-style" name="coding-style">coding-style</a><br>
<br>
These are the rules to use when making changes to the Vim source code. Please<br>
stick to these rules, to keep the sources readable and maintainable.<br>
<br>
This list is not complete. Look in the source code for more examples.<br>
<br>
<br>
<span class="Statement">MAKING CHANGES </span><a class="Constant" href="develop.html#style-changes" name="style-changes">style-changes</a><br>
<br>
The basic steps to make changes to the code:<br>
1. Get the code from github. That makes it easier to keep your changed<br>
version in sync with the main code base (it may be a while before your<br>
changes will be included). You do need to spend some time learning git,<br>
it's not the most user friendly tool.<br>
2. Adjust the documentation. Doing this first gives you an impression of how<br>
your changes affect the user.<br>
3. Make the source code changes.<br>
4. Check ../doc/todo.txt if the change affects any listed item.<br>
5. Make a patch with "git diff". You can also create a pull request on<br>
github, but it's the diff that matters.<br>
6. Make a <span class="Todo">note</span> about what changed, preferably mentioning the problem and the<br>
solution. Send an email to the <a class="Identifier" href="intro.html#vim-dev">vim-dev</a> maillist with an explanation and<br>
include the diff. Or create a pull request on github.<br>
<br>
<br>
<span class="Statement">C COMPILER </span><a class="Constant" href="develop.html#style-compiler" name="style-compiler">style-compiler</a><br>
<br>
The minimal C compiler version supported is C89, also known as ANSI C.<br>
Later standards don't add much and C89 is the widest supported.<br>
<br>
One restriction that this implies: no // comments, only /* comments */.<br>
<br>
<br>
<span class="Statement">USE OF COMMON FUNCTIONS </span><a class="Constant" href="develop.html#style-functions" name="style-functions">style-functions</a><br>
<br>
Some functions that are common to use, have a special Vim version. Always<br>
consider using the Vim version, because they were introduced with a reason.<br>
<br>
NORMAL NAME VIM NAME DIFFERENCE OF VIM VERSION<br>
free() vim_free() Checks for freeing NULL<br>
malloc() alloc() Checks for out of memory situation<br>
malloc() lalloc() Like alloc(), but has long argument<br>
strcpy() STRCPY() Includes cast to (char *), for char_u * args<br>
strchr() vim_strchr() Accepts special characters<br>
strrchr() vim_strrchr() Accepts special characters<br>
isspace() vim_isspace() Can handle characters > 128<br>
iswhite() vim_iswhite() Only TRUE for tab and space<br>
memcpy() mch_memmove() Handles overlapped copies<br>
bcopy() mch_memmove() Handles overlapped copies<br>
memset() vim_memset() Uniform for all systems<br>
<br>
<br>
<span class="Statement">NAMES </span><a class="Constant" href="develop.html#style-names" name="style-names">style-names</a><br>
<br>
Function names can not be more than 31 characters long (because of VMS).<br>
<br>
Don't use "delete" or "this" as a variable name, C++ doesn't like it.<br>
<br>
Because of the requirement that Vim runs on as many systems as possible, we<br>
need to avoid using names that are already defined by the system. This is a<br>
list of names that are known to cause trouble. The name is given as a regexp<br>
pattern.<br>
<br>
is.*() POSIX, ctype.h<br>
to.*() POSIX, ctype.h<br>
<br>
d_.* POSIX, dirent.h<br>
l_.* POSIX, fcntl.h<br>
gr_.* POSIX, grp.h<br>
pw_.* POSIX, pwd.h<br>
sa_.* POSIX, signal.h<br>
mem.* POSIX, string.h<br>
str.* POSIX, string.h<br>
wcs.* POSIX, string.h<br>
st_.* POSIX, stat.h<br>
tms_.* POSIX, times.h<br>
tm_.* POSIX, time.h<br>
c_.* POSIX, termios.h<br>
MAX.* POSIX, limits.h<br>
__.* POSIX, system<br>
_[A-Z].* POSIX, system<br>
E[A-Z0-9]* POSIX, errno.h<br>
<br>
.*_t POSIX, for typedefs. Use .*_T instead.<br>
<br>
wait don't use as argument to a function, conflicts with types.h<br>
index shadows global declaration<br>
time shadows global declaration<br>
new C++ reserved keyword<br>
try Borland C++ doesn't like it to be used as a variable.<br>
<br>
clear Mac curses.h<br>
echo Mac curses.h<br>
instr Mac curses.h<br>
meta Mac curses.h<br>
newwin Mac curses.h<br>
nl Mac curses.h<br>
overwrite Mac curses.h<br>
refresh Mac curses.h<br>
scroll Mac curses.h<br>
typeahead Mac curses.h<br>
<br>
basename() GNU string function<br>
dirname() GNU string function<br>
get_env_value() Linux system function<br>
<br>
<br>
<span class="Statement">VARIOUS </span><a class="Constant" href="develop.html#style-various" name="style-various">style-various</a><br>
<br>
Typedef'ed names should end in "_T":<br>
<div class="helpExample"> typedef int some_T;</div>
Define'ed names should be uppercase:<br>
<div class="helpExample"> #define SOME_THING</div>
Features always start with "FEAT_":<br>
<div class="helpExample"> #define FEAT_FOO</div>
<br>
Don't use '\"', some compilers can't handle it. '"' works fine.<br>
<br>
Don't use:<br>
#if HAVE_SOME<br>
Some compilers can't handle that and complain that "HAVE_SOME" is not defined.<br>
Use<br>
#ifdef HAVE_SOME<br>
or<br>
#if defined(HAVE_SOME)<br>
<br>
<br>
<span class="Statement">STYLE </span><a class="Constant" href="develop.html#style-examples" name="style-examples">style-examples</a><br>
<br>
General rule: One statement per line.<br>
<br>
Wrong: if (cond) a = 1;<br>
<br>
OK: if (cond)<br>
a = 1;<br>
<br>
Wrong: while (cond);<br>
<br>
OK: while (cond)<br>
;<br>
<br>
Wrong: do a = 1; while (cond);<br>
<br>
OK: do<br>
a = 1;<br>
while (cond);<br>
<br>
Wrong: if (cond) {<br>
cmd;<br>
cmd;<br>
} else {<br>
cmd;<br>
cmd;<br>
}<br>
<br>
OK: if (cond)<br>
{<br>
cmd;<br>
cmd;<br>
}<br>
else<br>
{<br>
cmd;<br>
cmd;<br>
}<br>
<br>
Use ANSI (new style) function declarations with the return type on a separate<br>
indented line.<br>
<br>
Wrong: int function_name(int arg1, int arg2)<br>
<br>
OK: /*<br>
* Explanation of what this function is used for.<br>
*<br>
* Return value explanation.<br>
*/<br>
int<br>
function_name(<br>
int arg1, /* short comment about arg1 */<br>
int arg2) /* short comment about arg2 */<br>
{<br>
int local; /* comment about local */<br>
<br>
local = arg1 * arg2;<br>
<br>
<br>
<br>
<span class="Statement">SPACES AND PUNCTUATION </span><a class="Constant" href="develop.html#style-spaces" name="style-spaces">style-spaces</a><br>
<br>
No space between a function name and the bracket:<br>
<br>
Wrong: func (arg);<br>
OK: func(arg);<br>
<br>
Do use a space after if, while, switch, etc.<br>
<br>
Wrong: if(arg) for(;;)<br>
OK: if (arg) for (;;)<br>
<br>
Use a space after a comma and semicolon:<br>
<br>
Wrong: func(arg1,arg2); for (i = 0;i < 2;++i)<br>
OK: func(arg1, arg2); for (i = 0; i < 2; ++i)<br>
<br>
Use a space before and after '=', '+', '/', etc.<br>
<br>
Wrong: var=a*5;<br>
OK: var = a * 5;<br>
<br>
In general: Use empty lines to group lines of code together. Put a comment<br>
just above the group of lines. This makes it easier to quickly see what is<br>
being done.<br>
<br>
OK: /* Prepare for building the table. */<br>
get_first_item();<br>
table_idx = 0;<br>
<br>
/* Build the table */<br>
while (has_item())<br>
table[table_idx++] = next_item();<br>
<br>
/* Finish up. */<br>
cleanup_items();<br>
generate_hash(table);<br>
<br>
<span class="PreProc">==============================================================================</span><br>
3. Design decisions <a class="Constant" href="develop.html#design-decisions" name="design-decisions">design-decisions</a><br>
<br>
Folding<br>
<br>
Several forms of folding should be possible for the same buffer. For example,<br>
have one window that shows the text with function bodies folded, another<br>
window that shows a function body.<br>
<br>
Folding is a way to display the text. It should not change the text itself.<br>
Therefore the folding has been implemented as a filter between the text stored<br>
in a buffer (buffer lines) and the text displayed in a window (logical lines).<br>
<br>
<br>
Naming the window<br>
<br>
The word "window" is commonly used for several things: A window on the screen,<br>
the xterm window, a window inside Vim to view a buffer.<br>
To avoid confusion, other items that are sometimes called window have been<br>
given another name. Here is an overview of the related items:<br>
<br>
screen The whole display. For the GUI it's something like 1024x768<br>
pixels. The Vim shell can use the whole screen or part of it.<br>
shell The Vim application. This can cover the whole screen (e.g.,<br>
when running in a console) or part of it (xterm or GUI).<br>
window View on a buffer. There can be several windows in Vim,<br>
together with the command line, menubar, toolbar, etc. they<br>
fit in the shell.<br>
<br>
<br>
Spell checking <a class="Constant" href="develop.html#develop-spell" name="develop-spell">develop-spell</a><br>
<br>
When spell checking was going to be added to Vim a survey was done over the<br>
available spell checking libraries and programs. Unfortunately, the result<br>
was that none of them provided sufficient capabilities to be used as the spell<br>
checking engine in Vim, for various reasons:<br>
<br>
- Missing support for multi-byte encodings. At least UTF-8 must be supported,<br>
so that more than one language can be used in the same file.<br>
Doing on-the-fly conversion is not always possible (would require iconv<br>
support).<br>
- For the programs and libraries: Using them as-is would require installing<br>
them separately from Vim. That's mostly not impossible, but a drawback.<br>
- Performance: A few tests showed that it's possible to check spelling on the<br>
fly (while redrawing), just like syntax highlighting. But the mechanisms<br>
used by other code are much slower. Myspell uses a hashtable, for example.<br>
The affix compression that most spell checkers use makes it slower too.<br>
- For using an external program like aspell a communication mechanism would<br>
have to be setup. That's complicated to do in a portable way (Unix-only<br>
would be relatively simple, but that's not good enough). And performance<br>
will become a problem (lots of process switching involved).<br>
- Missing support for words with non-word characters, such as "Etten-Leur" and<br>
"et al.", would require marking the pieces of them OK, lowering the<br>
reliability.<br>
- Missing support for regions or dialects. Makes it difficult to accept<br>
all English words and highlight non-Canadian words differently.<br>
- Missing support for rare words. Many words are correct but hardly ever used<br>
and could be a misspelled often-used word.<br>
- For making suggestions the speed is less important and requiring to install<br>
another program or library would be acceptable. But the word lists probably<br>
differ, the suggestions may be wrong words.<br>
<br>
<br>
Spelling suggestions <a class="Constant" href="develop.html#develop-spell-suggestions" name="develop-spell-suggestions">develop-spell-suggestions</a><br>
<br>
For making suggestions there are two basic mechanisms:<br>
1. Try changing the bad word a little bit and check for a match with a good<br>
word. Or go through the list of good words, change them a little bit and<br>
check for a match with the bad word. The changes are deleting a character,<br>
inserting a character, swapping two characters, etc.<br>
2. Perform soundfolding on both the bad word and the good words and then find<br>
matches, possibly with a few changes like with the first mechanism.<br>
<br>
The first is good for finding typing mistakes. After experimenting with<br>
hashtables and looking at solutions from other spell checkers the conclusion<br>
was that a trie (a kind of tree structure) is ideal for this. Both for<br>
reducing memory use and being able to try sensible changes. For example, when<br>
inserting a character only characters that lead to good words need to be<br>
tried. Other mechanisms (with hashtables) need to try all possible letters at<br>
every position in the word. Also, a hashtable has the requirement that word<br>
boundaries are identified separately, while a trie does not require this.<br>
That makes the mechanism a lot simpler.<br>
<br>
Soundfolding is useful when someone knows how the words sounds but doesn't<br>
know how it is spelled. For example, the word "dictionary" might be written<br>
as "daktonerie". The number of changes that the first method would need to<br>
try is very big, it's hard to find the good word that way. After soundfolding<br>
the words become "tktnr" and "tkxnry", these differ by only two letters.<br>
<br>
To find words by their soundfolded equivalent (soundalike word) we need a list<br>
of all soundfolded words. A few experiments have been done to find out what<br>
the best method is. Alternatives:<br>
1. Do the sound folding on the fly when looking for suggestions. This means<br>
walking through the trie of good words, soundfolding each word and<br>
checking how different it is from the bad word. This is very efficient for<br>
memory use, but takes a long time. On a fast PC it takes a couple of<br>
seconds for English, which can be acceptable for interactive use. But for<br>
some languages it takes more than ten seconds (e.g., German, Catalan),<br>
which is unacceptable slow. For batch processing (automatic corrections)<br>
it's too slow for all languages.<br>
2. Use a trie for the soundfolded words, so that searching can be done just<br>
like how it works without soundfolding. This requires remembering a list<br>
of good words for each soundfolded word. This makes finding matches very<br>
fast but requires quite a lot of memory, in the order of 1 to 10 Mbyte.<br>
For some languages more than the original word list.<br>
3. Like the second alternative, but reduce the amount of memory by using affix<br>
compression and store only the soundfolded basic word. This is what Aspell<br>
does. Disadvantage is that affixes need to be stripped from the bad word<br>
before soundfolding it, which means that mistakes at the start and/or end<br>
of the word will cause the mechanism to fail. Also, this becomes slow when<br>
the bad word is quite different from the good word.<br>
<br>
The choice made is to use the second mechanism and use a separate file. This<br>
way a user with sufficient memory can get very good suggestions while a user<br>
who is short of memory or just wants the spell checking and no suggestions<br>
doesn't use so much memory.<br>
<br>
<br>
Word frequency<br>
<br>
For sorting suggestions it helps to know which words are common. In theory we<br>
could store a word frequency with the word in the dictionary. However, this<br>
requires storing a count per word. That degrades word tree compression a lot.<br>
And maintaining the word frequency for all languages will be a heavy task.<br>
Also, it would be nice to prefer words that are already in the text. This way<br>
the words that appear in the specific text are preferred for suggestions.<br>
<br>
What has been implemented is to count words that have been seen during<br>
displaying. A hashtable is used to quickly find the word count. The count is<br>
initialized from words listed in COMMON items in the affix file, so that it<br>
also works when starting a new file.<br>
<br>
This isn't ideal, because the longer Vim is running the higher the counts<br>
become. But in practice it is a noticeable improvement over not using the word<br>
count.<br>
<br>
<span class="PreProc">==============================================================================</span><br>
4. Assumptions <a class="Constant" href="develop.html#design-assumptions" name="design-assumptions">design-assumptions</a><br>
<br>
Size of variables:<br>
char 8 bit signed<br>
char_u 8 bit unsigned<br>
int 32 or 64 bit signed (16 might be possible with limited features)<br>
unsigned 32 or 64 bit unsigned (16 as with ints)<br>
long 32 or 64 bit signed, can hold a pointer<br>
<br>
<span class="Todo">Note</span> that some compilers cannot handle long lines or strings. The C89<br>
standard specifies a limit of 509 characters.<br>
<br>
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: -->
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。