Skip to content

Commit 219aa9f

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents d0f9616 + ad73cc2 commit 219aa9f

36 files changed

Lines changed: 1314 additions & 1957 deletions

runtime/doc/options.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*options.txt* For Vim version 8.2. Last change: 2022 Jun 02
1+
*options.txt* For Vim version 8.2. Last change: 2022 Jun 07
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar

runtime/doc/tags

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,6 +1939,8 @@ $quote eval.txt /*$quote*
19391939
40.3 usr_40.txt /*40.3*
19401940
41.1 usr_41.txt /*41.1*
19411941
41.10 usr_41.txt /*41.10*
1942+
41.11 usr_41.txt /*41.11*
1943+
41.12 usr_41.txt /*41.12*
19421944
41.2 usr_41.txt /*41.2*
19431945
41.3 usr_41.txt /*41.3*
19441946
41.4 usr_41.txt /*41.4*
@@ -1973,6 +1975,7 @@ $quote eval.txt /*$quote*
19731975
45.5 usr_45.txt /*45.5*
19741976
50.1 usr_50.txt /*50.1*
19751977
50.2 usr_50.txt /*50.2*
1978+
50.3 usr_50.txt /*50.3*
19761979
51.1 usr_51.txt /*51.1*
19771980
51.2 usr_51.txt /*51.2*
19781981
51.3 usr_51.txt /*51.3*
@@ -8140,6 +8143,7 @@ lcs-conceal options.txt /*lcs-conceal*
81408143
lcs-eol options.txt /*lcs-eol*
81418144
lcs-extends options.txt /*lcs-extends*
81428145
lcs-lead options.txt /*lcs-lead*
8146+
lcs-leadmultispace options.txt /*lcs-leadmultispace*
81438147
lcs-multispace options.txt /*lcs-multispace*
81448148
lcs-nbsp options.txt /*lcs-nbsp*
81458149
lcs-precedes options.txt /*lcs-precedes*

runtime/doc/terminal.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*terminal.txt* For Vim version 8.2. Last change: 2022 May 23
1+
*terminal.txt* For Vim version 8.2. Last change: 2022 Jun 09
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -101,7 +101,7 @@ The special key combination CTRL-\ CTRL-N can be used to switch to Normal
101101
mode, just like this works in any other mode.
102102
*t_CTRL-W_CTRL-C*
103103
CTRL-W CTRL-C can be typed to forcefully end the job. On MS-Windows a
104-
CTRL-BREAK will also kill the job.
104+
CTRL-Break will also kill the job.
105105

106106
If you type CTRL-C the effect depends on what the pty has been configured to
107107
do. For simple commands this causes a SIGINT to be sent to the job, which

runtime/doc/todo.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*todo.txt* For Vim version 8.2. Last change: 2022 Jun 05
1+
*todo.txt* For Vim version 8.2. Last change: 2022 Jun 09
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -245,6 +245,9 @@ Memory leaks in test_channel? (or is it because of fork())
245245

246246
PR to support %e and %k in 'errorformat'. #9624
247247

248+
With a window height of 6 and 'scrolloff' set to 3, using "j" does not scroll
249+
evenly. (#10545)
250+
248251
Idea: when typing ":e /some/dir/" and "dir" does not exist, highlight in red.
249252

250253
":set &shellpipe" and ":set &shellredir" should use the logic from
@@ -306,6 +309,8 @@ inconsistent with the documentation.
306309

307310
globpath() does not use 'wildignorecase' at all? (related to #8350)
308311

312+
Add a "--gui-dialog-file" argument, to be used in tests to avoid getting stuck.
313+
309314
Add 'termguiattr' option, use "gui=" attributes in the terminal? Would work
310315
with 'termguicolors'. #1740
311316

runtime/doc/usr_41.txt

Lines changed: 69 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ script. There are a lot of them, therefore this is a long chapter.
1717
|41.6| Using functions
1818
|41.7| Defining a function
1919
|41.8| Lists and Dictionaries
20-
|41.9| Exceptions
21-
|41.10| Various remarks
20+
|41.9| White space
21+
|41.10| Line continuation
22+
|41.11| Comments
23+
|41.12| Fileformat
2224

2325
Next chapter: |usr_42.txt| Add new menus
2426
Previous chapter: |usr_40.txt| Make new commands
@@ -112,7 +114,7 @@ the links if you are impatient.
112114
TRYING OUT EXAMPLES
113115

114116
You can easily try out most examples in these help files without saving the
115-
commands in a file. For example, to try out the "for" loop above do this:
117+
commands to a file. For example, to try out the "for" loop above do this:
116118
1. position the cursor on the "for"
117119
2. start Visual mode with "v"
118120
3. move down to the "endfor"
@@ -195,7 +197,7 @@ cannot start with a digit. Valid variable names are:
195197
CamelCaseName
196198
LENGTH
197199

198-
Invalid names are "foo+bar" and "6var".
200+
Invalid names are "foo.bar" and "6var".
199201

200202
Some variables are global. To see a list of currently defined global
201203
variables type this command: >
@@ -684,8 +686,8 @@ search() function uses its first argument as a search pattern and the second
684686
one as flags. The "W" flag means the search doesn't wrap around the end of
685687
the file.
686688

687-
Using the `call` command is optional in |Vim9| script. This works the same
688-
way and also works in legacy script and on the command line: >
689+
Using the `call` command is optional in |Vim9| script. It is required in
690+
legacy script and on the command line: >
689691
690692
call search("Date: ", "W")
691693
@@ -711,7 +713,7 @@ statements is equal to: >
711713
712714
:substitute/\a/*/g
713715
714-
Using the functions becomes more interesting when you do more work before and
716+
Using the functions becomes interesting when you do more work before and
715717
after the substitute() call.
716718

