mirror of
https://github.com/zoriya/vim.git
synced 2026-01-01 20:08:13 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b2c2efa53a | ||
|
|
c6d8db78b1 | ||
|
|
b0bf8580c3 | ||
|
|
900b4d77f0 | ||
|
|
2c7a29c7fd | ||
|
|
5b962cf71c |
@@ -1,4 +1,4 @@
|
||||
*editing.txt* For Vim version 7.0aa. Last change: 2005 Jul 25
|
||||
*editing.txt* For Vim version 7.0aa. Last change: 2005 Dec 13
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -398,8 +398,9 @@ The expression can contain just about anything, thus this can also be used to
|
||||
avoid the special meaning of '"', '|', '%' and '#'.
|
||||
|
||||
*++opt* *[++opt]*
|
||||
The [++opt] argument can be used to force the value of 'fileformat' or
|
||||
'fileencoding' to a value for one command. The form is: >
|
||||
The [++opt] argument can be used to force the value of 'fileformat',
|
||||
'fileencoding' or 'binary' to a value for one command, and to specify the
|
||||
behavior for bad characters. The form is: >
|
||||
++{optname}={value}
|
||||
|
||||
Where {optname} is one of: *++ff* *++enc* *++bin* *++nobin*
|
||||
@@ -407,6 +408,7 @@ Where {optname} is one of: *++ff* *++enc* *++bin* *++nobin*
|
||||
enc or encoding overrides 'fileencoding'
|
||||
bin or binary sets 'binary'
|
||||
nobin or nobinary resets 'binary'
|
||||
bad specifies behavior for bad characters
|
||||
|
||||
{value} cannot contain white space. It can be any valid value for these
|
||||
options. Examples: >
|
||||
@@ -416,12 +418,24 @@ This edits the same file again with 'fileformat' set to "unix". >
|
||||
:w ++enc=latin1 newfile
|
||||
This writes the current buffer to "newfile" in latin1 format.
|
||||
|
||||
There may be several ++opt arguments, separated by white space. They must all
|
||||
appear before any |+cmd| argument.
|
||||
|
||||
*++bad*
|
||||
The argument of "++bad=" specifies what happens with characters that can't be
|
||||
converted and illegal bytes. It can be one of three things:
|
||||
++bad=X A single-byte character that replaces each bad character.
|
||||
++bad=keep Keep bad characters without conversion. Note that this may
|
||||
result in illegal bytes in your text!
|
||||
++bad=drop Remove the bad characters.
|
||||
|
||||
The default is like "++bad=?": Replace each bad character with a question
|
||||
mark.
|
||||
|
||||
Note that when reading, the 'fileformat' and 'fileencoding' options will be
|
||||
set to the used format. When writing this doesn't happen, thus a next write
|
||||
will use the old value of the option. Same for the 'binary' option.
|
||||
|
||||
There may be several ++opt arguments, separated by white space. They must all
|
||||
appear before any |+cmd| argument.
|
||||
|
||||
*+cmd* *[+cmd]*
|
||||
The [+cmd] argument can be used to position the cursor in the newly opened
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
*eval.txt* For Vim version 7.0aa. Last change: 2005 Dec 11
|
||||
*eval.txt* For Vim version 7.0aa. Last change: 2005 Dec 12
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -1278,7 +1278,7 @@ v:fname_in The name of the input file. Valid while evaluating:
|
||||
'diffexpr' original file
|
||||
'patchexpr' original file
|
||||
'printexpr' file to be printed
|
||||
And set to the swap file name for |SwapExits|.
|
||||
And set to the swap file name for |SwapExists|.
|
||||
|
||||
*v:fname_out* *fname_out-variable*
|
||||
v:fname_out The name of the output file. Only valid while
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
*index.txt* For Vim version 7.0aa. Last change: 2005 Dec 11
|
||||
*index.txt* For Vim version 7.0aa. Last change: 2005 Dec 12
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -736,6 +736,7 @@ tag char note action in Normal mode ~
|
||||
|gu| gu{motion} 2 make Nmove text lowercase
|
||||
|gv| gv reselect the previous Visual area
|
||||
|gw| gw{motion} 2 format Nmove text and keep cursor
|
||||
|g@| g@{motion} call 'operatorfunc'
|
||||
|g~| g~{motion} 2 swap case for Nmove text
|
||||
|g<Down>| g<Down> 1 same as "gj"
|
||||
|g<End>| g<End> 1 same as "g$"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
*insert.txt* For Vim version 7.0aa. Last change: 2005 Nov 22
|
||||
*insert.txt* For Vim version 7.0aa. Last change: 2005 Dec 12
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -1040,9 +1040,9 @@ Note: When used first time completion menu will be shown with little delay
|
||||
|
||||
XML *ft-xml-omni*
|
||||
|
||||
Vim 7 provides mechanism to context aware completion of XML files. It depends
|
||||
on special |xml-data-file| and two commands: |:XMLns| and |:XMLent|. Features
|
||||
are:
|
||||
Vim 7 provides mechanism to context aware completion of XML files. It depends
|
||||
on special |xml-omni-datafile| and two commands: |:XMLns| and |:XMLent|.
|
||||
Features are:
|
||||
|
||||
- after "<" complete tag name depending on context (no div suggest
|
||||
inside of an a tag)
|
||||
@@ -1050,7 +1050,7 @@ are:
|
||||
a tag)
|
||||
- when attribute has limited number of possible values help to complete
|
||||
them
|
||||
- complete names of entities (defined in |xml-data-file| and in current file
|
||||
- complete names of entities (defined in |xml-omni-datafile| and in current file
|
||||
with "<!ENTITY" declarations
|
||||
- when used after "</" CTRL-X CTRL-O will close the last opened tag
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
*map.txt* For Vim version 7.0aa. Last change: 2005 Dec 11
|
||||
*map.txt* For Vim version 7.0aa. Last change: 2005 Dec 12
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -10,6 +10,17 @@ This subject is introduced in sections |05.3|, |24.7| and |40.1| of the user
|
||||
manual.
|
||||
|
||||
1. Key mapping |key-mapping|
|
||||
1.1 MAP COMMANDS |:map-commands|
|
||||
1.2 Special arguments |:map-arguments|
|
||||
1.3 Mapping and modes |:map-modes|
|
||||
1.4 Listing mappings |map-listing|
|
||||
1.5 Mapping special keys |:map-special-keys|
|
||||
1.6 Special characters |:map-special-chars|
|
||||
1.7 What keys to map |map-which-keys|
|
||||
1.8 Examples |map-examples|
|
||||
1.9 Using mappings |map-typing|
|
||||
1.10 Mapping alt-keys |:map-alt-keys|
|
||||
1.11 Mapping an operator |:map-operator|
|
||||
2. Abbreviations |abbreviations|
|
||||
3. Local mappings and functions |script-local|
|
||||
4. User-defined commands |user-commands|
|
||||
@@ -24,6 +35,9 @@ is to define a sequence commands for a function key. Example: >
|
||||
|
||||
This appends the current date and time after the cursor (in <> notation |<>|).
|
||||
|
||||
|
||||
1.1 MAP COMMANDS *:map-commands*
|
||||
|
||||
There are commands to enter new mappings, remove mappings and list mappings.
|
||||
See |map-overview| for the various forms of "map" and their relationships with
|
||||
modes.
|
||||
@@ -116,6 +130,21 @@ characters. You can use this to put command sequences under function keys,
|
||||
translate one key into another, etc. See |:mkexrc| for how to save and
|
||||
restore the current mappings.
|
||||
|
||||
*map-ambiguous*
|
||||
When two mappings start with the same sequence of characters, they are
|
||||
ambiguous. Example: >
|
||||
:imap aa foo
|
||||
:imap aaa bar
|
||||
When Vim has read "aa", it will need to get another character to be able to
|
||||
decide if "aa" or "aaa" should be mapped. This means that after typing "aa"
|
||||
that mapping won't get expanded yet, Vim is waiting for another character.
|
||||
If you type a space, then "foo" will get inserted, plus the space. If you
|
||||
type "a", then "bar" will get inserted.
|
||||
{Vi does not allow ambiguous mappings}
|
||||
|
||||
|
||||
1.2 SPECIAL ARGUMENTS *:map-arguments*
|
||||
|
||||
*:map-local* *:map-<buffer>* *E224* *E225*
|
||||
If the first argument to one of these commands is "<buffer>" it will apply to
|
||||
mappings locally to the current buffer only. Example: >
|
||||
@@ -167,7 +196,7 @@ Example of what will fail: >
|
||||
They must appear right after the command, before any other arguments.
|
||||
|
||||
|
||||
MAPPING AND MODES
|
||||
1.3 MAPPING AND MODES *:map-modes*
|
||||
|
||||
There are five sets of mappings
|
||||
- For Normal mode: When typing commands.
|
||||
@@ -236,19 +265,9 @@ character as an argument to command like "f" or "t".
|
||||
are only used for typed characters. This assumes that the language mapping
|
||||
was already done when typing the mapping.
|
||||
|
||||
*map-multibyte*
|
||||
It is possible to map multibyte characters, but only the whole character. You
|
||||
cannot map the first byte only. This was done to prevent problems in this
|
||||
scenario: >
|
||||
:set encoding=latin1
|
||||
:imap <M-C> foo
|
||||
:set encoding=utf-8
|
||||
The mapping for <M-C> is defined with the latin1 encoding, resulting in a 0xc3
|
||||
byte. If you type the character <20> (0xea <M-a>) in UTF-8 encoding this is the
|
||||
two bytes 0xc3 0xa1. You don't want the 0xc3 byte to be mapped then,
|
||||
otherwise it would be impossible to type the <20> character.
|
||||
|
||||
*map-listing*
|
||||
1.4 LISTING MAPPINGS *map-listing*
|
||||
|
||||
When listing mappings the characters in the first two columns are:
|
||||
|
||||
CHAR MODE ~
|
||||
@@ -283,6 +302,48 @@ last defined. Example: >
|
||||
|
||||
See |:verbose-cmd| for more information.
|
||||
|
||||
|
||||
1.5 MAPPING SPECIAL KEYS *:map-special-keys*
|
||||
|
||||
There are three ways to map a special key:
|
||||
1. The Vi-compatible method: Map the key code. Often this is a sequence that
|
||||
starts with <Esc>. To enter a mapping like this you type ":map " and then
|
||||
you have to type CTRL-V before hitting the function key. Note that when
|
||||
the key code for the key is in the termcap (the t_ options), it will
|
||||
automatically be translated into the internal code and become the second
|
||||
way of mapping (unless the 'k' flag is included in 'cpoptions').
|
||||
2. The second method is to use the internal code for the function key. To
|
||||
enter such a mapping type CTRL-K and then hit the function key, or use
|
||||
the form "#1", "#2", .. "#9", "#0", "<Up>", "<S-Down>", "<S-F7>", etc.
|
||||
(see table of keys |key-notation|, all keys from <Up> can be used). The
|
||||
first ten function keys can be defined in two ways: Just the number, like
|
||||
"#2", and with "<F>", like "<F2>". Both stand for function key 2. "#0"
|
||||
refers to function key 10, defined with option 't_f10', which may be
|
||||
function key zero on some keyboards. The <> form cannot be used when
|
||||
'cpoptions' includes the '<' flag.
|
||||
3. Use the termcap entry, with the form <t_xx>, where "xx" is the name of the
|
||||
termcap entry. Any string entry can be used. For example: >
|
||||
:map <t_F3> G
|
||||
< Maps function key 13 to "G". This does not work if 'cpoptions' includes
|
||||
the '<' flag.
|
||||
|
||||
The advantage of the second and third method is that the mapping will work on
|
||||
different terminals without modification (the function key will be
|
||||
translated into the same internal code or the actual key code, no matter what
|
||||
terminal you are using. The termcap must be correct for this to work, and you
|
||||
must use the same mappings).
|
||||
|
||||
DETAIL: Vim first checks if a sequence from the keyboard is mapped. If it
|
||||
isn't the terminal key codes are tried (see |terminal-options|). If a
|
||||
terminal code is found it is replaced with the internal code. Then the check
|
||||
for a mapping is done again (so you can map an internal code to something
|
||||
else). What is written into the script file depends on what is recognized.
|
||||
If the terminal key code was recognized as a mapping the key code itself is
|
||||
written to the script file. If it was recognized as a terminal code the
|
||||
internal code is written to the script file.
|
||||
|
||||
|
||||
1.6 SPECIAL CHARACTERS *:map-special-chars*
|
||||
*map_backslash*
|
||||
Note that only CTRL-V is mentioned here as a special character for mappings
|
||||
and abbreviations. When 'cpoptions' does not contain 'B', a backslash can
|
||||
@@ -294,18 +355,6 @@ To map a backslash, or use a backslash literally in the {rhs}, the special
|
||||
sequence "<Bslash>" can be used. This avoids the need to double backslashes
|
||||
when using nested mappings.
|
||||
|
||||
*map-ambiguous*
|
||||
When two mappings start with the same sequence of characters, they are
|
||||
ambiguous. Example: >
|
||||
:imap aa foo
|
||||
:imap aaa bar
|
||||
When Vim has read "aa", it will need to get another character to be able to
|
||||
decide if "aa" or "aaa" should be mapped. This means that after typing "aa"
|
||||
that mapping won't get expanded yet, Vim is waiting for another character.
|
||||
If you type a space, then "foo" will get inserted, plus the space. If you
|
||||
type "a", then "bar" will get inserted.
|
||||
{Vi does not allow ambiguous mappings}
|
||||
|
||||
*map_CTRL-C*
|
||||
Using CTRL-C in the {lhs} is possible, but it will only work when Vim is
|
||||
waiting for a key, not when Vim is busy with something. When Vim is busy
|
||||
@@ -331,6 +380,18 @@ example, to make sure that function key 8 does nothing at all: >
|
||||
:map <F8> <Nop>
|
||||
:map! <F8> <Nop>
|
||||
<
|
||||
*map-multibyte*
|
||||
It is possible to map multibyte characters, but only the whole character. You
|
||||
cannot map the first byte only. This was done to prevent problems in this
|
||||
scenario: >
|
||||
:set encoding=latin1
|
||||
:imap <M-C> foo
|
||||
:set encoding=utf-8
|
||||
The mapping for <M-C> is defined with the latin1 encoding, resulting in a 0xc3
|
||||
byte. If you type the character <20> (0xea <M-a>) in UTF-8 encoding this is the
|
||||
two bytes 0xc3 0xa1. You don't want the 0xc3 byte to be mapped then,
|
||||
otherwise it would be impossible to type the <20> character.
|
||||
|
||||
*<Leader>* *mapleader*
|
||||
To define a mapping which uses the "mapleader" variable, the special string
|
||||
"<Leader>" can be used. It is replaced with the string value of "mapleader".
|
||||
@@ -418,7 +479,9 @@ and CTRL-X is not mapped. This was done to be able to use all the named
|
||||
registers and marks, even when the command with the same name has been
|
||||
mapped.
|
||||
|
||||
*map-which-keys*
|
||||
|
||||
1.7 WHAT KEYS TO MAP *map-which-keys*
|
||||
|
||||
If you are going to map something, you will need to choose which key(s) to use
|
||||
for the {lhs}. You will have to avoid keys that are used for Vim commands,
|
||||
otherwise you would not be able to use those commands anymore. Here are a few
|
||||
@@ -436,7 +499,9 @@ losing any builtin function. You can also use ":help {key}^D" to find out if
|
||||
a key is used for some command. ({key} is the specific key you want to find
|
||||
out about, ^D is CTRL-D).
|
||||
|
||||
*map-examples*
|
||||
|
||||
1.8 EXAMPLES *map-examples*
|
||||
|
||||
A few examples (given as you type them, for "<CR>" you type four characters;
|
||||
the '<' flag must not be present in 'cpoptions' for this to work). >
|
||||
|
||||
@@ -445,7 +510,9 @@ the '<' flag must not be present in 'cpoptions' for this to work). >
|
||||
:map _x d/END/e<CR>
|
||||
:map! qq quadrillion questions
|
||||
<
|
||||
*map-typing*
|
||||
|
||||
1.9 USING MAPPINGS *map-typing*
|
||||
|
||||
Vim will compare what you type with the start of a mapped sequence. If there
|
||||
is an incomplete match, it will get more characters until there either is a
|
||||
complete match or until there is no match at all. Example: If you map! "qq",
|
||||
@@ -521,46 +588,8 @@ the original Vi, as long as there is only one undo command in the mapped
|
||||
sequence (having two undo commands in a mapped sequence did not make sense
|
||||
in the original Vi, you would get back the text before the first undo).
|
||||
|
||||
*:map-special-keys*
|
||||
There are three ways to map a special key:
|
||||
1. The Vi-compatible method: Map the key code. Often this is a sequence that
|
||||
starts with <Esc>. To enter a mapping like this you type ":map " and then
|
||||
you have to type CTRL-V before hitting the function key. Note that when
|
||||
the key code for the key is in the termcap (the t_ options), it will
|
||||
automatically be translated into the internal code and become the second
|
||||
way of mapping (unless the 'k' flag is included in 'cpoptions').
|
||||
2. The second method is to use the internal code for the function key. To
|
||||
enter such a mapping type CTRL-K and then hit the function key, or use
|
||||
the form "#1", "#2", .. "#9", "#0", "<Up>", "<S-Down>", "<S-F7>", etc.
|
||||
(see table of keys |key-notation|, all keys from <Up> can be used). The
|
||||
first ten function keys can be defined in two ways: Just the number, like
|
||||
"#2", and with "<F>", like "<F2>". Both stand for function key 2. "#0"
|
||||
refers to function key 10, defined with option 't_f10', which may be
|
||||
function key zero on some keyboards. The <> form cannot be used when
|
||||
'cpoptions' includes the '<' flag.
|
||||
3. Use the termcap entry, with the form <t_xx>, where "xx" is the name of the
|
||||
termcap entry. Any string entry can be used. For example: >
|
||||
:map <t_F3> G
|
||||
< Maps function key 13 to "G". This does not work if 'cpoptions' includes
|
||||
the '<' flag.
|
||||
|
||||
The advantage of the second and third method is that the mapping will work on
|
||||
different terminals without modification (the function key will be
|
||||
translated into the same internal code or the actual key code, no matter what
|
||||
terminal you are using. The termcap must be correct for this to work, and you
|
||||
must use the same mappings).
|
||||
|
||||
DETAIL: Vim first checks if a sequence from the keyboard is mapped. If it
|
||||
isn't the terminal key codes are tried (see |terminal-options|). If a
|
||||
terminal code is found it is replaced with the internal code. Then the check
|
||||
for a mapping is done again (so you can map an internal code to something
|
||||
else). What is written into the script file depends on what is recognized.
|
||||
If the terminal key code was recognized as a mapping the key code itself is
|
||||
written to the script file. If it was recognized as a terminal code the
|
||||
internal code is written to the script file.
|
||||
|
||||
|
||||
Mapping ALT-keys *:map-alt-keys*
|
||||
1.10 MAPPING ALT-KEYS *:map-alt-keys*
|
||||
|
||||
In the GUI Vim handles the Alt key itself, thus mapping keys with ALT should
|
||||
always work. But in a terminal Vim gets a sequence of bytes and has to figure
|
||||
@@ -601,6 +630,62 @@ toggled on the fly through the "Main Options" menu, by pressing Ctrl-LeftClick
|
||||
on the terminal; that's a good last resource in case you want to send ESC when
|
||||
using other applications but not when inside VIM.
|
||||
|
||||
|
||||
1.11 MAPPING AN OPERATOR *:map-operator*
|
||||
|
||||
An operator is used before a {motion} command. To define your own operator
|
||||
you must create mapping that first sets the 'operatorfunc' option and then
|
||||
invoke the |g@| operator. After the user types the {motion} command the
|
||||
specified function will be called.
|
||||
|
||||
*g@*
|
||||
g@{motion} Call the function set by the 'operatorfunc' option.
|
||||
The '[ mark is positioned at the start of the text
|
||||
moved over by {motion}, the '] mark on the last
|
||||
character of the text.
|
||||
The function is called with one String argument:
|
||||
"line" {motion} was |linewise|
|
||||
"char" {motion} was |characterwise|
|
||||
"block" {motion} was |blockwise-visual||
|
||||
Although "block" would rarely appear, since it can
|
||||
only result from Visual mode where "g@" is not useful.
|
||||
{not available when compiled without the +eval
|
||||
feature}
|
||||
|
||||
Here is an example that counts the number of spaces with <F4>: >
|
||||
|
||||
nmap <silent> <F4> :set opfunc=CountSpaces<CR>g@
|
||||
vmap <silent> <F4> :<C-U>call CountSpaces(visualmode(), 1)<CR>
|
||||
|
||||
function! CountSpaces(type, ...)
|
||||
let sel_save = &selection
|
||||
let &selection = "inclusive"
|
||||
let reg_save = @@
|
||||
|
||||
if a:0 " Invoked from Visual mode, use '< and '> marks.
|
||||
silent exe "normal! `<" . a:type . "`>y"
|
||||
elseif a:type == 'line'
|
||||
silent exe "normal! '[V']y"
|
||||
elseif a:type == 'block'
|
||||
silent exe "normal! `[\<C-V>`]y"
|
||||
else
|
||||
silent exe "normal! `[v`]y"
|
||||
endif
|
||||
|
||||
echomsg strlen(substitute(@@, '[^ ]', '', 'g'))
|
||||
|
||||
let &selection = sel_save
|
||||
let @@ = reg_save
|
||||
endfunction
|
||||
|
||||
Note that the 'selection' option is temporarily set to "inclusive" to be able
|
||||
to yank exactly the right text by using Visual mode from the '[ to the ']
|
||||
mark.
|
||||
|
||||
Also note that there is a separate mapping for Visual mode. It removes the
|
||||
"'<,'>" range that ":" inserts in Visual mode and invokes the function with
|
||||
visualmode() and an extra argument.
|
||||
|
||||
==============================================================================
|
||||
2. Abbreviations *abbreviations* *Abbreviations*
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
*motion.txt* For Vim version 7.0aa. Last change: 2005 Dec 09
|
||||
*motion.txt* For Vim version 7.0aa. Last change: 2005 Dec 12
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -57,6 +57,7 @@ or change text. The following operators are available:
|
||||
|>| > shift right
|
||||
|<| < shift left
|
||||
|zf| zf define a fold
|
||||
|g@| g@ call function set with the 'operatorfunc' option
|
||||
|
||||
If the motion includes a count and the operator also had a count before it,
|
||||
the two counts are multiplied. For example: "2d3w" deletes six words.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
*options.txt* For Vim version 7.0aa. Last change: 2005 Dec 11
|
||||
*options.txt* For Vim version 7.0aa. Last change: 2005 Dec 13
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -2545,7 +2545,9 @@ A jump table for the options with a short description can be found at |Q_op|.
|
||||
'encoding' is "utf-8" (or one of the other Unicode variants)
|
||||
conversion is most likely done in a way that the reverse
|
||||
conversion results in the same text. When 'encoding' is not
|
||||
"utf-8" special characters may be lost!
|
||||
"utf-8" some non-ASCII characters may be lost! You can use
|
||||
the |++bad| argument to specify what is done with characters
|
||||
that can't be converted.
|
||||
For an empty file or a file with only ASCII characters most encodings
|
||||
will work and the first entry of 'fileencodings' will be used (except
|
||||
"ucs-bom", which requires the BOM to be present). If you prefer
|
||||
@@ -2555,7 +2557,9 @@ A jump table for the options with a short description can be found at |Q_op|.
|
||||
\ set fenc=iso-2022-jp | endif
|
||||
< This sets 'fileencoding' to "iso-2022-jp" if the file does not contain
|
||||
non-blank characters.
|
||||
Note that 'fileencodings' is not used for an new file, 'fileencoding'
|
||||
When the |++enc| argument is used then the value of 'fileencodings' is
|
||||
not used.
|
||||
Note that 'fileencodings' is not used for a new file, 'fileencoding'
|
||||
is always empty then. This means that a non-existing file may get a
|
||||
different encoding than an empty file.
|
||||
The special value "ucs-bom" can be used to check for a Unicode BOM
|
||||
@@ -4646,6 +4650,17 @@ A jump table for the options with a short description can be found at |Q_op|.
|
||||
For the use of the function see 'completefunc'.
|
||||
|
||||
|
||||
*'operatorfunc'* *'opfunc'*
|
||||
'operatorfunc' 'opfunc' string (default: empty)
|
||||
global
|
||||
{not in Vi}
|
||||
This option specifies a function to be called by the |g@| operator.
|
||||
See |:map-operator| for more info and an example.
|
||||
|
||||
This option cannot be set from a |modeline| or in the |sandbox|, for
|
||||
security reasons.
|
||||
|
||||
|
||||
*'osfiletype'* *'oft'* *E366*
|
||||
'osfiletype' 'oft' string (RISC-OS default: "Text",
|
||||
others default: "")
|
||||
@@ -5873,7 +5888,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
||||
{not in Vi}
|
||||
{not available when compiled without the |+syntax|
|
||||
feature}
|
||||
Methods used for spelling suggestions. Both for the |z?| command and
|
||||
Methods used for spelling suggestions. Both for the |z=| command and
|
||||
the |spellsuggest()| function. This is a comma-separated list of
|
||||
items:
|
||||
|
||||
@@ -5892,7 +5907,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
||||
character inserts/deletes/swaps. Works well for
|
||||
simple typing mistakes.
|
||||
|
||||
{number} The maximum number of suggestions listed for |z?|.
|
||||
{number} The maximum number of suggestions listed for |z=|.
|
||||
Not used for |spellsuggest()|. The number of
|
||||
suggestions is never more than the value of 'lines'
|
||||
minus two.
|
||||
@@ -5914,7 +5929,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
||||
Lists, each with a suggestion and a score.
|
||||
Example:
|
||||
[['the', 33], ['that', 44]]
|
||||
Set 'verbose' and use |z?| to see the scores that the
|
||||
Set 'verbose' and use |z=| to see the scores that the
|
||||
internal methods use. A lower score is better.
|
||||
This may invoke |spellsuggest()| if you temporarily
|
||||
set 'spellsuggest' to exclude the "expr:" part.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
*quickref.txt* For Vim version 7.0aa. Last change: 2005 Nov 25
|
||||
*quickref.txt* For Vim version 7.0aa. Last change: 2005 Dec 12
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -774,6 +774,7 @@ Short explanation of each option: *option-list*
|
||||
|'number'| |'nu'| print the line number in front of each line
|
||||
|'numberwidth'| |'nuw'| number of columns used for the line number
|
||||
|'omnifunc'| |'ofu'| function for filetype-specific completion
|
||||
|'operatorfunc'| |'opfunc'| funtion to be called for |g@| operator
|
||||
|'osfiletype'| |'oft'| operating system-specific filetype information
|
||||
|'paragraphs'| |'para'| nroff macros that separate paragraphs
|
||||
|'paste'| allow pasting text
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
*recover.txt* For Vim version 7.0aa. Last change: 2005 Feb 10
|
||||
*recover.txt* For Vim version 7.0aa. Last change: 2005 Dec 12
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -126,6 +126,28 @@ command:
|
||||
A Vim swap file can be recognized by the first six characters: "b0VIM ".
|
||||
After that comes the version number, e.g., "3.0".
|
||||
|
||||
|
||||
Links and symbolic links ~
|
||||
|
||||
On Unix it is possible to have two names for the same file. This can be done
|
||||
with hard links and with symbolic links (symlinks).
|
||||
|
||||
For hard links Vim does not know the other name of the file. Therefore, the
|
||||
name of the swapfile will be based on the name you used to edit the file.
|
||||
There is no check for editing the same file by the other name too, because Vim
|
||||
cannot find the other swapfile (except for searching all of your harddisk,
|
||||
which would be very slow).
|
||||
|
||||
For symbolic links Vim resolves the links to find the name of the actual file.
|
||||
The swap file name is based on that name. Thus it doesn't matter by what name
|
||||
you edit the file, the swap file name will normally be the same. However,
|
||||
there are exceptions:
|
||||
- When the directory of the actual file is not writable the swapfile is put
|
||||
elsewhere.
|
||||
- When the symbolic links somehow create a loop you get an *E773* error
|
||||
message and the unmodified file name will be used. You won't be able to
|
||||
save your file normally.
|
||||
|
||||
==============================================================================
|
||||
2. Recovery *recovery* *E308* *E311*
|
||||
|
||||
|
||||
@@ -614,6 +614,8 @@ $VIMRUNTIME starting.txt /*$VIMRUNTIME*
|
||||
'omnifunc' options.txt /*'omnifunc'*
|
||||
'op' vi_diff.txt /*'op'*
|
||||
'open' vi_diff.txt /*'open'*
|
||||
'operatorfunc' options.txt /*'operatorfunc'*
|
||||
'opfunc' options.txt /*'opfunc'*
|
||||
'optimize' vi_diff.txt /*'optimize'*
|
||||
'option' intro.txt /*'option'*
|
||||
'osfiletype' options.txt /*'osfiletype'*
|
||||
@@ -1011,6 +1013,7 @@ $VIMRUNTIME starting.txt /*$VIMRUNTIME*
|
||||
( motion.txt /*(*
|
||||
) motion.txt /*)*
|
||||
+ motion.txt /*+*
|
||||
++bad editing.txt /*++bad*
|
||||
++bin editing.txt /*++bin*
|
||||
++builtin_terms various.txt /*++builtin_terms*
|
||||
++enc editing.txt /*++enc*
|
||||
@@ -2144,9 +2147,14 @@ $VIMRUNTIME starting.txt /*$VIMRUNTIME*
|
||||
:map-<silent> map.txt /*:map-<silent>*
|
||||
:map-<unique> map.txt /*:map-<unique>*
|
||||
:map-alt-keys map.txt /*:map-alt-keys*
|
||||
:map-arguments map.txt /*:map-arguments*
|
||||
:map-commands map.txt /*:map-commands*
|
||||
:map-local map.txt /*:map-local*
|
||||
:map-modes map.txt /*:map-modes*
|
||||
:map-operator map.txt /*:map-operator*
|
||||
:map-script map.txt /*:map-script*
|
||||
:map-silent map.txt /*:map-silent*
|
||||
:map-special-chars map.txt /*:map-special-chars*
|
||||
:map-special-keys map.txt /*:map-special-keys*
|
||||
:map-undo map.txt /*:map-undo*
|
||||
:map-verbose map.txt /*:map-verbose*
|
||||
@@ -3777,6 +3785,7 @@ E77 message.txt /*E77*
|
||||
E770 spell.txt /*E770*
|
||||
E771 spell.txt /*E771*
|
||||
E772 spell.txt /*E772*
|
||||
E773 recover.txt /*E773*
|
||||
E78 motion.txt /*E78*
|
||||
E79 message.txt /*E79*
|
||||
E80 message.txt /*E80*
|
||||
@@ -5158,6 +5167,7 @@ g<Up> motion.txt /*g<Up>*
|
||||
g? change.txt /*g?*
|
||||
g?? change.txt /*g??*
|
||||
g?g? change.txt /*g?g?*
|
||||
g@ map.txt /*g@*
|
||||
gD pattern.txt /*gD*
|
||||
gE motion.txt /*gE*
|
||||
gH visual.txt /*gH*
|
||||
@@ -5991,6 +6001,7 @@ new-commands-5.4 version5.txt /*new-commands-5.4*
|
||||
new-debug-itf version6.txt /*new-debug-itf*
|
||||
new-debug-mode version6.txt /*new-debug-mode*
|
||||
new-debug-support version7.txt /*new-debug-support*
|
||||
new-define-operator version7.txt /*new-define-operator*
|
||||
new-diff-mode version6.txt /*new-diff-mode*
|
||||
new-encryption version5.txt /*new-encryption*
|
||||
new-evim version6.txt /*new-evim*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
*todo.txt* For Vim version 7.0aa. Last change: 2005 Dec 11
|
||||
*todo.txt* For Vim version 7.0aa. Last change: 2005 Dec 13
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -30,32 +30,6 @@ be worked on, but only if you sponsor Vim development. See |sponsor|.
|
||||
*known-bugs*
|
||||
-------------------- Known bugs and current work -----------------------
|
||||
|
||||
When editing a file "a" that is a symbolic link to "b", while another Vim is
|
||||
editing "b", there is no warning. Follow symlink to make swap file name?
|
||||
Patch from Stefano Zacchiroli. Updated by James Vega, Dec 2.
|
||||
|
||||
Using pipes for filter commands: provide some way to type a password, keep
|
||||
stderr in/out open for this? (Konstanti Rozinov)
|
||||
New problem: password is echoed. Put terminal in cooked mode and don't read
|
||||
from terminal?
|
||||
|
||||
Allow the user to handle the situation that a swap file already exists.
|
||||
Option to define a function to be called? Function would return the character
|
||||
that the dialog provides. Would make it possible to bring the other Vim to
|
||||
the foreground and abort the edit. Or hard-code this?
|
||||
|
||||
To support mapping <F4> to be used as <F4>{motion}: Add operator that
|
||||
executes a user defined function. '[ and '] marks are at start and end of
|
||||
text. ":map <F4> :set opfunc=MyOp<CR>gy".
|
||||
|
||||
Patch from Yasuhiro Matsumoto: ":e ++enc=xxx" keeps encoding for conversion
|
||||
errors and illegal bytes. Make default to replace bad bytes/characters with
|
||||
'?' and allow for two alternatives:
|
||||
:e ++enc=xxx ++bad=keep foo.txt
|
||||
:e ++enc=xxx ++bad=drop foo.txt
|
||||
:e ++enc=xxx ++bad=? foo.txt
|
||||
(patch 6 December)
|
||||
|
||||
ml_get error with specific vimrc and lots of plugins. (Tomi Mickelsson)
|
||||
|
||||
Win32: preserve the hidden attribute of the viminfo file.
|
||||
@@ -73,6 +47,7 @@ ccomplete:
|
||||
characters, advance to the first match instead of removing the popup menu.
|
||||
If there is no match remove the selection. (Yegappan Lakshmanan)
|
||||
- Complete the longest common match instead of the first match?
|
||||
For all kinds of completions? Configurable?
|
||||
- !_TAG_FILE_FORMAT and it's ilk are listed in the global completions
|
||||
- When completing something that is a structure, add the "." or "->".
|
||||
- When a typedef or struct is local to a file only use it in that file?
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
*version7.txt* For Vim version 7.0aa. Last change: 2005 Dec 11
|
||||
*version7.txt* For Vim version 7.0aa. Last change: 2005 Dec 13
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -29,6 +29,7 @@ Scroll back in messages |new-scroll-back|
|
||||
POSIX compatibility |new-posix|
|
||||
Debugger support |new-debug-support|
|
||||
Remote file explorer |new-netrw-explore|
|
||||
Define an operator |new-define-operator|
|
||||
Various new items |new-items-7|
|
||||
|
||||
IMPROVEMENTS |improvements-7|
|
||||
@@ -167,7 +168,7 @@ The 'spellsuggest' option specifies the methods used for making suggestions
|
||||
|
||||
The |[s| and |]s| commands can be used to move to the next or previous error.
|
||||
The |zg| and |zw| commands can be used to add good and wrong words.
|
||||
The |z?| command can be used to correct the word.
|
||||
The |z=| command can be used to correct the word.
|
||||
The |:mkspell| command is used to generate a Vim spell file from word lists.
|
||||
|
||||
The "undercurl" highlighting attribute was added to nicely point out spelling
|
||||
@@ -341,6 +342,18 @@ and a GUI dialog is not possible.
|
||||
The netrw plugin is maintained by Charles Campbell.
|
||||
|
||||
|
||||
Define an operator *new-define-operator*
|
||||
------------------
|
||||
|
||||
Previously it was not possible to define your own operator; a command that is
|
||||
followed by a {motion}. Vim 7 introduces the 'operatorfunc' option and the
|
||||
|g@| operator. This makes it possible to define a mapping that works like an
|
||||
operator. The actual work is then done by a function, which is invoked
|
||||
through the |g@| operator.
|
||||
|
||||
See |:map-operator| for the explanation and an example.
|
||||
|
||||
|
||||
Various new items *new-items-7*
|
||||
-----------------
|
||||
|
||||
@@ -427,6 +440,16 @@ Ex command modifiers: ~
|
||||
|:sandbox| Execute a command in the sandbox.
|
||||
|
||||
|
||||
Ex command arguments: ~
|
||||
|
||||
|++bad| Specify what happens with characters that can't be
|
||||
converted and illegal bytes. (code example by Yasuhiro
|
||||
Matsumoto)
|
||||
Also, when a conversion error occurs or illegal bytes
|
||||
are found include the line number in the error
|
||||
message.
|
||||
|
||||
|
||||
New and extended functions: ~
|
||||
|
||||
|add()| append an item to a List
|
||||
@@ -573,17 +596,19 @@ Mac: GUI font selector. (Peter Cucka)
|
||||
|
||||
Mac: support for multi-byte characters. (Da Woon Jung)
|
||||
|
||||
GUI font selector for Motif. (Marcin Dalecki)
|
||||
|
||||
Nicer toolbar buttons for Motif. (Marcin Dalecki)
|
||||
|
||||
Mnemonics for the Motif find/replace dialog. (Marcin Dalecki)
|
||||
Mac: Support the xterm mouse in the non-GUI version.
|
||||
|
||||
Mac: better integration with Xcode. Post a fake mouse-up event after the odoc
|
||||
event and the drag receive handler to work around a stall after Vim loads a
|
||||
file. Fixed an off-by-one line number error. (Da Woon Jung)
|
||||
|
||||
Added the t_SI and t_EI escape sequences for starting and ending Insert mode.
|
||||
GUI font selector for Motif. (Marcin Dalecki)
|
||||
|
||||
Nicer toolbar buttons for Motif. (Marcin Dalecki)
|
||||
|
||||
Mnemonics for the Motif find/replace dialog. (Marcin Dalecki)
|
||||
|
||||
To be used to set the cursor shape to a bar or a block. No default values,
|
||||
they are not supported by termcap/terminfo.
|
||||
|
||||
@@ -707,6 +732,10 @@ the swap file to indicate it is in the same directory as the edited file. The
|
||||
used path then doesn't matter and the check for editing the same file is much
|
||||
more reliable.
|
||||
|
||||
Unix: When editing a file through a symlink the swap file would use the name
|
||||
of the symlink. Now use the name of the actual file, so that editing the same
|
||||
file twice is detected. (suggestions by Stefano Zacchiroli and James Vega)
|
||||
|
||||
Client-server communication now supports 'encoding'. When setting 'encoding'
|
||||
in a Vim server to "utf-8", and using "vim --remote fname" in a console,
|
||||
"fname" is converted from the console encoding to utf-8. Also allows Vims
|
||||
@@ -869,6 +898,10 @@ file would be used for the current buffer. But the buffer contents is
|
||||
actually different from the file content. Don't set the file name, unless the
|
||||
'P' flag is present in 'cpoptions'.
|
||||
|
||||
When starting to edit a new file and the directory for the file doesn't exist
|
||||
then Vim will report "[New DIRECTORY]" instead of "[New File] to give the user
|
||||
a hint that something might be wrong.
|
||||
|
||||
==============================================================================
|
||||
COMPILE TIME CHANGES *compile-changes-7*
|
||||
|
||||
@@ -1438,4 +1471,8 @@ the buffer to use "fname", the modified flag was reset.
|
||||
When appending to to current file the "not edited" flag would be reset.
|
||||
":w" would overwrite the file accidentally.
|
||||
|
||||
Unix: When filtering text with an external command Vim would still read input,
|
||||
causing text typed for the command (e.g., a password) to be eaten and echoed.
|
||||
Don't read input when the terminal is in cooked mode.
|
||||
|
||||
vim:tw=78:ts=8:ft=help:norl:
|
||||
|
||||
@@ -12836,10 +12836,9 @@ f_resolve(argvars, rettv)
|
||||
remain = vim_strsave(q - 1);
|
||||
else
|
||||
{
|
||||
cpy = vim_strnsave(q-1, STRLEN(q-1) + STRLEN(remain));
|
||||
cpy = concat_str(q - 1, remain);
|
||||
if (cpy != NULL)
|
||||
{
|
||||
STRCAT(cpy, remain);
|
||||
vim_free(remain);
|
||||
remain = cpy;
|
||||
}
|
||||
@@ -15713,6 +15712,8 @@ set_cmdarg(eap, oldarg)
|
||||
# ifdef FEAT_MBYTE
|
||||
if (eap->force_enc != 0)
|
||||
len += (unsigned)STRLEN(eap->cmd + eap->force_enc) + 7;
|
||||
if (eap->bad_char != 0)
|
||||
len += (unsigned)STRLEN(eap->cmd + eap->bad_char) + 7;
|
||||
# endif
|
||||
|
||||
newval = alloc(len + 1);
|
||||
@@ -15732,6 +15733,9 @@ set_cmdarg(eap, oldarg)
|
||||
if (eap->force_enc != 0)
|
||||
sprintf((char *)newval + STRLEN(newval), " ++enc=%s",
|
||||
eap->cmd + eap->force_enc);
|
||||
if (eap->bad_char != 0)
|
||||
sprintf((char *)newval + STRLEN(newval), " ++bad=%s",
|
||||
eap->cmd + eap->bad_char);
|
||||
# endif
|
||||
vimvars[VV_CMDARG].vv_str = newval;
|
||||
return oldval;
|
||||
|
||||
@@ -996,9 +996,10 @@ struct exarg
|
||||
int amount; /* number of '>' or '<' for shift command */
|
||||
int regname; /* register name (NUL if none) */
|
||||
int force_bin; /* 0, FORCE_BIN or FORCE_NOBIN */
|
||||
int force_ff; /* forced 'fileformat' (index in cmd[]) */
|
||||
int force_ff; /* ++ff= argument (index in cmd[]) */
|
||||
#ifdef FEAT_MBYTE
|
||||
int force_enc; /* forced 'encoding' (index in cmd[]) */
|
||||
int force_enc; /* ++enc= argument (index in cmd[]) */
|
||||
int bad_char; /* ++bad= argument (index in cmd[]) */
|
||||
#endif
|
||||
#ifdef FEAT_USR_CMDS
|
||||
int useridx; /* user command index */
|
||||
|
||||
@@ -4549,6 +4549,11 @@ getargopt(eap)
|
||||
arg += 8;
|
||||
pp = &eap->force_enc;
|
||||
}
|
||||
else if (STRNCMP(arg, "bad", 3) == 0)
|
||||
{
|
||||
arg += 3;
|
||||
pp = &eap->bad_char;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (pp == NULL || *arg != '=')
|
||||
@@ -4568,12 +4573,26 @@ getargopt(eap)
|
||||
return FAIL;
|
||||
#ifdef FEAT_MBYTE
|
||||
}
|
||||
else
|
||||
else if (pp == &eap->force_enc)
|
||||
{
|
||||
/* Make 'fileencoding' lower case. */
|
||||
for (p = eap->cmd + eap->force_enc; *p != NUL; ++p)
|
||||
*p = TOLOWER_ASC(*p);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Check ++bad= argument. Must be a single-byte character, "keep" or
|
||||
* "drop". */
|
||||
p = eap->cmd + eap->bad_char;
|
||||
if (STRICMP(p, "keep") == 0)
|
||||
eap->bad_char = BAD_KEEP;
|
||||
else if (STRICMP(p, "drop") == 0)
|
||||
eap->bad_char = BAD_DROP;
|
||||
else if (MB_BYTE2LEN(*p) == 1 && p[1] == NUL)
|
||||
eap->bad_char = *p;
|
||||
else
|
||||
return FAIL;
|
||||
}
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
|
||||
@@ -972,7 +972,7 @@
|
||||
* +mouse Any mouse support (any of the above enabled).
|
||||
*/
|
||||
/* OS/2 and Amiga console have no mouse support */
|
||||
#if (!defined(AMIGA) && !defined(OS2) && !defined(MACOS))
|
||||
#if !defined(AMIGA) && !defined(OS2)
|
||||
# ifdef FEAT_NORMAL
|
||||
# define FEAT_MOUSE_XTERM
|
||||
# endif
|
||||
|
||||
513
src/fileio.c
513
src/fileio.c
@@ -124,6 +124,7 @@ struct bw_info
|
||||
static int buf_write_bytes __ARGS((struct bw_info *ip));
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
static linenr_T readfile_linenr __ARGS((linenr_T linecnt, char_u *p, char_u *endp));
|
||||
static int ucs2bytes __ARGS((unsigned c, char_u **pp, int flags));
|
||||
static int same_encoding __ARGS((char_u *a, char_u *b));
|
||||
static int get_fio_flags __ARGS((char_u *ptr));
|
||||
@@ -138,6 +139,7 @@ static int get_mac_fio_flags __ARGS((char_u *ptr));
|
||||
#endif
|
||||
static int move_lines __ARGS((buf_T *frombuf, buf_T *tobuf));
|
||||
|
||||
|
||||
void
|
||||
filemess(buf, name, s, attr)
|
||||
buf_T *buf;
|
||||
@@ -257,10 +259,13 @@ readfile(fname, sfname, from, lines_to_skip, lines_to_read, eap, flags)
|
||||
int file_rewind = FALSE;
|
||||
#ifdef FEAT_MBYTE
|
||||
int can_retry;
|
||||
int conv_error = FALSE; /* conversion error detected */
|
||||
linenr_T conv_error = 0; /* line nr with conversion error */
|
||||
linenr_T illegal_byte = 0; /* line nr with illegal byte */
|
||||
int keep_dest_enc = FALSE; /* don't retry when char doesn't fit
|
||||
in destination encoding */
|
||||
linenr_T illegal_byte = 0; /* line nr with illegal byte */
|
||||
int bad_char_behavior = BAD_REPLACE;
|
||||
/* BAD_KEEP, BAD_DROP or character to
|
||||
* replace with */
|
||||
char_u *tmpname = NULL; /* name of 'charconvert' output file */
|
||||
int fio_flags = 0;
|
||||
char_u *fenc; /* fileencoding to use */
|
||||
@@ -556,7 +561,11 @@ readfile(fname, sfname, from, lines_to_skip, lines_to_read, eap, flags)
|
||||
if (!bt_dontwrite(curbuf))
|
||||
#endif
|
||||
check_need_swap(newfile);
|
||||
filemess(curbuf, sfname, (char_u *)_("[New File]"), 0);
|
||||
if (dir_of_file_exists(fname))
|
||||
filemess(curbuf, sfname, (char_u *)_("[New File]"), 0);
|
||||
else
|
||||
filemess(curbuf, sfname,
|
||||
(char_u *)_("[New DIRECTORY]"), 0);
|
||||
#ifdef FEAT_VIMINFO
|
||||
/* Even though this is a new file, it might have been
|
||||
* edited before and deleted. Get the old marks. */
|
||||
@@ -750,13 +759,18 @@ readfile(fname, sfname, from, lines_to_skip, lines_to_read, eap, flags)
|
||||
linecnt = curbuf->b_ml.ml_line_count;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/* "++bad=" argument. */
|
||||
if (eap != NULL && eap->bad_char != 0)
|
||||
bad_char_behavior = eap->bad_char;
|
||||
|
||||
/*
|
||||
* Decide which 'encoding' to use first.
|
||||
* Decide which 'encoding' to use or use first.
|
||||
*/
|
||||
if (eap != NULL && eap->force_enc != 0)
|
||||
{
|
||||
fenc = enc_canonize(eap->cmd + eap->force_enc);
|
||||
fenc_alloced = TRUE;
|
||||
keep_dest_enc = TRUE;
|
||||
}
|
||||
else if (curbuf->b_p_bin)
|
||||
{
|
||||
@@ -860,7 +874,7 @@ retry:
|
||||
#ifdef FEAT_MBYTE
|
||||
if (newfile)
|
||||
curbuf->b_p_bomb = FALSE;
|
||||
conv_error = FALSE;
|
||||
conv_error = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -904,7 +918,7 @@ retry:
|
||||
/* Conversion given with "++cc=" wasn't possible, read
|
||||
* without conversion. */
|
||||
notconverted = TRUE;
|
||||
conv_error = FALSE;
|
||||
conv_error = 0;
|
||||
if (fenc_alloced)
|
||||
vim_free(fenc);
|
||||
fenc = (char_u *)"";
|
||||
@@ -1039,11 +1053,10 @@ retry:
|
||||
}
|
||||
}
|
||||
|
||||
/* Set can_retry when it's possible to rewind the file and try with
|
||||
/* Set "can_retry" when it's possible to rewind the file and try with
|
||||
* another "fenc" value. It's FALSE when no other "fenc" to try, reading
|
||||
* stdin or "fenc" was specified with "++enc=". */
|
||||
can_retry = (*fenc != NUL && !read_stdin
|
||||
&& (eap == NULL || eap->force_enc == 0));
|
||||
* stdin or fixed at a specific encoding. */
|
||||
can_retry = (*fenc != NUL && !read_stdin && !keep_dest_enc);
|
||||
#endif
|
||||
|
||||
if (!skip_read)
|
||||
@@ -1225,8 +1238,30 @@ retry:
|
||||
error = TRUE;
|
||||
#ifdef FEAT_MBYTE
|
||||
else if (conv_restlen > 0)
|
||||
/* some trailing bytes unconverted */
|
||||
conv_error = TRUE;
|
||||
{
|
||||
/* Reached end-of-file but some trailing bytes could
|
||||
* not be converted. Trucated file? */
|
||||
if (conv_error == 0)
|
||||
conv_error = linecnt;
|
||||
if (bad_char_behavior != BAD_DROP)
|
||||
{
|
||||
fio_flags = 0; /* don't convert this */
|
||||
if (bad_char_behavior == BAD_KEEP)
|
||||
{
|
||||
/* Keep the trailing bytes as-is. */
|
||||
size = conv_restlen;
|
||||
ptr -= conv_restlen;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Replace the trailing bytes with the
|
||||
* replacement character. */
|
||||
size = 1;
|
||||
*--ptr = bad_char_behavior;
|
||||
}
|
||||
conv_restlen = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1345,16 +1380,25 @@ retry:
|
||||
== (size_t)-1 && ICONV_ERRNO != ICONV_EINVAL)
|
||||
|| from_size > CONV_RESTLEN)
|
||||
{
|
||||
if (!keep_dest_enc && can_retry)
|
||||
if (can_retry)
|
||||
goto rewind_retry;
|
||||
if (!keep_dest_enc)
|
||||
conv_error = TRUE;
|
||||
if (conv_error == 0)
|
||||
conv_error = readfile_linenr(linecnt,
|
||||
ptr, (char_u *)top);
|
||||
|
||||
/* Ignore a byte and try again. */
|
||||
/* Deal with a bad byte and continue with the next. */
|
||||
++fromp;
|
||||
--from_size;
|
||||
*top++ = '?';
|
||||
--to_size;
|
||||
if (bad_char_behavior == BAD_KEEP)
|
||||
{
|
||||
*top++ = *(fromp - 1);
|
||||
--to_size;
|
||||
}
|
||||
else if (bad_char_behavior != BAD_DROP)
|
||||
{
|
||||
*top++ = bad_char_behavior;
|
||||
--to_size;
|
||||
}
|
||||
}
|
||||
|
||||
if (from_size > 0)
|
||||
@@ -1375,141 +1419,167 @@ retry:
|
||||
# ifdef WIN3264
|
||||
if (fio_flags & FIO_CODEPAGE)
|
||||
{
|
||||
char_u *src, *dst;
|
||||
int u8c;
|
||||
WCHAR ucs2buf[3];
|
||||
int ucs2len;
|
||||
int codepage = FIO_GET_CP(fio_flags);
|
||||
int bytelen;
|
||||
int found_bad;
|
||||
char replstr[2];
|
||||
|
||||
/*
|
||||
* Conversion from an MS-Windows codepage or UTF-8 to UTF-8 or
|
||||
* a codepage, using standard MS-Windows functions.
|
||||
* 1. find out how many ucs-2 characters there are.
|
||||
* 2. convert from 'fileencoding' to ucs-2
|
||||
* 3. convert from ucs-2 to 'encoding'
|
||||
*/
|
||||
char_u *ucsp;
|
||||
size_t from_size = size;
|
||||
int needed;
|
||||
char_u *p;
|
||||
int u8c;
|
||||
|
||||
/*
|
||||
* 1. find out how many ucs-2 characters there are.
|
||||
*/
|
||||
# ifdef CP_UTF8 /* VC 4.1 doesn't define CP_UTF8 */
|
||||
if (FIO_GET_CP(fio_flags) == CP_UTF8)
|
||||
{
|
||||
int l, flen;
|
||||
|
||||
/* Handle CP_UTF8 ourselves to be able to handle trailing
|
||||
* bytes properly. First find out the number of
|
||||
* characters and check for trailing bytes. */
|
||||
needed = 0;
|
||||
p = ptr;
|
||||
for (flen = from_size; flen > 0; flen -= l)
|
||||
{
|
||||
l = utf_ptr2len_len(p, flen);
|
||||
if (l > flen) /* incomplete char */
|
||||
{
|
||||
if (l > CONV_RESTLEN)
|
||||
/* weird overlong byte sequence */
|
||||
goto rewind_retry;
|
||||
mch_memmove(conv_rest, p, flen);
|
||||
conv_restlen = flen;
|
||||
from_size -= flen;
|
||||
break;
|
||||
}
|
||||
if (l == 1 && *p >= 0x80) /* illegal byte */
|
||||
goto rewind_retry;
|
||||
++needed;
|
||||
p += l;
|
||||
}
|
||||
}
|
||||
else
|
||||
# endif
|
||||
{
|
||||
/* We can't tell if the last byte of an MBCS string is
|
||||
* valid and MultiByteToWideChar() returns zero if it
|
||||
* isn't. Try the whole string, and if that fails, bump
|
||||
* the last byte into conv_rest and try again. */
|
||||
needed = MultiByteToWideChar(FIO_GET_CP(fio_flags),
|
||||
MB_ERR_INVALID_CHARS, (LPCSTR)ptr, from_size,
|
||||
NULL, 0);
|
||||
if (needed == 0)
|
||||
{
|
||||
conv_rest[0] = ptr[from_size - 1];
|
||||
conv_restlen = 1;
|
||||
--from_size;
|
||||
needed = MultiByteToWideChar(FIO_GET_CP(fio_flags),
|
||||
MB_ERR_INVALID_CHARS, (LPCSTR)ptr, from_size,
|
||||
NULL, 0);
|
||||
}
|
||||
|
||||
/* If there really is a conversion error, try using another
|
||||
* conversion. */
|
||||
if (needed == 0)
|
||||
goto rewind_retry;
|
||||
}
|
||||
|
||||
/*
|
||||
* 2. convert from 'fileencoding' to ucs-2
|
||||
* a codepage, using standard MS-Windows functions. This
|
||||
* requires two steps:
|
||||
* 1. convert from 'fileencoding' to ucs-2
|
||||
* 2. convert from ucs-2 to 'encoding'
|
||||
*
|
||||
* Put the result of conversion to UCS-2 at the end of the
|
||||
* buffer, then convert from UCS-2 to UTF-8 or "enc_codepage"
|
||||
* into the start of the buffer. If there is not enough space
|
||||
* just fail, there is probably something wrong.
|
||||
* Because there may be illegal bytes AND an incomplete byte
|
||||
* sequence at the end, we may have to do the conversion one
|
||||
* character at a time to get it right.
|
||||
*/
|
||||
ucsp = ptr + real_size - (needed * sizeof(WCHAR));
|
||||
if (ucsp < ptr + size)
|
||||
goto rewind_retry;
|
||||
|
||||
# ifdef CP_UTF8 /* VC 4.1 doesn't define CP_UTF8 */
|
||||
if (FIO_GET_CP(fio_flags) == CP_UTF8)
|
||||
{
|
||||
int l, flen;
|
||||
|
||||
/* Convert from utf-8 to ucs-2. */
|
||||
needed = 0;
|
||||
p = ptr;
|
||||
for (flen = from_size; flen > 0; flen -= l)
|
||||
{
|
||||
l = utf_ptr2len_len(p, flen);
|
||||
u8c = utf_ptr2char(p);
|
||||
ucsp[needed * 2] = (u8c & 0xff);
|
||||
ucsp[needed * 2 + 1] = (u8c >> 8);
|
||||
++needed;
|
||||
p += l;
|
||||
}
|
||||
}
|
||||
/* Replacement string for WideCharToMultiByte(). */
|
||||
if (bad_char_behavior > 0)
|
||||
replstr[0] = bad_char_behavior;
|
||||
else
|
||||
# endif
|
||||
needed = MultiByteToWideChar(FIO_GET_CP(fio_flags),
|
||||
MB_ERR_INVALID_CHARS, (LPCSTR)ptr,
|
||||
from_size, (LPWSTR)ucsp, needed);
|
||||
replstr[0] = '?';
|
||||
replstr[1] = NUL;
|
||||
|
||||
/*
|
||||
* 3. convert from ucs-2 to 'encoding'
|
||||
* Move the bytes to the end of the buffer, so that we have
|
||||
* room to put the result at the start.
|
||||
*/
|
||||
if (enc_utf8)
|
||||
{
|
||||
/* From UCS-2 to UTF-8. Cannot fail. */
|
||||
p = ptr;
|
||||
for (; needed > 0; --needed)
|
||||
{
|
||||
u8c = *ucsp++;
|
||||
u8c += (*ucsp++ << 8);
|
||||
p += utf_char2bytes(u8c, p);
|
||||
}
|
||||
size = p - ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOL bad = FALSE;
|
||||
src = ptr + real_size - size;
|
||||
mch_memmove(src, ptr, size);
|
||||
|
||||
/* From UCS-2 to "enc_codepage". If the conversion uses
|
||||
* the default character "?", the data doesn't fit in this
|
||||
* encoding, so fail (unless forced). */
|
||||
size = WideCharToMultiByte(enc_codepage, 0,
|
||||
(LPCWSTR)ucsp, needed,
|
||||
(LPSTR)ptr, real_size, "?", &bad);
|
||||
if (bad && !keep_dest_enc)
|
||||
goto rewind_retry;
|
||||
/*
|
||||
* Do the conversion.
|
||||
*/
|
||||
dst = ptr;
|
||||
size = size;
|
||||
while (size > 0)
|
||||
{
|
||||
found_bad = FALSE;
|
||||
|
||||
# ifdef CP_UTF8 /* VC 4.1 doesn't define CP_UTF8 */
|
||||
if (codepage == CP_UTF8)
|
||||
{
|
||||
/* Handle CP_UTF8 input ourselves to be able to handle
|
||||
* trailing bytes properly.
|
||||
* Get one UTF-8 character from src. */
|
||||
bytelen = utf_ptr2len_len(src, size);
|
||||
if (bytelen > size)
|
||||
{
|
||||
/* Only got some bytes of a character. Normally
|
||||
* it's put in "conv_rest", but if it's too long
|
||||
* deal with it as if they were illegal bytes. */
|
||||
if (bytelen <= CONV_RESTLEN)
|
||||
break;
|
||||
|
||||
/* weird overlong byte sequence */
|
||||
bytelen = size;
|
||||
found_bad = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8c = utf_ptr2char(src);
|
||||
if (u8c > 0xffff)
|
||||
found_bad = TRUE;
|
||||
ucs2buf[0] = u8c;
|
||||
ucs2len = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
# endif
|
||||
{
|
||||
/* We don't know how long the byte sequence is, try
|
||||
* from one to three bytes. */
|
||||
for (bytelen = 1; bytelen <= size && bytelen <= 3;
|
||||
++bytelen)
|
||||
{
|
||||
ucs2len = MultiByteToWideChar(codepage,
|
||||
MB_ERR_INVALID_CHARS,
|
||||
(LPCSTR)src, bytelen,
|
||||
ucs2buf, 3);
|
||||
if (ucs2len > 0)
|
||||
break;
|
||||
}
|
||||
if (ucs2len == 0)
|
||||
{
|
||||
/* If we have only one byte then it's probably an
|
||||
* incomplete byte sequence. Otherwise discard
|
||||
* one byte as a bad character. */
|
||||
if (size == 1)
|
||||
break;
|
||||
found_bad = TRUE;
|
||||
bytelen = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found_bad)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Convert "ucs2buf[ucs2len]" to 'enc' in "dst". */
|
||||
if (enc_utf8)
|
||||
{
|
||||
/* From UCS-2 to UTF-8. Cannot fail. */
|
||||
for (i = 0; i < ucs2len; ++i)
|
||||
dst += utf_char2bytes(ucs2buf[i], dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOL bad = FALSE;
|
||||
int dstlen;
|
||||
|
||||
/* From UCS-2 to "enc_codepage". If the
|
||||
* conversion uses the default character "?",
|
||||
* the data doesn't fit in this encoding. */
|
||||
dstlen = WideCharToMultiByte(enc_codepage, 0,
|
||||
(LPCWSTR)ucs2buf, ucs2len,
|
||||
(LPSTR)dst, (src - dst),
|
||||
replstr, &bad);
|
||||
if (bad)
|
||||
found_bad = TRUE;
|
||||
else
|
||||
dst += dstlen;
|
||||
}
|
||||
}
|
||||
|
||||
if (found_bad)
|
||||
{
|
||||
/* Deal with bytes we can't convert. */
|
||||
if (can_retry)
|
||||
goto rewind_retry;
|
||||
if (conv_error == 0)
|
||||
conv_error = readfile_linenr(linecnt, ptr, dst);
|
||||
if (bad_char_behavior != BAD_DROP)
|
||||
{
|
||||
if (bad_char_behavior == BAD_KEEP)
|
||||
{
|
||||
mch_memmove(dst, src, bytelen);
|
||||
dst += bytelen;
|
||||
}
|
||||
else
|
||||
*dst++ = bad_char_behavior;
|
||||
}
|
||||
}
|
||||
|
||||
src += bytelen;
|
||||
size -= bytelen;
|
||||
}
|
||||
|
||||
if (size > 0)
|
||||
{
|
||||
/* An incomplete byte sequence remaining. */
|
||||
mch_memmove(conv_rest, src, size);
|
||||
conv_restlen = size;
|
||||
}
|
||||
|
||||
/* The new size is equal to how much "dst" was advanced. */
|
||||
size = dst - ptr;
|
||||
}
|
||||
else
|
||||
# endif
|
||||
@@ -1624,7 +1694,13 @@ retry:
|
||||
/* Missing leading word. */
|
||||
if (can_retry)
|
||||
goto rewind_retry;
|
||||
conv_error = TRUE;
|
||||
if (conv_error == 0)
|
||||
conv_error = readfile_linenr(linecnt,
|
||||
ptr, p);
|
||||
if (bad_char_behavior == BAD_DROP)
|
||||
continue;
|
||||
if (bad_char_behavior != BAD_KEEP)
|
||||
u8c = bad_char_behavior;
|
||||
}
|
||||
|
||||
/* found second word of double-word, get the first
|
||||
@@ -1639,15 +1715,22 @@ retry:
|
||||
u16c = *--p;
|
||||
u16c += (*--p << 8);
|
||||
}
|
||||
u8c = 0x10000 + ((u16c & 0x3ff) << 10)
|
||||
+ (u8c & 0x3ff);
|
||||
|
||||
/* Check if the word is indeed a leading word. */
|
||||
if (u16c < 0xd800 || u16c > 0xdbff)
|
||||
{
|
||||
if (can_retry)
|
||||
goto rewind_retry;
|
||||
conv_error = TRUE;
|
||||
if (conv_error == 0)
|
||||
conv_error = readfile_linenr(linecnt,
|
||||
ptr, p);
|
||||
if (bad_char_behavior == BAD_DROP)
|
||||
continue;
|
||||
if (bad_char_behavior != BAD_KEEP)
|
||||
u8c = bad_char_behavior;
|
||||
}
|
||||
u8c = 0x10000 + ((u16c & 0x3ff) << 10)
|
||||
+ (u8c & 0x3ff);
|
||||
}
|
||||
}
|
||||
else if (fio_flags & FIO_UCS4)
|
||||
@@ -1674,6 +1757,8 @@ retry:
|
||||
else
|
||||
{
|
||||
len = utf_head_off(ptr, p);
|
||||
p -= len;
|
||||
u8c = utf_ptr2char(p);
|
||||
if (len == 0)
|
||||
{
|
||||
/* Not a valid UTF-8 character, retry with
|
||||
@@ -1681,10 +1766,14 @@ retry:
|
||||
* report the error. */
|
||||
if (can_retry)
|
||||
goto rewind_retry;
|
||||
conv_error = TRUE;
|
||||
if (conv_error == 0)
|
||||
conv_error = readfile_linenr(linecnt,
|
||||
ptr, p);
|
||||
if (bad_char_behavior == BAD_DROP)
|
||||
continue;
|
||||
if (bad_char_behavior != BAD_KEEP)
|
||||
u8c = bad_char_behavior;
|
||||
}
|
||||
p -= len;
|
||||
u8c = utf_ptr2char(p);
|
||||
}
|
||||
}
|
||||
if (enc_utf8) /* produce UTF-8 */
|
||||
@@ -1700,10 +1789,18 @@ retry:
|
||||
/* character doesn't fit in latin1, retry with
|
||||
* another fenc when possible, otherwise just
|
||||
* report the error. */
|
||||
if (can_retry && !keep_dest_enc)
|
||||
if (can_retry)
|
||||
goto rewind_retry;
|
||||
*dest = 0xBF;
|
||||
conv_error = TRUE;
|
||||
if (conv_error == 0)
|
||||
conv_error = readfile_linenr(linecnt, ptr, p);
|
||||
if (bad_char_behavior == BAD_DROP)
|
||||
++dest;
|
||||
else if (bad_char_behavior == BAD_KEEP)
|
||||
*dest = u8c;
|
||||
else if (eap != NULL && eap->bad_char != 0)
|
||||
*dest = bad_char_behavior;
|
||||
else
|
||||
*dest = 0xBF;
|
||||
}
|
||||
else
|
||||
*dest = u8c;
|
||||
@@ -1716,63 +1813,76 @@ retry:
|
||||
size = (long)((ptr + real_size) - dest);
|
||||
ptr = dest;
|
||||
}
|
||||
else if (enc_utf8 && !conv_error && !curbuf->b_p_bin)
|
||||
else if (enc_utf8 && conv_error == 0 && !curbuf->b_p_bin)
|
||||
{
|
||||
/* Reading UTF-8: Check if the bytes are valid UTF-8.
|
||||
* Need to start before "ptr" when part of the character was
|
||||
* read in the previous read() call. */
|
||||
for (p = ptr - utf_head_off(buffer, ptr); p < ptr + size; ++p)
|
||||
for (p = ptr - utf_head_off(buffer, ptr); ; ++p)
|
||||
{
|
||||
int todo = (ptr + size) - p;
|
||||
int l;
|
||||
|
||||
if (todo <= 0)
|
||||
break;
|
||||
if (*p >= 0x80)
|
||||
{
|
||||
len = utf_ptr2len(p);
|
||||
/* A length of 1 means it's an illegal byte. Accept
|
||||
* an incomplete character at the end though, the next
|
||||
* read() will get the next bytes, we'll check it
|
||||
* then. */
|
||||
if (len == 1)
|
||||
l = utf_ptr2len_len(p, todo);
|
||||
if (l > todo)
|
||||
{
|
||||
p += utf_byte2len(*p) - 1;
|
||||
/* Incomplete byte sequence, the next read()
|
||||
* should get them and check the bytes. */
|
||||
p += todo;
|
||||
break;
|
||||
}
|
||||
p += len - 1;
|
||||
if (l == 1)
|
||||
{
|
||||
/* Illegal byte. If we can try another encoding
|
||||
* do that. */
|
||||
if (can_retry)
|
||||
break;
|
||||
|
||||
/* Remember the first linenr with an illegal byte */
|
||||
if (illegal_byte == 0)
|
||||
illegal_byte = readfile_linenr(linecnt, ptr, p);
|
||||
# ifdef USE_ICONV
|
||||
/* When we did a conversion report an error. */
|
||||
if (iconv_fd != (iconv_t)-1 && conv_error == 0)
|
||||
conv_error = readfile_linenr(linecnt, ptr, p);
|
||||
# endif
|
||||
|
||||
/* Drop, keep or replace the bad byte. */
|
||||
if (bad_char_behavior == BAD_DROP)
|
||||
{
|
||||
mch_memmove(p, p+1, todo - 1);
|
||||
--p;
|
||||
--size;
|
||||
}
|
||||
else if (bad_char_behavior != BAD_KEEP)
|
||||
*p = bad_char_behavior;
|
||||
}
|
||||
p += l - 1;
|
||||
}
|
||||
}
|
||||
if (p < ptr + size)
|
||||
{
|
||||
/* Detected a UTF-8 error. */
|
||||
if (can_retry)
|
||||
{
|
||||
rewind_retry:
|
||||
/* Retry reading with another conversion. */
|
||||
/* Retry reading with another conversion. */
|
||||
# if defined(FEAT_EVAL) && defined(USE_ICONV)
|
||||
if (*p_ccv != NUL && iconv_fd != (iconv_t)-1)
|
||||
/* iconv() failed, try 'charconvert' */
|
||||
did_iconv = TRUE;
|
||||
else
|
||||
# endif
|
||||
/* use next item from 'fileencodings' */
|
||||
advance_fenc = TRUE;
|
||||
file_rewind = TRUE;
|
||||
goto retry;
|
||||
}
|
||||
|
||||
/* There is no alternative fenc, just report the error. */
|
||||
# ifdef USE_ICONV
|
||||
if (iconv_fd != (iconv_t)-1)
|
||||
conv_error = TRUE;
|
||||
if (*p_ccv != NUL && iconv_fd != (iconv_t)-1)
|
||||
/* iconv() failed, try 'charconvert' */
|
||||
did_iconv = TRUE;
|
||||
else
|
||||
# endif
|
||||
if (illegal_byte == 0) /* Keep the first linenr */
|
||||
{
|
||||
char_u *s;
|
||||
|
||||
/* Estimate the line number. */
|
||||
illegal_byte = curbuf->b_ml.ml_line_count - linecnt + 1;
|
||||
for (s = ptr; s < p; ++s)
|
||||
if (*s == '\n')
|
||||
++illegal_byte;
|
||||
}
|
||||
/* use next item from 'fileencodings' */
|
||||
advance_fenc = TRUE;
|
||||
file_rewind = TRUE;
|
||||
goto retry;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -2155,9 +2265,10 @@ failed:
|
||||
}
|
||||
#endif
|
||||
#ifdef FEAT_MBYTE
|
||||
if (conv_error)
|
||||
if (conv_error != 0)
|
||||
{
|
||||
STRCAT(IObuff, _("[CONVERSION ERROR]"));
|
||||
sprintf((char *)IObuff + STRLEN(IObuff),
|
||||
_("[CONVERSION ERROR in line %ld]"), (long)conv_error);
|
||||
c = TRUE;
|
||||
}
|
||||
else if (illegal_byte > 0)
|
||||
@@ -2211,7 +2322,7 @@ failed:
|
||||
/* with errors writing the file requires ":w!" */
|
||||
if (newfile && (error
|
||||
#ifdef FEAT_MBYTE
|
||||
|| conv_error
|
||||
|| conv_error != 0
|
||||
#endif
|
||||
))
|
||||
curbuf->b_p_ro = TRUE;
|
||||
@@ -2293,6 +2404,30 @@ failed:
|
||||
return OK;
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
|
||||
/*
|
||||
* From the current line count and characters read after that, estimate the
|
||||
* line number where we are now.
|
||||
* Used for error messages that include a line number.
|
||||
*/
|
||||
static linenr_T
|
||||
readfile_linenr(linecnt, p, endp)
|
||||
linenr_T linecnt; /* line count before reading more bytes */
|
||||
char_u *p; /* start of more bytes read */
|
||||
char_u *endp; /* end of more bytes read */
|
||||
{
|
||||
char_u *s;
|
||||
linenr_T lnum;
|
||||
|
||||
lnum = curbuf->b_ml.ml_line_count - linecnt + 1;
|
||||
for (s = p; s < endp; ++s)
|
||||
if (*s == '\n')
|
||||
++lnum;
|
||||
return lnum;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Fill "*eap" to force the 'fileencoding' and 'fileformat' to be equal to the
|
||||
* buffer "buf". Used for calling readfile().
|
||||
|
||||
1319
src/gui_mac.c
1319
src/gui_mac.c
File diff suppressed because it is too large
Load Diff
12
src/keymap.h
12
src/keymap.h
@@ -6,18 +6,18 @@
|
||||
* Do ":help credits" in Vim to see a list of people who contributed.
|
||||
*/
|
||||
|
||||
/*
|
||||
* For MSDOS some keys produce codes larger than 0xff. They are split into two
|
||||
* chars, the first one is K_NUL (same value used in term.h).
|
||||
*/
|
||||
#define K_NUL (0xce) /* for MSDOS: special key follows */
|
||||
|
||||
/*
|
||||
* Keycode definitions for special keys.
|
||||
*
|
||||
* Any special key code sequences are replaced by these codes.
|
||||
*/
|
||||
|
||||
/*
|
||||
* For MSDOS some keys produce codes larger than 0xff. They are split into two
|
||||
* chars, the first one is K_NUL (same value used in term.h).
|
||||
*/
|
||||
#define K_NUL (0xce) /* for MSDOS: special key follows */
|
||||
|
||||
/*
|
||||
* K_SPECIAL is the first byte of a special key code and is always followed by
|
||||
* two bytes.
|
||||
|
||||
112
src/memline.c
112
src/memline.c
@@ -3382,6 +3382,87 @@ ml_lineadd(buf, count)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_READLINK
|
||||
static int resolve_symlink __ARGS((char_u *fname, char_u *buf));
|
||||
|
||||
/*
|
||||
* Resolve a symlink in the last component of a file name.
|
||||
* Note that f_resolve() does it for every part of the path, we don't do that
|
||||
* here.
|
||||
* If it worked returns OK and the resolved link in "buf[MAXPATHL]".
|
||||
* Otherwise returns FAIL.
|
||||
*/
|
||||
static int
|
||||
resolve_symlink(fname, buf)
|
||||
char_u *fname;
|
||||
char_u *buf;
|
||||
{
|
||||
char_u tmp[MAXPATHL];
|
||||
int ret;
|
||||
int depth = 0;
|
||||
|
||||
if (fname == NULL)
|
||||
return FAIL;
|
||||
|
||||
/* Put the result so far in tmp[], starting with the original name. */
|
||||
vim_strncpy(tmp, fname, MAXPATHL - 1);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
/* Limit symlink depth to 100, catch recursive loops. */
|
||||
if (++depth == 100)
|
||||
{
|
||||
EMSG2(_("E773: Symlink loop for \"%s\""), fname);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
ret = readlink((char *)tmp, (char *)buf, MAXPATHL - 1);
|
||||
if (ret <= 0)
|
||||
{
|
||||
if (errno == EINVAL) /* found non-symlink, stop here */
|
||||
{
|
||||
/* When at the first level use the unmodifed name, skip the
|
||||
* call to vim_FullName(). */
|
||||
if (depth == 1)
|
||||
return FAIL;
|
||||
|
||||
/* Use the resolved name in tmp[]. */
|
||||
break;
|
||||
}
|
||||
|
||||
/* There must be some error reading links, use original name. */
|
||||
return FAIL;
|
||||
}
|
||||
buf[ret] = NUL;
|
||||
|
||||
/*
|
||||
* Check whether the symlink is relative or absolute.
|
||||
* If it's relative, build a new path based on the directory
|
||||
* portion of the filename (if any) and the path the symlink
|
||||
* points to.
|
||||
*/
|
||||
if (mch_isFullName(buf))
|
||||
STRCPY(tmp, buf);
|
||||
else
|
||||
{
|
||||
char_u *tail;
|
||||
|
||||
tail = gettail(tmp);
|
||||
if (STRLEN(tail) + STRLEN(buf) >= MAXPATHL)
|
||||
return FAIL;
|
||||
STRCPY(tail, buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Try to resolve the full name of the file so that the swapfile name will
|
||||
* be consistent even when opening a relative symlink from different
|
||||
* working directories.
|
||||
*/
|
||||
return vim_FullName(tmp, buf, MAXPATHL, TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Make swap file name out of the file name and a directory name.
|
||||
* Returns pointer to allocated memory or NULL.
|
||||
@@ -3395,6 +3476,10 @@ makeswapname(fname, ffname, buf, dir_name)
|
||||
char_u *dir_name;
|
||||
{
|
||||
char_u *r, *s;
|
||||
#ifdef HAVE_READLINK
|
||||
char_u fname_buf[MAXPATHL];
|
||||
char_u *fname_res;
|
||||
#endif
|
||||
|
||||
#if defined(UNIX) || defined(WIN3264) /* Need _very_ long file names */
|
||||
s = dir_name + STRLEN(dir_name);
|
||||
@@ -3410,6 +3495,15 @@ makeswapname(fname, ffname, buf, dir_name)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_READLINK
|
||||
/* Expand symlink in the file name, so that we put the swap file with the
|
||||
* actual file instead of with the symlink. */
|
||||
if (resolve_symlink(fname, fname_buf) == OK)
|
||||
fname_res = fname_buf;
|
||||
else
|
||||
fname_res = fname;
|
||||
#endif
|
||||
|
||||
r = buf_modname(
|
||||
#ifdef SHORT_FNAME
|
||||
TRUE,
|
||||
@@ -3420,7 +3514,11 @@ makeswapname(fname, ffname, buf, dir_name)
|
||||
/* Avoid problems if fname has special chars, eg <Wimp$Scrap> */
|
||||
ffname,
|
||||
#else
|
||||
# ifdef HAVE_READLINK
|
||||
fname_res,
|
||||
# else
|
||||
fname,
|
||||
# endif
|
||||
#endif
|
||||
(char_u *)
|
||||
#if defined(VMS) || defined(RISCOS)
|
||||
@@ -3848,7 +3946,17 @@ findswapname(buf, dirp, old_fname)
|
||||
if (fnamecmp(gettail(buf->b_ffname),
|
||||
gettail(b0.b0_fname)) != 0
|
||||
|| !same_directory(fname, buf->b_ffname))
|
||||
differ = TRUE;
|
||||
{
|
||||
#ifdef CHECK_INODE
|
||||
/* Symlinks may point to the same file even
|
||||
* when the name differs, need to check the
|
||||
* inode too. */
|
||||
expand_env(b0.b0_fname, NameBuff, MAXPATHL);
|
||||
if (fnamecmp_ino(buf->b_ffname, NameBuff,
|
||||
char_to_long(b0.b0_ino)))
|
||||
#endif
|
||||
differ = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3859,7 +3967,7 @@ findswapname(buf, dirp, old_fname)
|
||||
expand_env(b0.b0_fname, NameBuff, MAXPATHL);
|
||||
#ifdef CHECK_INODE
|
||||
if (fnamecmp_ino(buf->b_ffname, NameBuff,
|
||||
char_to_long(b0.b0_ino)))
|
||||
char_to_long(b0.b0_ino)))
|
||||
differ = TRUE;
|
||||
#else
|
||||
if (fnamecmp(NameBuff, buf->b_ffname) != 0)
|
||||
|
||||
23
src/misc1.c
23
src/misc1.c
@@ -4443,6 +4443,29 @@ vim_ispathlistsep(c)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Return TRUE if the directory of "fname" exists, FALSE otherwise.
|
||||
* Also returns TRUE if there is no directory name.
|
||||
* "fname" must be writable!.
|
||||
*/
|
||||
int
|
||||
dir_of_file_exists(fname)
|
||||
char_u *fname;
|
||||
{
|
||||
char_u *p;
|
||||
int c;
|
||||
int retval;
|
||||
|
||||
p = gettail_sep(fname);
|
||||
if (p == fname)
|
||||
return TRUE;
|
||||
c = *p;
|
||||
*p = NUL;
|
||||
retval = mch_isdir(fname);
|
||||
*p = c;
|
||||
return retval;
|
||||
}
|
||||
|
||||
#if (defined(CASE_INSENSITIVE_FILENAME) && defined(BACKSLASH_IN_FILENAME)) \
|
||||
|| defined(PROTO)
|
||||
/*
|
||||
|
||||
44
src/normal.c
44
src/normal.c
@@ -32,6 +32,7 @@ _RTLENTRYF
|
||||
nv_compare __ARGS((const void *s1, const void *s2));
|
||||
static int find_command __ARGS((int cmdchar));
|
||||
static void op_colon __ARGS((oparg_T *oap));
|
||||
static void op_function __ARGS((oparg_T *oap));
|
||||
#if defined(FEAT_MOUSE) && defined(FEAT_VISUAL)
|
||||
static void find_start_of_word __ARGS((pos_T *));
|
||||
static void find_end_of_word __ARGS((pos_T *));
|
||||
@@ -1696,6 +1697,7 @@ do_pending_operator(cap, old_col, gui_yank)
|
||||
}
|
||||
|
||||
redo_VIsual_busy = FALSE;
|
||||
|
||||
/*
|
||||
* Switch Visual off now, so screen updating does
|
||||
* not show inverted text when the screen is redrawn.
|
||||
@@ -1718,6 +1720,7 @@ do_pending_operator(cap, old_col, gui_yank)
|
||||
#endif
|
||||
if ((oap->op_type == OP_YANK
|
||||
|| oap->op_type == OP_COLON
|
||||
|| oap->op_type == OP_FUNCTION
|
||||
|| oap->op_type == OP_FILTER)
|
||||
&& oap->motion_force == NUL)
|
||||
redraw_curbuf_later(INVERTED);
|
||||
@@ -1940,6 +1943,10 @@ do_pending_operator(cap, old_col, gui_yank)
|
||||
op_format(oap, TRUE); /* use internal function */
|
||||
break;
|
||||
|
||||
case OP_FUNCTION:
|
||||
op_function(oap); /* call 'operatorfunc' */
|
||||
break;
|
||||
|
||||
case OP_INSERT:
|
||||
case OP_APPEND:
|
||||
#ifdef FEAT_VISUAL
|
||||
@@ -2100,6 +2107,41 @@ op_colon(oap)
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle the "gy" operator: call 'operatorfunc'.
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
void
|
||||
op_function(oap)
|
||||
oparg_T *oap;
|
||||
{
|
||||
#ifdef FEAT_EVAL
|
||||
char_u *(argv[1]);
|
||||
|
||||
if (*p_opfunc == NUL)
|
||||
EMSG(_("E774: 'operatorfunc' is empty"));
|
||||
else
|
||||
{
|
||||
/* Set '[ and '] marks to text to be operated on. */
|
||||
curbuf->b_op_start = oap->start;
|
||||
curbuf->b_op_end = oap->end;
|
||||
if (oap->motion_type != MLINE && !oap->inclusive)
|
||||
/* Exclude the end position. */
|
||||
decl(&curbuf->b_op_end);
|
||||
|
||||
if (oap->block_mode)
|
||||
argv[0] = (char_u *)"block";
|
||||
else if (oap->motion_type == MLINE)
|
||||
argv[0] = (char_u *)"line";
|
||||
else
|
||||
argv[0] = (char_u *)"char";
|
||||
(void)call_func_retnr(p_opfunc, 1, argv, FALSE);
|
||||
}
|
||||
#else
|
||||
EMSG(_("E775: Eval feature not available"));
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(FEAT_MOUSE) || defined(PROTO)
|
||||
/*
|
||||
* Do the appropriate action for the current mouse click in the current mode.
|
||||
@@ -7660,6 +7702,7 @@ nv_g_cmd(cap)
|
||||
* "gu" Change text to lower case.
|
||||
* "gU" Change text to upper case.
|
||||
* "g?" rot13 encoding
|
||||
* "gy" call 'operatorfunc'
|
||||
*/
|
||||
case 'q':
|
||||
case 'w':
|
||||
@@ -7669,6 +7712,7 @@ nv_g_cmd(cap)
|
||||
case 'u':
|
||||
case 'U':
|
||||
case '?':
|
||||
case 'y':
|
||||
nv_operator(cap);
|
||||
break;
|
||||
|
||||
|
||||
11
src/ops.c
11
src/ops.c
@@ -159,6 +159,7 @@ static char opchars[][3] =
|
||||
{'z', 'd', TRUE}, /* OP_FOLDDEL */
|
||||
{'z', 'D', TRUE}, /* OP_FOLDDELREC */
|
||||
{'g', 'w', TRUE}, /* OP_FORMAT2 */
|
||||
{'g', 'y', FALSE}, /* OP_FUNCTION */
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -2737,10 +2738,10 @@ op_yank(oap, deleting, mess)
|
||||
else
|
||||
free_yank_all(); /* free previously yanked lines */
|
||||
|
||||
/*
|
||||
* If the cursor was in column 1 before and after the movement, and the
|
||||
* operator is not inclusive, the yank is always linewise.
|
||||
*/
|
||||
/*
|
||||
* If the cursor was in column 1 before and after the movement, and the
|
||||
* operator is not inclusive, the yank is always linewise.
|
||||
*/
|
||||
if ( oap->motion_type == MCHAR
|
||||
&& oap->start.col == 0
|
||||
&& !oap->inclusive
|
||||
@@ -4786,7 +4787,7 @@ block_prep(oap, bdp, lnum, is_del)
|
||||
/* if (!is_del || oap->op_type == OP_APPEND) */
|
||||
if (oap->op_type == OP_APPEND || virtual_op)
|
||||
bdp->endspaces = oap->end_vcol - bdp->end_vcol
|
||||
+ oap->inclusive;
|
||||
+ oap->inclusive;
|
||||
else
|
||||
bdp->endspaces = 0; /* replace doesn't add characters */
|
||||
}
|
||||
|
||||
@@ -1624,6 +1624,9 @@ static struct vimoption
|
||||
{"open", NULL, P_BOOL|P_VI_DEF,
|
||||
(char_u *)NULL, PV_NONE,
|
||||
{(char_u *)FALSE, (char_u *)0L}},
|
||||
{"operatorfunc", "opfunc", P_STRING|P_VI_DEF|P_SECURE,
|
||||
(char_u *)&p_opfunc, PV_NONE,
|
||||
{(char_u *)"", (char_u *)0L} },
|
||||
{"optimize", "opt", P_BOOL|P_VI_DEF,
|
||||
(char_u *)NULL, PV_NONE,
|
||||
{(char_u *)FALSE, (char_u *)0L}},
|
||||
|
||||
@@ -613,6 +613,7 @@ EXTERN int p_more; /* 'more' */
|
||||
#ifdef FEAT_MZSCHEME
|
||||
EXTERN long p_mzq; /* 'mzquantum */
|
||||
#endif
|
||||
EXTERN char_u *p_opfunc; /* 'operatorfunc' */
|
||||
EXTERN char_u *p_para; /* 'paragraphs' */
|
||||
EXTERN int p_paste; /* 'paste' */
|
||||
EXTERN char_u *p_pt; /* 'pastetoggle' */
|
||||
|
||||
@@ -3970,14 +3970,25 @@ mch_call_shell(cmd, options)
|
||||
{
|
||||
/*
|
||||
* Check if keys have been typed, write them to the child
|
||||
* if there are any. Don't do this if we are expanding
|
||||
* wild cards (would eat typeahead). Don't get extra
|
||||
* characters when we already have one.
|
||||
* if there are any.
|
||||
* Don't do this if we are expanding wild cards (would eat
|
||||
* typeahead).
|
||||
* Don't do this when filtering and terminal is in cooked
|
||||
* mode, the shell command will handle the I/O. Avoids
|
||||
* that a typed password is echoed for ssh or gpg command.
|
||||
* Don't get extra characters when we already have one.
|
||||
* Don't read characters unless we didn't get output for a
|
||||
* while, avoids that ":r !ls" eats typeahead.
|
||||
*/
|
||||
len = 0;
|
||||
if (!(options & SHELL_EXPAND)
|
||||
&& ((options &
|
||||
(SHELL_READ|SHELL_WRITE|SHELL_COOKED))
|
||||
!= (SHELL_READ|SHELL_WRITE|SHELL_COOKED)
|
||||
#ifdef FEAT_GUI
|
||||
|| gui.in_use
|
||||
#endif
|
||||
)
|
||||
&& (ta_len > 0
|
||||
|| (noread_cnt > 4
|
||||
&& (len = ui_inchar(ta_buf,
|
||||
|
||||
@@ -1,93 +1,94 @@
|
||||
/* misc1.c */
|
||||
int get_indent __ARGS((void));
|
||||
int get_indent_lnum __ARGS((linenr_T lnum));
|
||||
int get_indent_buf __ARGS((buf_T *buf, linenr_T lnum));
|
||||
int get_indent_str __ARGS((char_u *ptr, int ts));
|
||||
int set_indent __ARGS((int size, int flags));
|
||||
int get_number_indent __ARGS((linenr_T lnum));
|
||||
int open_line __ARGS((int dir, int flags, int old_indent));
|
||||
int get_leader_len __ARGS((char_u *line, char_u **flags, int backward));
|
||||
int plines __ARGS((linenr_T lnum));
|
||||
int plines_win __ARGS((win_T *wp, linenr_T lnum, int winheight));
|
||||
int plines_nofill __ARGS((linenr_T lnum));
|
||||
int plines_win_nofill __ARGS((win_T *wp, linenr_T lnum, int winheight));
|
||||
int plines_win_nofold __ARGS((win_T *wp, linenr_T lnum));
|
||||
int plines_win_col __ARGS((win_T *wp, linenr_T lnum, long column));
|
||||
int plines_m_win __ARGS((win_T *wp, linenr_T first, linenr_T last));
|
||||
void ins_bytes __ARGS((char_u *p));
|
||||
void ins_bytes_len __ARGS((char_u *p, int len));
|
||||
void ins_char __ARGS((int c));
|
||||
void ins_char_bytes __ARGS((char_u *buf, int charlen));
|
||||
void ins_str __ARGS((char_u *s));
|
||||
int del_char __ARGS((int fixpos));
|
||||
int del_chars __ARGS((long count, int fixpos));
|
||||
int del_bytes __ARGS((long count, int fixpos));
|
||||
int truncate_line __ARGS((int fixpos));
|
||||
void del_lines __ARGS((long nlines, int undo));
|
||||
int gchar_pos __ARGS((pos_T *pos));
|
||||
int gchar_cursor __ARGS((void));
|
||||
void pchar_cursor __ARGS((int c));
|
||||
int inindent __ARGS((int extra));
|
||||
char_u *skip_to_option_part __ARGS((char_u *p));
|
||||
void changed __ARGS((void));
|
||||
void changed_bytes __ARGS((linenr_T lnum, colnr_T col));
|
||||
void appended_lines __ARGS((linenr_T lnum, long count));
|
||||
void appended_lines_mark __ARGS((linenr_T lnum, long count));
|
||||
void deleted_lines __ARGS((linenr_T lnum, long count));
|
||||
void deleted_lines_mark __ARGS((linenr_T lnum, long count));
|
||||
void changed_lines __ARGS((linenr_T lnum, colnr_T col, linenr_T lnume, long xtra));
|
||||
void unchanged __ARGS((buf_T *buf, int ff));
|
||||
void check_status __ARGS((buf_T *buf));
|
||||
void change_warning __ARGS((int col));
|
||||
int ask_yesno __ARGS((char_u *str, int direct));
|
||||
int get_keystroke __ARGS((void));
|
||||
int get_number __ARGS((int colon, int *mouse_used));
|
||||
int prompt_for_number __ARGS((int *mouse_used));
|
||||
void msgmore __ARGS((long n));
|
||||
void beep_flush __ARGS((void));
|
||||
void vim_beep __ARGS((void));
|
||||
void init_homedir __ARGS((void));
|
||||
void free_homedir __ARGS((void));
|
||||
void expand_env __ARGS((char_u *src, char_u *dst, int dstlen));
|
||||
void expand_env_esc __ARGS((char_u *srcp, char_u *dst, int dstlen, int esc, char_u *startstr));
|
||||
char_u *vim_getenv __ARGS((char_u *name, int *mustfree));
|
||||
char_u *expand_env_save __ARGS((char_u *src));
|
||||
void vim_setenv __ARGS((char_u *name, char_u *val));
|
||||
char_u *get_env_name __ARGS((expand_T *xp, int idx));
|
||||
void home_replace __ARGS((buf_T *buf, char_u *src, char_u *dst, int dstlen, int one));
|
||||
char_u *home_replace_save __ARGS((buf_T *buf, char_u *src));
|
||||
int fullpathcmp __ARGS((char_u *s1, char_u *s2, int checkname));
|
||||
char_u *gettail __ARGS((char_u *fname));
|
||||
char_u *gettail_sep __ARGS((char_u *fname));
|
||||
char_u *getnextcomp __ARGS((char_u *fname));
|
||||
char_u *get_past_head __ARGS((char_u *path));
|
||||
int vim_ispathsep __ARGS((int c));
|
||||
int vim_ispathlistsep __ARGS((int c));
|
||||
int vim_fnamecmp __ARGS((char_u *x, char_u *y));
|
||||
int vim_fnamencmp __ARGS((char_u *x, char_u *y, size_t len));
|
||||
char_u *concat_fnames __ARGS((char_u *fname1, char_u *fname2, int sep));
|
||||
char_u *concat_str __ARGS((char_u *str1, char_u *str2));
|
||||
void add_pathsep __ARGS((char_u *p));
|
||||
char_u *FullName_save __ARGS((char_u *fname, int force));
|
||||
pos_T *find_start_comment __ARGS((int ind_maxcomment));
|
||||
void do_c_expr_indent __ARGS((void));
|
||||
int cin_islabel __ARGS((int ind_maxcomment));
|
||||
int cin_iscase __ARGS((char_u *s));
|
||||
int cin_isscopedecl __ARGS((char_u *s));
|
||||
int get_c_indent __ARGS((void));
|
||||
int get_expr_indent __ARGS((void));
|
||||
int get_lisp_indent __ARGS((void));
|
||||
void prepare_to_exit __ARGS((void));
|
||||
void preserve_exit __ARGS((void));
|
||||
int vim_fexists __ARGS((char_u *fname));
|
||||
void line_breakcheck __ARGS((void));
|
||||
void fast_breakcheck __ARGS((void));
|
||||
int expand_wildcards __ARGS((int num_pat, char_u **pat, int *num_file, char_u ***file, int flags));
|
||||
int match_suffix __ARGS((char_u *fname));
|
||||
int unix_expandpath __ARGS((garray_T *gap, char_u *path, int wildoff, int flags, int didstar));
|
||||
int gen_expand_wildcards __ARGS((int num_pat, char_u **pat, int *num_file, char_u ***file, int flags));
|
||||
void addfile __ARGS((garray_T *gap, char_u *f, int flags));
|
||||
char_u *get_cmd_output __ARGS((char_u *cmd, char_u *infile, int flags));
|
||||
void FreeWild __ARGS((int count, char_u **files));
|
||||
int goto_im __ARGS((void));
|
||||
extern int get_indent __ARGS((void));
|
||||
extern int get_indent_lnum __ARGS((linenr_T lnum));
|
||||
extern int get_indent_buf __ARGS((buf_T *buf, linenr_T lnum));
|
||||
extern int get_indent_str __ARGS((char_u *ptr, int ts));
|
||||
extern int set_indent __ARGS((int size, int flags));
|
||||
extern int get_number_indent __ARGS((linenr_T lnum));
|
||||
extern int open_line __ARGS((int dir, int flags, int old_indent));
|
||||
extern int get_leader_len __ARGS((char_u *line, char_u **flags, int backward));
|
||||
extern int plines __ARGS((linenr_T lnum));
|
||||
extern int plines_win __ARGS((win_T *wp, linenr_T lnum, int winheight));
|
||||
extern int plines_nofill __ARGS((linenr_T lnum));
|
||||
extern int plines_win_nofill __ARGS((win_T *wp, linenr_T lnum, int winheight));
|
||||
extern int plines_win_nofold __ARGS((win_T *wp, linenr_T lnum));
|
||||
extern int plines_win_col __ARGS((win_T *wp, linenr_T lnum, long column));
|
||||
extern int plines_m_win __ARGS((win_T *wp, linenr_T first, linenr_T last));
|
||||
extern void ins_bytes __ARGS((char_u *p));
|
||||
extern void ins_bytes_len __ARGS((char_u *p, int len));
|
||||
extern void ins_char __ARGS((int c));
|
||||
extern void ins_char_bytes __ARGS((char_u *buf, int charlen));
|
||||
extern void ins_str __ARGS((char_u *s));
|
||||
extern int del_char __ARGS((int fixpos));
|
||||
extern int del_chars __ARGS((long count, int fixpos));
|
||||
extern int del_bytes __ARGS((long count, int fixpos));
|
||||
extern int truncate_line __ARGS((int fixpos));
|
||||
extern void del_lines __ARGS((long nlines, int undo));
|
||||
extern int gchar_pos __ARGS((pos_T *pos));
|
||||
extern int gchar_cursor __ARGS((void));
|
||||
extern void pchar_cursor __ARGS((int c));
|
||||
extern int inindent __ARGS((int extra));
|
||||
extern char_u *skip_to_option_part __ARGS((char_u *p));
|
||||
extern void changed __ARGS((void));
|
||||
extern void changed_bytes __ARGS((linenr_T lnum, colnr_T col));
|
||||
extern void appended_lines __ARGS((linenr_T lnum, long count));
|
||||
extern void appended_lines_mark __ARGS((linenr_T lnum, long count));
|
||||
extern void deleted_lines __ARGS((linenr_T lnum, long count));
|
||||
extern void deleted_lines_mark __ARGS((linenr_T lnum, long count));
|
||||
extern void changed_lines __ARGS((linenr_T lnum, colnr_T col, linenr_T lnume, long xtra));
|
||||
extern void unchanged __ARGS((buf_T *buf, int ff));
|
||||
extern void check_status __ARGS((buf_T *buf));
|
||||
extern void change_warning __ARGS((int col));
|
||||
extern int ask_yesno __ARGS((char_u *str, int direct));
|
||||
extern int get_keystroke __ARGS((void));
|
||||
extern int get_number __ARGS((int colon, int *mouse_used));
|
||||
extern int prompt_for_number __ARGS((int *mouse_used));
|
||||
extern void msgmore __ARGS((long n));
|
||||
extern void beep_flush __ARGS((void));
|
||||
extern void vim_beep __ARGS((void));
|
||||
extern void init_homedir __ARGS((void));
|
||||
extern void free_homedir __ARGS((void));
|
||||
extern void expand_env __ARGS((char_u *src, char_u *dst, int dstlen));
|
||||
extern void expand_env_esc __ARGS((char_u *srcp, char_u *dst, int dstlen, int esc, char_u *startstr));
|
||||
extern char_u *vim_getenv __ARGS((char_u *name, int *mustfree));
|
||||
extern char_u *expand_env_save __ARGS((char_u *src));
|
||||
extern void vim_setenv __ARGS((char_u *name, char_u *val));
|
||||
extern char_u *get_env_name __ARGS((expand_T *xp, int idx));
|
||||
extern void home_replace __ARGS((buf_T *buf, char_u *src, char_u *dst, int dstlen, int one));
|
||||
extern char_u *home_replace_save __ARGS((buf_T *buf, char_u *src));
|
||||
extern int fullpathcmp __ARGS((char_u *s1, char_u *s2, int checkname));
|
||||
extern char_u *gettail __ARGS((char_u *fname));
|
||||
extern char_u *gettail_sep __ARGS((char_u *fname));
|
||||
extern char_u *getnextcomp __ARGS((char_u *fname));
|
||||
extern char_u *get_past_head __ARGS((char_u *path));
|
||||
extern int vim_ispathsep __ARGS((int c));
|
||||
extern int vim_ispathlistsep __ARGS((int c));
|
||||
extern int dir_of_file_exists __ARGS((char_u *fname));
|
||||
extern int vim_fnamecmp __ARGS((char_u *x, char_u *y));
|
||||
extern int vim_fnamencmp __ARGS((char_u *x, char_u *y, size_t len));
|
||||
extern char_u *concat_fnames __ARGS((char_u *fname1, char_u *fname2, int sep));
|
||||
extern char_u *concat_str __ARGS((char_u *str1, char_u *str2));
|
||||
extern void add_pathsep __ARGS((char_u *p));
|
||||
extern char_u *FullName_save __ARGS((char_u *fname, int force));
|
||||
extern pos_T *find_start_comment __ARGS((int ind_maxcomment));
|
||||
extern void do_c_expr_indent __ARGS((void));
|
||||
extern int cin_islabel __ARGS((int ind_maxcomment));
|
||||
extern int cin_iscase __ARGS((char_u *s));
|
||||
extern int cin_isscopedecl __ARGS((char_u *s));
|
||||
extern int get_c_indent __ARGS((void));
|
||||
extern int get_expr_indent __ARGS((void));
|
||||
extern int get_lisp_indent __ARGS((void));
|
||||
extern void prepare_to_exit __ARGS((void));
|
||||
extern void preserve_exit __ARGS((void));
|
||||
extern int vim_fexists __ARGS((char_u *fname));
|
||||
extern void line_breakcheck __ARGS((void));
|
||||
extern void fast_breakcheck __ARGS((void));
|
||||
extern int expand_wildcards __ARGS((int num_pat, char_u **pat, int *num_file, char_u ***file, int flags));
|
||||
extern int match_suffix __ARGS((char_u *fname));
|
||||
extern int unix_expandpath __ARGS((garray_T *gap, char_u *path, int wildoff, int flags, int didstar));
|
||||
extern int gen_expand_wildcards __ARGS((int num_pat, char_u **pat, int *num_file, char_u ***file, int flags));
|
||||
extern void addfile __ARGS((garray_T *gap, char_u *f, int flags));
|
||||
extern char_u *get_cmd_output __ARGS((char_u *cmd, char_u *infile, int flags));
|
||||
extern void FreeWild __ARGS((int count, char_u **files));
|
||||
extern int goto_im __ARGS((void));
|
||||
/* vim: set ft=c : */
|
||||
|
||||
@@ -7703,7 +7703,6 @@ spell_add_word(word, len, bad, index)
|
||||
FILE *fd;
|
||||
buf_T *buf = NULL;
|
||||
int new_spf = FALSE;
|
||||
struct stat st;
|
||||
char_u *fname;
|
||||
char_u fnamebuf[MAXPATHL];
|
||||
char_u line[MAXWLEN * 2];
|
||||
@@ -7797,9 +7796,7 @@ spell_add_word(word, len, bad, index)
|
||||
/* We just initialized the 'spellfile' option and can't open the file.
|
||||
* We may need to create the "spell" directory first. We already
|
||||
* checked the runtime directory is writable in init_spellfile(). */
|
||||
STRCPY(NameBuff, fname);
|
||||
*gettail_sep(NameBuff) = NUL;
|
||||
if (mch_stat((char *)NameBuff, &st) < 0)
|
||||
if (!dir_of_file_exists(fname))
|
||||
{
|
||||
/* The directory doesn't exist. Try creating it and opening the
|
||||
* file again. */
|
||||
|
||||
@@ -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 (2005 Dec 11)"
|
||||
#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2005 Dec 11, compiled "
|
||||
#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2005 Dec 13)"
|
||||
#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2005 Dec 13, compiled "
|
||||
|
||||
@@ -1201,6 +1201,7 @@ typedef enum
|
||||
#define OP_FOLDDEL 24 /* "zd" delete folds */
|
||||
#define OP_FOLDDELREC 25 /* "zD" delete folds recursively */
|
||||
#define OP_FORMAT2 26 /* "gw" format operator, keeps cursor pos */
|
||||
#define OP_FUNCTION 27 /* "gy" call 'operatorfunc' */
|
||||
|
||||
/*
|
||||
* Motion types, used for operators and for yank/delete registers.
|
||||
@@ -1922,4 +1923,9 @@ typedef int proftime_T; /* dummy for function prototypes */
|
||||
#define VGR_GLOBAL 1
|
||||
#define VGR_NOJUMP 2
|
||||
|
||||
/* behavior for bad character, "++bad=" argument */
|
||||
#define BAD_REPLACE '?' /* replace it with '?' (default) */
|
||||
#define BAD_KEEP -1 /* leave it */
|
||||
#define BAD_DROP -2 /* erase it */
|
||||
|
||||
#endif /* VIM__H */
|
||||
|
||||
@@ -4765,7 +4765,7 @@ vim_isAbsName(name)
|
||||
}
|
||||
|
||||
/*
|
||||
* Get absolute file name into buffer 'buf' of length 'len' bytes.
|
||||
* Get absolute file name into buffer "buf[len]".
|
||||
*
|
||||
* return FAIL for failure, OK otherwise
|
||||
*/
|
||||
@@ -4773,7 +4773,7 @@ vim_isAbsName(name)
|
||||
vim_FullName(fname, buf, len, force)
|
||||
char_u *fname, *buf;
|
||||
int len;
|
||||
int force;
|
||||
int force; /* force expansion even when already absolute */
|
||||
{
|
||||
int retval = OK;
|
||||
int url;
|
||||
|
||||
Reference in New Issue
Block a user