comparison runtime/doc/insert.txt @ 859:99305c4c42d4

updated for version 7.0g02
author vimboss
date Wed, 03 May 2006 21:26:49 +0000
parents b933657f7c9d
children a5677b7ce858
comparison
equal deleted inserted replaced
858:ca82de29ac19 859:99305c4c42d4
1 *insert.txt* For Vim version 7.0g. Last change: 2006 May 01 1 *insert.txt* For Vim version 7.0g. Last change: 2006 May 03
2 2
3 3
4 VIM REFERENCE MANUAL by Bram Moolenaar 4 VIM REFERENCE MANUAL by Bram Moolenaar
5 5
6 6
917 Completion is done by a function that can be defined by the user with the 917 Completion is done by a function that can be defined by the user with the
918 'omnifunc' option. This is to be used for filetype-specific completion. 918 'omnifunc' option. This is to be used for filetype-specific completion.
919 919
920 See below for how the function is called and an example |complete-functions|. 920 See below for how the function is called and an example |complete-functions|.
921 For remarks about specific filetypes see |compl-omni-filetypes|. 921 For remarks about specific filetypes see |compl-omni-filetypes|.
922 More completion scripts will appear, check www.vim.org. Currently there is a
923 first version for C++.
922 924
923 *i_CTRL-X_CTRL-O* 925 *i_CTRL-X_CTRL-O*
924 CTRL-X CTRL-O Guess what kind of item is in front of the cursor and 926 CTRL-X CTRL-O Guess what kind of item is in front of the cursor and
925 find the first match for it. 927 find the first match for it.
926 CTRL-O or 928 CTRL-O or
1270 run |:make| command to detect formatting problems. 1272 run |:make| command to detect formatting problems.
1271 1273
1272 1274
1273 HTML flavor *html-flavor* 1275 HTML flavor *html-flavor*
1274 1276
1275 Default HTML completion depends on filetype. For HTML files it is HTML 1277 The default HTML completion depends on the filetype. For HTML files it is
1276 4.01 Transitional (&ft=='html'), for XHTML it is XHTML 1.0 Strict 1278 HTML 4.01 Transitional ('filetype' is "html"), for XHTML it is XHTML 1.0
1277 (&ft=='xhtml'). 1279 Strict ('filetype' is "xhtml").
1278 1280
1279 These are not the only HTML versions. To use another data file and still 1281 When doing completion outside of any other tag you will have possibility to
1280 have benefits of custom completion for class, style, etc. attributes set 1282 choose DOCTYPE and the appropriate data file will be loaded and used for all
1281 b:html_omni_flavor variable. Example (in .vimrc or filetype plugin 1283 next completions.
1282 file): > 1284
1283 1285 More about format of data file in |xml-omni-datafile|. Some of the data files
1284 let g:html_omni_flavor = 'xhtml10s' 1286 may be found on the Vim website (|www|).
1285 1287
1286 (Completion data file for HTML 4.01 Strict is also provided by Vim 1288 Note that b:html_omni_flavor may point to a file with any XML data. This
1287 distribution.) 1289 makes possible to mix PHP (|ft-php-omni|) completion with any XML dialect
1288 1290 (assuming you have data file for it). Without setting that variable XHTML 1.0
1289 Data for HTML completion will be read from 'autoload/xml/html10s.vim' file 1291 Strict will be used.
1290 located somewhere in 'runtimepath'.
1291
1292 Note: HTML completion files are also located in 'autoload/xml'
1293 directory.
1294
1295 More about format of data file in |xml-omni-datafile|. Some of data
1296 files may in future be found on vim-online site (|www|).
1297
1298 Note that b:html_omni_flavor may point to file with any XML data. This
1299 makes possible to mix PHP (|ft-php-omni|) completion with whatever XML
1300 dialect (assuming you have data file for it).
1301 1292
1302 1293
1303 JAVASCRIPT *ft-javascript-omni* 1294 JAVASCRIPT *ft-javascript-omni*
1304 1295
1305 Completion of most elements of JavaScript language and DOM elements. 1296 Completion of most elements of JavaScript language and DOM elements.
1484 PHP code and SQL code at the same time. 1475 PHP code and SQL code at the same time.
1485 1476
1486 1477
1487 XML *ft-xml-omni* 1478 XML *ft-xml-omni*
1488 1479
1489 Vim 7 provides mechanism to context aware completion of XML files. It depends 1480 Vim 7 provides a mechanism for context aware completion of XML files. It
1490 on special |xml-omni-datafile| and two commands: |:XMLns| and |:XMLent|. 1481 depends on a special |xml-omni-datafile| and two commands: |:XMLns| and
1491 Features are: 1482 |:XMLent|. Features are:
1492 1483
1493 - after "<" complete tag name depending on context (no div suggest 1484 - after "<" complete the tag name, depending on context
1494 inside of an a tag) 1485 - inside of a tag complete proper attributes
1495 - inside of tag complete proper attributes (no width attribute for an 1486 - when an attribute has a limited number of possible values help to complete
1496 a tag)
1497 - when attribute has limited number of possible values help to complete
1498 them 1487 them
1499 - complete names of entities (defined in |xml-omni-datafile| and in current 1488 - complete names of entities (defined in |xml-omni-datafile| and in the
1500 file with "<!ENTITY" declarations 1489 current file with "<!ENTITY" declarations)
1501 - when used after "</" CTRL-X CTRL-O will close the last opened tag 1490 - when used after "</" CTRL-X CTRL-O will close the last opened tag
1502 1491
1503 Format of XML data file *xml-omni-datafile* 1492 Format of XML data file *xml-omni-datafile*
1504 1493
1505 Vim distribution provides two data files as examples (xhtml10s.vim, xsl.vim) 1494 XML data files are stored in the "autoload/xml" directory in 'runtimepath'.
1506 1495 Vim distribution provides examples of data files in the
1507 XML data files are stored in "autoload/xml" directory in 'runtimepath'. They 1496 "$VIMRUNTIME/autoload/xml" directory. They have a meaningful name which will
1508 have meaningful name which will be used in commands. It should be unique name 1497 be used in commands. It should be a unique name which will not create
1509 which will not create conflicts in future. For example name xhtml10s.vim means 1498 conflicts. For example, the name xhtml10s.vim means it is the data file for
1510 it is data file for XHTML 1.0 Strict. 1499 XHTML 1.0 Strict.
1511 1500
1512 File contains one variable with fixed name: g:xmldata_xhtml10s . It is 1501 Each file contains a variable with a name like g:xmldata_xhtml10s . It is
1513 compound from two parts: 1502 a compound from two parts:
1514 1503
1515 1. "g:xmldata_" general prefix 1504 1. "g:xmldata_" general prefix, constant for all data files
1516 2. "xhtml10s" name of file and name of described XML dialect 1505 2. "xhtml10s" the name of the file and the name of the described XML
1506 dialect; it will be used as an argument for the |:XMLns|
1507 command
1517 1508
1518 Part two must be exactly the same as name of file. 1509 Part two must be exactly the same as name of file.
1519 1510
1520 Variable is data structure in form of |Dictionary|. Keys are tag names and 1511 The variable is a |Dictionary|. Keys are tag names and each value is a two
1521 values are two element |List|. First element of List is also List with names 1512 element |List|. The first element of the List is also a List with the names
1522 of possible children, second element is |Dictionary| with names of attributes 1513 of possible children. The second element is a |Dictionary| with the names of
1523 as keys and possible values of attributes as values. Example: > 1514 attributes as keys and the possible values of attributes as values. Example: >
1524 1515
1525 let g:xmldata_crippledhtml = { 1516 let g:xmldata_crippled = {
1526 \ "html": 1517 \ "vimxmlentities": ["amp", "lt", "gt", "apos", "quot"],
1527 \ [ ["body", "head"], {"id": [], "xmlns": ["http://www.w3.org/1999/xhtml"], 1518 \ 'vimxmlroot': ['tag1'],
1528 \ "lang": [], "xml:lang": [], "dir": ["ltr", "rtl"]}], 1519 \ 'tag1':
1529 \ "script": 1520 \ [ ['childoftag1a', 'childoftag1b'], {'attroftag1a': [],
1530 \ [ [], {"id": [], "charset": [], "type": ["text/javascript"], "src": [], 1521 \ 'attroftag1b': ['valueofattr1', 'valueofattr2']}],
1531 \ "defer": ["BOOL"], "xml:space": ["preserve"]}], 1522 \ 'childoftag1a':
1532 \ "meta": 1523 \ [ [], {'attrofchild': ['attrofchild']}],
1533 \ [ [], {"id": [], "http-equiv": [], "name": [], "content": [], "scheme": 1524 \ 'childoftag1b':
1534 \ [], "lang": [], "xml:lang": [], "dir": ["ltr", "rtl"]}] 1525 \ [ ['childoftag1a'], {'attrofchild': []}],
1535 \ "vimxmlentities": ["amp", "lt", "gt", "apos", "quot"]},
1536 \ "vimxmltaginfo": { 1526 \ "vimxmltaginfo": {
1537 \ 'meta': ['/>', '']}, 1527 \ 'tag1': ['Menu info', 'Long information visible in preview window']},
1538 \ "vimxmlattrinfo": { 1528 \ 'vimxmlattrinfo': {
1539 \ 'http-equiv': ['ContentType', '']} 1529 \ 'attrofchild': ['Menu info', 'Long information visible in preview window']}}
1540 1530
1541 This example should be put in "autoload/xml/crippledhtml.vim" file. 1531 This example would be put in the "autoload/xml/crippled.vim" file and could
1542 1532 help to write this file: >
1543 In example are visible four special elements: 1533
1544 1534 <tag1 attroftag1b="valueofattr1">
1545 1. "vimxmlentities" - special key with List containing entities of this XML 1535 <childoftag1a attrofchild>
1536 &amp; &lt;
1537 </childoftag1a>
1538 <childoftag1b attrofchild="5">
1539 <childoftag1a>
1540 &gt; &apos; &quot;
1541 </childoftag1a>
1542 </childoftag1b>
1543 </tag1>
1544
1545 In the example four special elements are visible:
1546
1547 1. "vimxmlentities" - a special key with List containing entities of this XML
1546 dialect. 1548 dialect.
1547 2. "BOOL" - value of attribute key showing if attribute should be inserted 1549 2. If the list containing possible values of attributes has one element and
1548 bare ("defer" vs. 'defer="'). It can be the only element of List of 1550 this element is equal to the name of the attribute this attribute will be
1549 attribute values. 1551 treated as boolean and inserted as 'attrname' and not as 'attrname="'
1550 3. "vimxmltaginfo" - special key with dictionary containing as key tag names, 1552 3. "vimxmltaginfo" - a special key with a Dictionary containing tag
1551 as value two element List for additional menu info and long description. 1553 names as keys and two element List as values, for additional menu info and
1552 4. "vimxmlattrinfo" - special key with dictionary containing as key attribute 1554 the long description.
1553 names, as value two element List for additional menu info and long 1555 4. "vimxmlattrinfo" - special key with Dictionary containing attribute names
1556 as keys and two element List as values, for additional menu info and long
1554 description. 1557 description.
1555 1558
1556 Note: Tag names in data file MUST not contain namespace description. Check 1559 Note: Tag names in the data file MUST not contain a namespace description.
1557 xsl.vim for example. 1560 Check xsl.vim for an example.
1561 Note: All data and functions are publicly available as global
1562 variables/functions and can be used for personal editing functions.
1558 1563
1559 1564
1560 DTD -> Vim *dtd2vim* 1565 DTD -> Vim *dtd2vim*
1561 1566
1562 On |www| is script |dtd2vim| which parses DTD and creates XML data file 1567 On |www| is the script |dtd2vim| which parses DTD and creates an XML data file
1563 for Vim XML omni completion. 1568 for Vim XML omni completion.
1564 1569
1565 dtd2vim: http://www.vim.org/scripts/script.php?script_id=1462 1570 dtd2vim: http://www.vim.org/scripts/script.php?script_id=1462
1566 1571
1567 Check there and beginning of file for details of usage. 1572 Check the beginning of that file for usage details.
1568 Script requires perl and: 1573 The script requires perl and:
1569 1574
1570 perlSGML: http://savannah.nongnu.org/projects/perlsgml 1575 perlSGML: http://savannah.nongnu.org/projects/perlsgml
1571 1576
1572 1577
1573 Commands 1578 Commands
1574 1579
1575 :XMLns {name} [{namespace}] *:XMLns* 1580 :XMLns {name} [{namespace}] *:XMLns*
1576 1581
1577 Vim has to know which data file should be used and with which namespace. For 1582 Vim has to know which data file should be used and with which namespace. For
1578 loading of data file and connecting data with prope namespace use |:XMLns| 1583 loading of the data file and connecting data with the proper namespace use
1579 command. First (obligatory) argument is name of data (xhtml10s, xsl). Second 1584 |:XMLns| command. The first (obligatory) argument is the name of the data
1580 argument is code of namespace (h, xsl). When used without second argument 1585 (xhtml10s, xsl). The second argument is the code of namespace (h, xsl). When
1581 dialect will be used as default - without namespace declaration. For example 1586 used without a second argument the dialect will be used as default - without
1582 to use XML completion in .xsl files: > 1587 namespace declaration. For example to use XML completion in .xsl files: >
1583 1588
1584 :XMLns xhtml10s 1589 :XMLns xhtml10s
1585 :XMLns xsl xsl 1590 :XMLns xsl xsl
1586 1591
1587 1592
1588 :XMLent {name} *:XMLent* 1593 :XMLent {name} *:XMLent*
1589 1594
1590 By default entities will be completed from data file of default 1595 By default entities will be completed from the data file of the default
1591 namespace. XMLent command should be used in case when there is no 1596 namespace. The XMLent command should be used in case when there is no default
1592 default namespace: > 1597 namespace: >
1593 1598
1594 :XMLent xhtml10s 1599 :XMLent xhtml10s
1595 1600
1596 Usage 1601 Usage
1597 1602
1598 While used in situation (after declarations from previous part, | is 1603 While used in this situation (after declarations from previous part, | is
1599 cursor position): > 1604 cursor position): >
1600 1605
1601 <| 1606 <|
1602 1607
1603 Will complete to appropriate XHTML tag, and in this situation: > 1608 Will complete to an appropriate XHTML tag, and in this situation: >
1604 1609
1605 <xsl:| 1610 <xsl:|
1606 1611
1607 Will complete to appropriate XSL tag. 1612 Will complete to an appropriate XSL tag.
1608 1613
1609 File xmlcomplete.vim provides through |autoload| mechanism 1614
1610 GetLastOpenTag function which can be used in XML files to get name of 1615 The script xmlcomplete.vim, provided through the |autoload| mechanism,
1611 last open tag with (b:unaryTagsStack has to be defined): > 1616 has the xmlcomplete#GetLastOpenTag() function which can be used in XML files
1617 to get the name of the last open tag (b:unaryTagsStack has to be defined): >
1612 1618
1613 :echo xmlcomplete#GetLastOpenTag("b:unaryTagsStack") 1619 :echo xmlcomplete#GetLastOpenTag("b:unaryTagsStack")
1614
1615
1616 1620
1617 1621
1618 1622
1619 ============================================================================== 1623 ==============================================================================
1620 8. Insert mode commands *inserting* 1624 8. Insert mode commands *inserting*