717719

@@ -1402,8 +1404,9 @@ Let's assign the variable "smaller" the value of the smallest number: >
14021404
smaller = num2
14031405
endif
14041406
1405-
The variable "smaller" is a local variable. Variables used inside a function
1406-
are local unless prefixed by something like "g:", "w:", or "s:".
1407+
The variable "smaller" is a local variable. It is declared to be a number,
1408+
that way Vim can warn you for any mistakes. Variables used inside a function
1409+
are local unless prefixed by something like "g:", "w:", or "b:".
14071410

14081411
Note:
14091412
To access a global variable from inside a function you must prepend
@@ -1469,6 +1472,10 @@ For a function that does not return anything simply leave out the return type: >
14691472
echo text
14701473
enddef
14711474
1475+
If you want to return any kind of value, you can use the "any" return type: >
1476+
def GetValue(): any
1477+
This disables type checking for the return value, use only when needed.
1478+
14721479
It is also possible to define a legacy function with `function` and
14731480
`endfunction`. These do not have types and are not compiled. Therefore they
14741481
execute much slower.
@@ -1485,47 +1492,12 @@ once for every line in the range, with the cursor in that line. Example: >
14851492
14861493
If you call this function with: >
14871494
1488-
:10,15call Number()
1495+
:10,15Number()
14891496
14901497
The function will be called six times, starting on line 10 and ending on line
14911498
15.
14921499

14931500

