# HG changeset patch # User vimboss # Date 1105739323 0 # Node ID 04f2e519ab18c9de57bbd67e4e9e671499eedaa4 # Parent 98435a8ddb094d8ce0c437bcdaeb3b97c7a61cb1 updated for version 7.0038 diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt --- a/runtime/doc/change.txt +++ b/runtime/doc/change.txt @@ -1,4 +1,4 @@ -*change.txt* For Vim version 7.0aa. Last change: 2004 Dec 29 +*change.txt* For Vim version 7.0aa. Last change: 2005 Jan 14 VIM REFERENCE MANUAL by Bram Moolenaar @@ -378,7 +378,7 @@ The CTRL-A command is very useful in a m steps to make a numbered list. 1. Create the first list entry, make sure it starts with a number. -2. qa - start recording into buffer 'a' +2. qa - start recording into register 'a' 3. Y - yank the entry 4. p - put a copy of the entry below the first one 5. CTRL-A - increment the number diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1,4 +1,4 @@ -*eval.txt* For Vim version 7.0aa. Last change: 2005 Jan 11 +*eval.txt* For Vim version 7.0aa. Last change: 2005 Jan 14 VIM REFERENCE MANUAL by Bram Moolenaar @@ -9,14 +9,15 @@ Expression evaluation *expression* *ex Using expressions is introduced in chapter 41 of the user manual |usr_41.txt|. Note: Expression evaluation can be disabled at compile time. If this has been -done, the features in this document are not available. See |+eval| and the -last chapter below. +done, the features in this document are not available. See |+eval| and +|no-eval-feature|. 1. Variables |variables| 1.1 Variable types 1.2 Function references |Funcref| 1.3 Lists |List| - 1.4 More about variables |more-variables| + 1.4 Dictionaries |Dictionaries| + 1.5 More about variables |more-variables| 2. Expression syntax |expression-syntax| 3. Internal variable |internal-variables| 4. Builtin Functions |functions| @@ -37,10 +38,17 @@ 1.1 Variable types ~ There are four types of variables: -Number a 32 bit signed number -String a NUL terminated string of 8-bit unsigned characters (bytes) -Funcref a reference to a function |Funcref| -List an ordered sequence of items |List| +Number A 32 bit signed number. + Examples: -123 0x10 0177 + +String A NUL terminated string of 8-bit unsigned characters (bytes). + Examples: "ab\txx\"--" 'x-z''a,c' + +Funcref A reference to a function |Funcref|. + Example: function("strlen") + +List An ordered sequence of items |List|. + Example: [1, 2, ['a', 'b']] The Number and String types are converted automatically, depending on how they are used. @@ -78,7 +86,7 @@ List and Funcref types are not automatic *E706* You will get an error if you try to change the type of a variable. You need to |:unlet| it first to avoid this error. String and Number are considered -equivalent though. > +equivalent though. Consider this sequence of commands: > :let l = "string" :let l = 44 " changes type from String to Number :let l = [1, 2, 3] " error! @@ -171,9 +179,14 @@ available. > :let shortlist = mylist[2:2] " List with one item: [3] :let otherlist = mylist[:] " make a copy of the List +The second index can be just before the first index. In that case the result +is an empty list. If the second index is lower, this results in an error. > + :echo mylist[2:1] " result: [] + :echo mylist[2:0] " error! + List identity ~ - + *list-identity* When variable "aa" is a list and you assign it to another variable "bb", both variables refer to the same list. Thus changing the list "aa" will also change "bb": > @@ -248,7 +261,7 @@ examples: > :call extend(list, [1, 2]) " extend the list with two more items :let i = remove(list, 3) " remove item 3 :let l = remove(list, 3, -1) " remove items 3 to last item - :call filter(list, #& =~ 'x'#) " remove items with an 'x' + :call filter(list, '& =~ "x"') " remove items with an 'x' Changing the oder of items in a list: > :call sort(list) " sort a list alphabetically @@ -303,7 +316,7 @@ Functions that are useful with a List: > :if empty(list) " check if list is empty :let l = len(list) " number of items in a list :let big = max(list) " maximum value in a list - :let small = min(list) " minumum value in a list + :let small = min(list) " minimum value in a list :let xs = count(list, 'x') " count nr of times 'x' appears in list :let i = index(list, 'x') " index of first 'x' in list :let lines = getline(1, 10) " get ten text lines from buffer @@ -311,10 +324,109 @@ Functions that are useful with a List: > :let list = split("a b c") " create list from items in a string :let string = join(list, ', ') " create string from list items :let s = string() " String representation of a list - :call map(list, #'>> ' . &#) " prepend ">> " to each item - - -1.4 More about variables ~ + :call map(list, '">> " . &') " prepend ">> " to each item + + +1.4 Dictionaries ~ + *Dictionaries* +A Dictionary is an associative array: Each entry has a key and a value. The +entry can be located with the key. The entries are stored without ordering. + + +Dictionary creation ~ + +A Dictionary is created with a comma separated list of entries in curly +braces. Each entry has a key and a value, separated by a colon. Examples: > + :let mydict = {1: 'one', 2: 'two', 3: 'three'} + :let emptydict = {} + +A key is always a String. You can use a Number, it will be converted to a +String automatically. Thus the String '4' and the number 4 will find the same +entry. Note that the String '04' and the Number 04 are different, since 04 +will be converted to the String '4'. + +A value can be any expression. Using a Dictionary for an entry creates a +nested Dictionary: > + :let nestdict = {1: {11: 'a', 12: 'b'}, 2: {21: 'c'}} + +An extra comma after the last entry is ignored. + + +Accessing entries ~ + +The normal way to access an entry is by putting the key in square brackets: > + :let val = mydict["one"] + :let mydict["four"] = 4 + +You can add new entries to an existing Dictionary this way. + +For keys that consist entirely of letters, digits and underscore the following +form can be used |expr-entry|: > + :let val = mydict.one + :let mydict.four = 4 + +Since an entry can be any type, also a List and a Dictionary, the indexing and +key lookup can be repeated: > + :let dict.key[idx].key = 0 + + +Dictionary to List conversion ~ + +You may want to loop over the entries in a dictionary. For this you need to +turn the Dictionary into a List and pass it to |:for|. + +Most often you want to loop over the keys, using the |keys()| function: > + :for key in keys(mydict) + : echo key . ': ' . mydict[key] + :endfor + +The List of keys is unsorted. You may want to sort them first: > + :for key in sort(keys(mydict)) + +To loop over the values use the |values()| function: > + :for v in values(mydict) + : echo "value: " . v + :endfor + +If you want both the key and the value use the |items()| function. It returns +a List of Lists with two items: the key and the value: > + :for entry in items(mydict) + : echo entry[0] . ': ' . entry[1] + :endfor + + +Dictionary identity ~ + +Just like Lists you need to use |copy()| and |deepcopy()| to make a copy of a +Dictionary. Otherwise, assignment results in referring to the same +Dictionary: > + :let onedict = {'a': 1, 'b': 2} + :let adict = onedict + :let adict['a'] = 11 + :echo onedict['a'] + 11 + +For more info see |list-identity|. + + +Dictionary modification ~ + *dict-modification* +To change an already existing entry of a Dictionary, or to add a new entry, +use |:let| this way: > + :let dict[4] = "four" + :let dict['one'] = item + +Removing an entry from a Dictionary is done with |remove()|: > + :let i = remove(dict, 'aaa') " remove item with key 'aaa' + +Merging a Dictionary with another is done with |extend()|: > + :call extend(adict, bdict) " extend adict with entries from bdict + +Weeding out entries from a Dictionary can be done with |filter()|: > + :call filter(dict '& =~ "x"') " remove entries with value 'x' + + +1.5 More about variables ~ *more-variables* If you need to know the type of a variable or expression, use the |type()| function. @@ -379,11 +491,11 @@ Expression syntax summary, from least to |expr8| expr9[expr1] byte of a String or item of a List expr9[expr1 : expr2] substring of a String or sublist of a List + expr9.name entry in a Dictionary |expr9| number number constant "string" string constant, backslash is special - 'string' string constant - #string# string constant + 'string' string constant, ' is doubled [expr1, ...] List &option option value (expr1) nested expression @@ -607,6 +719,7 @@ error. Example: > Generally, if a List index is equal to or higher than the length of the List, or more negative than the length of the List, this results in an error. + expr9[expr1a : expr1b] substring or sublist *expr-[:]* If expr9 is a Number or String this results in the substring with the bytes @@ -638,6 +751,26 @@ above, except that indexes out of range Using expr9[expr1] or expr9[expr1a : expr1b] on a Funcref results in an error. + +expr9.name entry in a Dictionary *expr-entry* + +If expr9 is a Dictionary and it is followed by a dot, then the following name +will be used as a key in the Dictionary. This is just like: expr9[name]. + +The name must consist of alphanumeric characters, just like a variable name, +but it may start with a number. Curly braces cannot be used. + +There must not be white space before or after the dot. + +Examples: > + :let dict = {"one": 1, 2: "two"} + :echo dict.one + :echo dict .2 + +Note that the dot is also used for String concatenation. To avoid confusion +always put spaces around the dot for String concatenation. + + *expr9* number ------ @@ -683,8 +816,7 @@ literal-string *literal-string* *E1 Note that single quotes are used. This string is taken as it is. No backslashes are removed or have a special -meaning. A literal-string cannot contain a single quote. Use a double-quoted -string or sharp-string for that. +meaning. The only exception is that two quotes stand for one quote. Single quoted strings are useful for patterns, so that backslashes do not need to be doubled. These two commands are equivalent: > @@ -692,17 +824,6 @@ to be doubled. These two commands are e if a =~ '\s*' -sharp-string *sharp-string* ---------------- -#string# string constant *expr-#* - -Most characters in the string are taken as-is. Only the '#' character is -special: It needs to be double to get one. - -Sharp-strings are useful when a string may contain single quotes, double -quotes and/or backslashes. - - option *expr-option* *E112* *E113* ------ &option option value, local value if possible @@ -1236,6 +1357,7 @@ inputsecret( {prompt} [, {text}]) String insert( {list}, {item} [, {idx}]) List insert {item} in {list} [before {idx}] isdirectory( {directory}) Number TRUE if {directory} is a directory join( {list} [, {sep}]) String join {list} items into one String +keys( {dict}) List List of keys in {dict} len( {expr}) Number the length of {expr} libcall( {lib}, {func}, {arg}) String call {func} in library {lib} with {arg} libcallnr( {lib}, {func}, {arg}) Number idem, but return a Number @@ -1258,6 +1380,8 @@ mode() String current editing mode nextnonblank( {lnum}) Number line nr of non-blank line >= {lnum} nr2char( {expr}) String single char with ASCII value {expr} prevnonblank( {lnum}) Number line nr of non-blank line <= {lnum} +range( {expr} [, {max} [, {stride}]]) + List items from {expr} to {max} remote_expr( {server}, {string} [, {idvar}]) String send expression remote_foreground( {server}) Number bring Vim server to the foreground @@ -1267,6 +1391,7 @@ remote_read( {serverid}) String read rep remote_send( {server}, {string} [, {idvar}]) String send key sequence remove( {list}, {idx} [, {end}]) any remove items {idx}-{end} from {list} +remove( {dict}, {key}) any remove entry {key} from {dict} rename( {from}, {to}) Number rename (move) file from {from} to {to} repeat( {expr}, {count}) String repeat {expr} {count} times resolve( {filename}) String get filename a shortcut points to @@ -1905,14 +2030,17 @@ filter({list}, {expr}) *filter()* *E zero remove the item from the List. Inside {expr} the symbol "&" stands for the existing item. Example: > - :call filter(mylist, #& !~ "OLD"#) -< Removes the items where "OLD" appears. + :call filter(mylist, '& !~ "OLD"') +< Removes the items where "OLD" appears. And this: > + :call filter(mylist, 0) +< Removes all the items, thus clears the List or Dictionary. + Note that {expr} is an expression that evaluates to an - expression. Often it is good to use a |sharp-string| to avoid - having to double backslashes. + expression. Often it is good to use a |literal-string| to + avoid having to double backslashes. The operation is done in-place. If you want a list to remain unmodified make a copy first: > - :let l = filter(copy(mylist), #& =~ "KEEP"#) + :let l = filter(copy(mylist), '& =~ "KEEP"') < Returns {list}. @@ -2524,6 +2652,10 @@ join({list} [, {sep}]) *join()* converted into a string like with |string()|. The opposite function is |split()|. +keys({dict}) *keys()* + Return a List with all the keys of {dict}. The List is in + arbitrary order. + *len()* *E701* len({expr}) The result is a Number, which is the length of the argument. When {expr} is a String or a Number the length in bytes is @@ -2637,14 +2769,14 @@ map({list}, {expr}) *map()* {expr}. Inside {expr} the symbol "&" stands for the existing item. Example: > - :call map(mylist, #"> " . & . " <"#) + :call map(mylist, '"> " . & . " <"') < This puts "> " before and " <" after each item in "mylist". Note that {expr} is an expression that evaluates to an - expression. Often it is good to use a |sharp-string| to avoid - having to double backslashes. + expression. Often it is good to use a |literal-string| to + avoid having to double backslashes. The operation is done in-place. If you want a list to remain unmodified make a copy first: > - :let tlist = map(copy(mylist), # & . "\t"#) + :let tlist = map(copy(mylist), ' & . "\t"') < Returns {list}. @@ -2817,6 +2949,19 @@ prevnonblank({lnum}) *prevnonblank() above it, zero is returned. Also see |nextnonblank()|. +range({expr} [, {max} [, {stride}]]) *range()* + Returns a List with Numbers: + - If only {expr} is specified: [0, 1, ..., {expr} - 1] + - If {max} is specified: [{expr}, {expr} + 1, ..., {max}] + - If {stride} is specified: [{expr}, {expr} + {stride}, ..., + {max}] (increasing {expr} with {stride} each time, not + producing a value past {max}). + Examples: > + range(4) " [0, 1, 2, 3] + range(2, 4) " [2, 3, 4] + range(2, 9, 3) " [2, 5, 8] + range(2, -2, -1) " [2, 1, 0, -1, -2] +< *remote_expr()* *E449* remote_expr({server}, {string} [, {idvar}]) Send the {string} to {server}. The string is sent as an @@ -2902,7 +3047,12 @@ remove({list}, {idx} [, {end}]) *remo Example: > :echo "last item: " . remove(mylist, -1) :call remove(mylist, 0, 9) -< Use |delete()| to remove a file. +remove({dict}, {key}) + Remove the entry from {dict} with key {key}. Example: > + :echo "removed " . remove(dict, "one") +< If there is no {key} in {dict} this is an error. + + Use |delete()| to remove a file. rename({from}, {to}) *rename()* Rename the file by the name {from} to the name {to}. This @@ -3088,8 +3238,11 @@ setcmdpos({pos}) *setcmdpos()* {pos}. The first position is 1. Use |getcmdpos()| to obtain the current position. Only works while editing the command line, thus you must use - |c_CTRL-\_e| or |c_CTRL-R_=|. The position is set after the - command line is set to the expression. + |c_CTRL-\_e|, |c_CTRL-R_=| or |c_CTRL-R_CTRL-R| with '='. For + |c_CTRL-\_e| and |c_CTRL-R_CTRL-R| with '=' the position is + set after the command line is set to the expression. For + |c_CTRL-R_=| it is set after evaluating the expression but + before inserting the resulting text. When the number is too big the cursor is put at the end of the line. A number smaller than one has undefined results. Returns 0 when successful, 1 when not editing the command @@ -3229,11 +3382,11 @@ string({expr}) Return {expr} converted t String or a composition of them, then the result can be parsed back with |eval()|. {expr} type result ~ - String #string# + String 'string' Number 123 - Funcref function(#name#) + Funcref function('name') List [item, item] - Note that in String values the # character is doubled. + Note that in String values the ' character is doubled. *strlen()* strlen({expr}) The result is a Number, which is the length of the String @@ -4110,7 +4263,7 @@ 7. Commands *expression-commands* :endwhile < NOTE: The ":append" and ":insert" commands don't work - properly inside a :while" and ":for" loop. + properly inside a ":while" and ":for" loop. :for {var} in {list} *:for* *E690* :endfo[r] *:endfo* *:endfor* @@ -4358,8 +4511,8 @@ 7. Commands *expression-commands* < This has an character, see |expr-string|. Note: The executed string may be any command-line, but - you cannot start or end a "while" or "if" command. - Thus this is illegal: > + you cannot start or end a "while", "for" or "if" + command. Thus this is illegal: > :execute 'while i > 5' :execute 'echo "test" | break' < diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1,4 +1,4 @@ -*options.txt* For Vim version 7.0aa. Last change: 2005 Jan 07 +*options.txt* For Vim version 7.0aa. Last change: 2005 Jan 14 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1969,6 +1969,7 @@ A jump table for the options with a shor To include a comma in a file name precede it with a backslash. Spaces after a comma are ignored, otherwise spaces are included in the file name. See |option-backslash| about using backslashes. + This has nothing to do with the |Dictionary| variable type. Where to find a list of words? - On FreeBSD, there is the file "/usr/share/dict/words". - In the Simtel archive, look in the "msdos/linguist" directory. diff --git a/runtime/doc/tags b/runtime/doc/tags --- a/runtime/doc/tags +++ b/runtime/doc/tags @@ -5006,7 +5006,6 @@ hebrew hebrew.txt /*hebrew* hebrew.txt hebrew.txt /*hebrew.txt* help various.txt /*help* help-context help.txt /*help-context* -help-tags tags 1 help-translated various.txt /*help-translated* help-xterm-window various.txt /*help-xterm-window* help.txt help.txt /*help.txt* diff --git a/runtime/keymap/polish-slash.vim b/runtime/keymap/polish-slash.vim --- a/runtime/keymap/polish-slash.vim +++ b/runtime/keymap/polish-slash.vim @@ -1,3 +1,12 @@ +" Polish letters under VIM >= 6 +" Maintainer: HS6_06 +" Last changed: 2005 Jan 12 +" Current version: 1.0.2 +" History: +" 2005.01.12 1.0.2 keymap_name shortened, added Current version, History +" 2005.01.10 1.0.1 un*x line ends for all files +" 2005.01.09 1.0.0 Initial release + let encoding = &enc if encoding == 'latin1' if has("unix") diff --git a/runtime/keymap/polish-slash_iso-8859-2.vim b/runtime/keymap/polish-slash_iso-8859-2.vim --- a/runtime/keymap/polish-slash_iso-8859-2.vim +++ b/runtime/keymap/polish-slash_iso-8859-2.vim @@ -1,6 +1,8 @@ " Polish letters keymap for iso-8859-2 " Maintainer: HS6_06 -" Last Changed: 2005 Jan 9 +" Last Changed: 2005 Jan 12 +" Current version: 1.0.2 +" History: polish-slash.vim " This keymap adds the special Polish letters " to an existing Latin keyboard. @@ -9,7 +11,7 @@ " instead of AltGr+{acelnosxz} you ve to use "/" followed by {acelnosxz} " short keymap name for statusline -let b:keymap_name = "polish-slash-iso-8859-2" +let b:keymap_name = "PL-slash-ISO" scriptencoding latin1 diff --git a/runtime/lang/menu_cs_cz.iso_8859-2.vim b/runtime/lang/menu_cs_cz.iso_8859-2.vim --- a/runtime/lang/menu_cs_cz.iso_8859-2.vim +++ b/runtime/lang/menu_cs_cz.iso_8859-2.vim @@ -38,7 +38,7 @@ menutrans &Paste"+gP V&ložit"+gP menutrans Put\ &Before[p Vložit\ &před[p menutrans Put\ &After]p Vloži&t\ za]p menutrans &Deletex &Smazatx -menutrans &Select\ allggVG Vy&brat\ všeggVG +menutrans &Select\ AllggVG Vy&brat\ všeggVG menutrans &Find\.\.\. &Hledat\.\.\. menutrans Find\ and\ Rep&lace\.\.\. &Nahradit\.\.\. menutrans Options\.\.\. Volb&y\.\.\. @@ -186,6 +186,7 @@ menutrans &How-to\ links Ho&wto menutrans &GUI &Grafické\ rozhraní menutrans &Credits &Autoři menutrans Co&pying &Licenční\ politika +menutrans &Sponsor/Register Sponzorování/&Registrace menutrans &Find\.\.\. &Hledat\.\.\. menutrans O&rphans O&siřelé\ děti menutrans &Version &Verze diff --git a/src/mbyte.c b/src/mbyte.c --- a/src/mbyte.c +++ b/src/mbyte.c @@ -2408,6 +2408,21 @@ utf_head_off(base, p) } /* + * Copy a character from "*fp" to "*tp" and advance the pointers. + */ + void +mb_copy_char(fp, tp) + char_u **fp; + char_u **tp; +{ + int l = (*mb_ptr2len_check)(*fp); + + mch_memmove(*tp, *fp, (size_t)l); + *tp += l; + *fp += l; +} + +/* * Return the offset from "p" to the first byte of a character. When "p" is * at the start of a character 0 is returned, otherwise the offset to the next * character. Can start anywhere in a stream of bytes. diff --git a/src/os_unix.c b/src/os_unix.c --- a/src/os_unix.c +++ b/src/os_unix.c @@ -4724,7 +4724,7 @@ mch_expand_wildcards(num_pat, pat, num_f else buf = vim_strsave(*pat); expl_files = NULL; - has_wildcard = mch_has_exp_wildcard(buf); /* (still) wildcards in there? */ + has_wildcard = mch_has_exp_wildcard(buf); /* (still) wildcards? */ if (has_wildcard) /* yes, so expand them */ expl_files = (char_u **)_fnexplode(buf); @@ -5226,12 +5226,20 @@ save_patterns(num_pat, pat, num_file, fi char_u ***file; { int i; + char_u *s; *file = (char_u **)alloc(num_pat * sizeof(char_u *)); if (*file == NULL) return FAIL; for (i = 0; i < num_pat; i++) - (*file)[i] = vim_strsave(pat[i]); + { + s = vim_strsave(pat[i]); + if (s != NULL) + /* Be compatible with expand_filename(): halve the number of + * backslashes. */ + backslash_halve(s); + (*file)[i] = s; + } *num_file = num_pat; return OK; } diff --git a/src/proto/mbyte.pro b/src/proto/mbyte.pro --- a/src/proto/mbyte.pro +++ b/src/proto/mbyte.pro @@ -45,6 +45,7 @@ int latin_head_off __ARGS((char_u *base, int dbcs_head_off __ARGS((char_u *base, char_u *p)); int dbcs_screen_head_off __ARGS((char_u *base, char_u *p)); int utf_head_off __ARGS((char_u *base, char_u *p)); +void mb_copy_char __ARGS((char_u **fp, char_u **tp)); int mb_off_next __ARGS((char_u *base, char_u *p)); int mb_tail_off __ARGS((char_u *base, char_u *p)); int utf_valid_string __ARGS((char_u *s, char_u *end)); diff --git a/src/version.h b/src/version.h --- a/src/version.h +++ b/src/version.h @@ -36,5 +36,5 @@ #define VIM_VERSION_NODOT "vim70aa" #define VIM_VERSION_SHORT "7.0aa" #define VIM_VERSION_MEDIUM "7.0aa ALPHA" -#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2004 Jan 11)" -#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2004 Jan 11, compiled " +#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2004 Jan 14)" +#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2004 Jan 14, compiled "