1494-
VARIABLE NUMBER OF ARGUMENTS
1495-
1496-
Vim enables you to define functions that have a variable number of arguments.
1497-
The following command, for instance, defines a function that must have 1
1498-
argument (start) and can have up to 20 additional arguments: >
1499-
1500-
def Show(start: string, ...items: list<string>)
1501-
1502-
The variable "items" will be a list in the function containing the extra
1503-
arguments. You can use it like any list, for example: >
1504-
1505-
def Show(start: string, ...items: list<string>)
1506-
echohl Title
1507-
echo "start is " .. start
1508-
echohl None
1509-
for index in range(len(items))
1510-
echon $" Arg {index} is {items[index]}"
1511-
endfor
1512-
echo
1513-
enddef
1514-
1515-
You can call it like this: >
1516-
1517-
Show('Title', 'one', 'two', 'three')
1518-
< start is Title Arg 0 is one Arg 1 is two Arg 2 is three ~
1519-
1520-
This uses the `echohl` command to specify the highlighting used for the
1521-
following `echo` command. `echohl None` stops it again. The `echon` command
1522-
works like `echo`, but doesn't output a line break.
1523-
1524-
If you call it with one argument the "items" list will be empty.
1525-
`range(len(items))` returns a list with the indexes, what `for` loops over,
1526-
we'll explain that further down.
1527-
1528-
15291501
LISTING FUNCTIONS
15301502

15311503
The `function` command lists the names and arguments of all user-defined
@@ -1606,6 +1578,11 @@ Note that the name of a variable that holds a function reference must start
16061578
with a capital. Otherwise it could be confused with the name of a builtin
16071579
function.
16081580

1581+
1582+
FURTHER READING
1583+
1584+
Using a variable number of arguments is introduced in section |50.2|.
1585+
16091586
More information about defining your own functions here: |user-functions|.
16101587

16111588
==============================================================================
@@ -1766,95 +1743,16 @@ need to use a List, it stores items in an ordered sequence.
17661743
For further reading see |Dictionaries|.
17671744

17681745
==============================================================================
1769-
*41.9* Exceptions
1770-
1771-
Let's start with an example: >
1772-
1773-
try
1774-
read ~/templates/pascal.tmpl
1775-
catch /E484:/
1776-
echo "Sorry, the Pascal template file cannot be found."
1777-
endtry
1778-
1779-
The `read` command will fail if the file does not exist. Instead of
1780-
generating an error message, this code catches the error and gives the user a
1781-
message with more information.
1782-
1783-
For the commands in between `try` and `endtry` errors are turned into
1784-
exceptions. An exception is a string. In the case of an error the string
1785-
contains the error message. And every error message has a number. In this
1786-
case, the error we catch contains "E484:". This number is guaranteed to stay
1787-
the same (the text may change, e.g., it may be translated).
1788-
1789-
Besides being able to give a nice error message, Vim will also continue
1790-
executing commands after the `:endtry`. Otherwise, once an uncaught error is
1791-
encountered, execution of the script/function/mapping will be aborted.
1792-
1793-
When the `read` command causes another error, the pattern "E484:" will not
1794-
match in it. Thus this exception will not be caught and result in the usual
1795-
error message and execution is aborted.
1796-
1797-
You might be tempted to do this: >
1798-
1799-
try
1800-
read ~/templates/pascal.tmpl
1801-
catch
1802-
echo "Sorry, the Pascal template file cannot be found."
1803-
endtry
1804-
1805-
This means all errors are caught. But then you will not see an error that
1806-
would indicate a completely different problem, such as "E21: Cannot make
1807-
changes, 'modifiable' is off". Think twice before you catch any error!
1808-
1809-
Another useful mechanism is the `finally` command: >
1810-
1811-
var tmp = tempname()
1812-
try
1813-
exe ":.,$write " .. tmp
1814-
exe "!filter " .. tmp
1815-
:.,$delete
1816-
exe ":$read " .. tmp
1817-
finally
1818-
delete(tmp)
1819-
endtry
1820-
1821-
This filters the lines from the cursor until the end of the file through the
1822-
"filter" command, which takes a file name argument. No matter if the
1823-
filtering works, if something goes wrong in between `try` and `finally` or the
1824-
user cancels the filtering by pressing CTRL-C, the `delete(tmp)` call is
1825-
always executed. This makes sure you don't leave the temporary file behind.
1826-
1827-
The `finally` does not catch the exception, the error will still abort
1828-
further execution.
1829-
1830-
More information about exception handling can be found in the reference
1831-
manual: |exception-handling|.
1832-
1833-
==============================================================================
1834-
*41.10* Various remarks
1835-
1836-
Here are a few items that are useful to know when writing Vim scripts.
1837-
1838-
1839-
FILEFORMAT
1840-
1841-
The end-of-line character depends on the system. For Vim scripts it is
1842-
recommended to always use the Unix fileformat. This also works on any other
1843-
system. That way you can copy your Vim scripts from MS-Windows to Unix and
1844-
they still work. See |:source_crnl|. To be sure it is set right, do this
1845-
before writing the file: >
1846-
1847-
:setlocal fileformat=unix
1848-
1849-
1850-
WHITE SPACE
1746+
*41.9* White space
18511747

18521748
Blank lines are allowed and ignored.
18531749

18541750
Leading whitespace characters (blanks and TABs) are always ignored.
18551751

18561752
Trailing whitespace is often ignored, but not always. One command that
1857-
includes it is `map`.
1753+
includes it is `map`. You have to watch out for that, it can cause hard to
1754+
understand mistakes. A generic solution is to never use trailing white space,
1755+
unless you really need it.
18581756

18591757
To include a whitespace character in the value of an option, it must be
18601758
escaped by a "\" (backslash) as in the following example: >
@@ -1876,8 +1774,39 @@ intentionally to make sure scripts are easy to read and to avoid mistakes.
18761774
If you use white space sensibly it will just work. When not you will get an
18771775
error message telling you where white space is missing or should be removed.
18781776

1777+
==============================================================================
1778+
*41.10* Line continuation
1779+
1780+
In legacy Vim script line continuation is done by preceding a continuation
1781+
line with a backslash: >
1782+
let mylist = [
1783+
\ 'one',
1784+
\ 'two',
1785+
\ ]
1786+
1787+
This requires the 'cpo' option to exclude the "C" flag. Normally this is done
1788+
by putting this at the start of the script: >
1789+
let s:save_cpo = &cpo
1790+
set cpo&vim
1791+
1792+
And restore the option at the end of the script: >
1793+
let &cpo = s:save_cpo
1794+
unlet s:save_cpo
1795+
1796+
A few more details can be found here: |line-continuation|.
1797+
1798+
In |Vim9| script the backslash can still be used, but in most places it is not
1799+
needed: >
1800+
var mylist = [
1801+
'one',
1802+
'two',
1803+
]
1804+
1805+
Also, the 'cpo' option does not need to be changed. See
1806+
|vim9-line-continuation| for details.
18791807

1880-
COMMENTS
1808+
==============================================================================
1809+
*41.11* Comments
18811810

18821811
In |Vim9| script the character # starts a comment. That character and
18831812
everything after it until the end-of-line is considered a comment and
@@ -1933,11 +1862,21 @@ script executable, and it also works in legacy script: >
19331862
echo "this is a Vim script"
19341863
quit
19351864
1865+
==============================================================================
1866+
*41.12* Fileformat
19361867

1937-
Advance information about writing Vim script is in |usr_50.txt|.
1868+
The end-of-line character depends on the system. For Vim scripts it is
1869+
recommended to always use the Unix fileformat. This also works on any other
1870+
system. That way you can copy your Vim scripts from MS-Windows to Unix and
1871+
they still work. See |:source_crnl|. To be sure it is set right, do this
1872+
before writing the file: >
1873+
1874+
:setlocal fileformat=unix
19381875
19391876
==============================================================================
19401877

1878+
Advance information about writing Vim script is in |usr_50.txt|.
1879+
19411880
Next chapter: |usr_42.txt| Add new menus
19421881

19431882
Copyright: see |manual-copyright| vim:tw=78:ts=8:noet:ft=help:norl:

0 commit comments

Comments
 (0)