mirror of
https://github.com/neovim/neovim.git
synced 2025-09-08 12:28:18 +00:00
Merge pull request #3470 from ZyX-I/pr-3198
XDG base directory specification support
This commit is contained in:
@@ -104,9 +104,9 @@ o Setting the Arabic fonts
|
|||||||
font name akin to that used in Linux/Unix systems.
|
font name akin to that used in Linux/Unix systems.
|
||||||
(e.g. -misc-fixed-medium-r-normal--20-200-75-75-c-100-iso10646-1)
|
(e.g. -misc-fixed-medium-r-normal--20-200-75-75-c-100-iso10646-1)
|
||||||
|
|
||||||
You can append the 'guifont' set command to your .vimrc file
|
You can append the 'guifont' set command to your vimrc file
|
||||||
in order to get the same above noted results. In other words,
|
in order to get the same above noted results. In other words,
|
||||||
you can include ':set guifont=your_ARABIC_FONT' to your .vimrc
|
you can include ':set guifont=your_ARABIC_FONT' to your vimrc
|
||||||
file.
|
file.
|
||||||
|
|
||||||
+ Under the X Window environment, you can also start VIM with
|
+ Under the X Window environment, you can also start VIM with
|
||||||
@@ -118,9 +118,9 @@ o Setting the appropriate character Encoding
|
|||||||
>
|
>
|
||||||
:set encoding=utf-8
|
:set encoding=utf-8
|
||||||
<
|
<
|
||||||
to your .vimrc file (entering the command manually into you VIM
|
to your vimrc file (entering the command manually into you VIM
|
||||||
window is highly discouraged). In short, include ':set
|
window is highly discouraged). In short, include ':set
|
||||||
encoding=utf-8' to your .vimrc file.
|
encoding=utf-8' to your vimrc file.
|
||||||
|
|
||||||
Attempts to use Arabic without UTF-8 will result the following
|
Attempts to use Arabic without UTF-8 will result the following
|
||||||
warning message,
|
warning message,
|
||||||
@@ -149,7 +149,7 @@ o Enable Arabic settings [short-cut]
|
|||||||
4. enable rightleftcmd mode (affecting the command-line)
|
4. enable rightleftcmd mode (affecting the command-line)
|
||||||
5. enable arabicshape mode (do visual character alterations)
|
5. enable arabicshape mode (do visual character alterations)
|
||||||
|
|
||||||
You may also append the command to your .vimrc file and simply
|
You may also append the command to your vimrc file and simply
|
||||||
include ':set arabic' to it.
|
include ':set arabic' to it.
|
||||||
|
|
||||||
You are also capable of disabling Arabic support via
|
You are also capable of disabling Arabic support via
|
||||||
@@ -184,8 +184,8 @@ o Enable Arabic settings [short-cut]
|
|||||||
:set keymap=arabic
|
:set keymap=arabic
|
||||||
<
|
<
|
||||||
in your VIM window. You can also append the 'keymap' set command to
|
in your VIM window. You can also append the 'keymap' set command to
|
||||||
your .vimrc file. In other words, you can include ':set keymap=arabic'
|
your vimrc file. In other words, you can include ':set keymap=arabic'
|
||||||
to your .vimrc file.
|
to your vimrc file.
|
||||||
|
|
||||||
To turn toggle (or switch) your keymapping between Arabic and the
|
To turn toggle (or switch) your keymapping between Arabic and the
|
||||||
default mapping (English), it is advised that users use the 'CTRL-^'
|
default mapping (English), it is advised that users use the 'CTRL-^'
|
||||||
@@ -206,8 +206,8 @@ o Enable Arabic settings [short-cut]
|
|||||||
:set delcombine
|
:set delcombine
|
||||||
<
|
<
|
||||||
in our VIM window. You can also append the 'delcombine' set command
|
in our VIM window. You can also append the 'delcombine' set command
|
||||||
to your .vimrc file. In other words, you can include ':set delcombine'
|
to your vimrc file. In other words, you can include ':set delcombine'
|
||||||
to your .vimrc file.
|
to your vimrc file.
|
||||||
|
|
||||||
+ Arabic right-to-left Mode
|
+ Arabic right-to-left Mode
|
||||||
|
|
||||||
@@ -221,8 +221,8 @@ o Enable Arabic settings [short-cut]
|
|||||||
- While in Left-to-right mode, enter ':set rl' in the command line
|
- While in Left-to-right mode, enter ':set rl' in the command line
|
||||||
('rl' is the abbreviation for rightleft).
|
('rl' is the abbreviation for rightleft).
|
||||||
|
|
||||||
- Put the ':set rl' line in your '.vimrc' file to start Vim in
|
- Put the ':set rl' line in your vimrc file to start Vim in
|
||||||
right-to-left mode permanently.
|
right-to-left mode permanently.
|
||||||
|
|
||||||
+ Arabic right-to-left command-line Mode
|
+ Arabic right-to-left command-line Mode
|
||||||
|
|
||||||
@@ -248,8 +248,8 @@ o Enable Arabic settings [short-cut]
|
|||||||
:set arabicshape
|
:set arabicshape
|
||||||
<
|
<
|
||||||
in our VIM window. You can also append the 'arabicshape' set
|
in our VIM window. You can also append the 'arabicshape' set
|
||||||
command to your .vimrc file. In other words, you can include
|
command to your vimrc file. In other words, you can include
|
||||||
':set arabicshape' to your .vimrc file.
|
':set arabicshape' to your vimrc file.
|
||||||
|
|
||||||
|
|
||||||
Keymap/Keyboard *arabickeymap*
|
Keymap/Keyboard *arabickeymap*
|
||||||
|
@@ -28,7 +28,7 @@ a file, when entering or leaving a buffer or window, and when exiting Vim.
|
|||||||
For example, you can create an autocommand to set the 'cindent' option for
|
For example, you can create an autocommand to set the 'cindent' option for
|
||||||
files matching *.c. You can also use autocommands to implement advanced
|
files matching *.c. You can also use autocommands to implement advanced
|
||||||
features, such as editing compressed files (see |gzip-example|). The usual
|
features, such as editing compressed files (see |gzip-example|). The usual
|
||||||
place to put autocommands is in your .vimrc or .exrc file.
|
place to put autocommands is in your vimrc file.
|
||||||
|
|
||||||
*E203* *E204* *E143* *E855*
|
*E203* *E204* *E143* *E855*
|
||||||
WARNING: Using autocommands is very powerful, and may lead to unexpected side
|
WARNING: Using autocommands is very powerful, and may lead to unexpected side
|
||||||
@@ -73,8 +73,8 @@ exception is that "<sfile>" is expanded when the autocmd is defined. Example:
|
|||||||
|
|
||||||
Here Vim expands <sfile> to the name of the file containing this line.
|
Here Vim expands <sfile> to the name of the file containing this line.
|
||||||
|
|
||||||
When your .vimrc file is sourced twice, the autocommands will appear twice.
|
When your vimrc file is sourced twice, the autocommands will appear twice.
|
||||||
To avoid this, put this command in your .vimrc file, before defining
|
To avoid this, put this command in your vimrc file, before defining
|
||||||
autocommands: >
|
autocommands: >
|
||||||
|
|
||||||
:autocmd! " Remove ALL autocommands for the current group.
|
:autocmd! " Remove ALL autocommands for the current group.
|
||||||
@@ -695,7 +695,7 @@ FuncUndefined When a user function is used but it isn't
|
|||||||
GUIEnter After starting the GUI successfully, and after
|
GUIEnter After starting the GUI successfully, and after
|
||||||
opening the window. It is triggered before
|
opening the window. It is triggered before
|
||||||
VimEnter when using gvim. Can be used to
|
VimEnter when using gvim. Can be used to
|
||||||
position the window from a .gvimrc file: >
|
position the window from a gvimrc file: >
|
||||||
:autocmd GUIEnter * winpos 100 50
|
:autocmd GUIEnter * winpos 100 50
|
||||||
< *GUIFailed*
|
< *GUIFailed*
|
||||||
GUIFailed After starting the GUI failed. Vim may
|
GUIFailed After starting the GUI failed. Vim may
|
||||||
@@ -907,7 +907,7 @@ UserGettingBored When the user presses the same key 42 times.
|
|||||||
Just kidding! :-)
|
Just kidding! :-)
|
||||||
*VimEnter*
|
*VimEnter*
|
||||||
VimEnter After doing all the startup stuff, including
|
VimEnter After doing all the startup stuff, including
|
||||||
loading .vimrc files, executing the "-c cmd"
|
loading vimrc files, executing the "-c cmd"
|
||||||
arguments, creating all windows and loading
|
arguments, creating all windows and loading
|
||||||
the buffers in them.
|
the buffers in them.
|
||||||
*VimLeave*
|
*VimLeave*
|
||||||
@@ -994,7 +994,7 @@ expect.
|
|||||||
Environment variables can be used in a pattern: >
|
Environment variables can be used in a pattern: >
|
||||||
:autocmd BufRead $VIMRUNTIME/doc/*.txt set expandtab
|
:autocmd BufRead $VIMRUNTIME/doc/*.txt set expandtab
|
||||||
And ~ can be used for the home directory (if $HOME is defined): >
|
And ~ can be used for the home directory (if $HOME is defined): >
|
||||||
:autocmd BufWritePost ~/.vimrc so ~/.vimrc
|
:autocmd BufWritePost ~/.config/nvim/init.vim so <afile>
|
||||||
:autocmd BufRead ~archive/* set readonly
|
:autocmd BufRead ~archive/* set readonly
|
||||||
The environment variable is expanded when the autocommand is defined, not when
|
The environment variable is expanded when the autocommand is defined, not when
|
||||||
the autocommand is executed. This is different from the command!
|
the autocommand is executed. This is different from the command!
|
||||||
@@ -1135,7 +1135,7 @@ Example: >
|
|||||||
:augroup END
|
:augroup END
|
||||||
|
|
||||||
This prevents having the autocommands defined twice (e.g., after sourcing the
|
This prevents having the autocommands defined twice (e.g., after sourcing the
|
||||||
.vimrc file again).
|
vimrc file again).
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
9. Executing autocommands *autocmd-execute*
|
9. Executing autocommands *autocmd-execute*
|
||||||
@@ -1157,7 +1157,7 @@ option will not cause any commands to be executed.
|
|||||||
It's possible to use this inside an autocommand too,
|
It's possible to use this inside an autocommand too,
|
||||||
so you can base the autocommands for one extension on
|
so you can base the autocommands for one extension on
|
||||||
another extension. Example: >
|
another extension. Example: >
|
||||||
:au BufEnter *.cpp so ~/.vimrc_cpp
|
:au BufEnter *.cpp so ~/.config/nvim/init_cpp.vim
|
||||||
:au BufEnter *.cpp doau BufEnter x.c
|
:au BufEnter *.cpp doau BufEnter x.c
|
||||||
< Be careful to avoid endless loops. See
|
< Be careful to avoid endless loops. See
|
||||||
|autocmd-nested|.
|
|autocmd-nested|.
|
||||||
|
@@ -109,7 +109,7 @@ CTRL-W Delete the |word| before the cursor. This depends on the
|
|||||||
CTRL-U Remove all characters between the cursor position and
|
CTRL-U Remove all characters between the cursor position and
|
||||||
the beginning of the line. Previous versions of vim
|
the beginning of the line. Previous versions of vim
|
||||||
deleted all characters on the line. If that is the
|
deleted all characters on the line. If that is the
|
||||||
preferred behavior, add the following to your .vimrc: >
|
preferred behavior, add the following to your vimrc: >
|
||||||
:cnoremap <C-U> <C-E><C-U>
|
:cnoremap <C-U> <C-E><C-U>
|
||||||
<
|
<
|
||||||
*c_<Insert>* *c_Insert*
|
*c_<Insert>* *c_Insert*
|
||||||
@@ -456,7 +456,7 @@ that take a file name.
|
|||||||
If you would like using <S-Tab> for CTRL-P in an xterm, put this command in
|
If you would like using <S-Tab> for CTRL-P in an xterm, put this command in
|
||||||
your .cshrc: >
|
your .cshrc: >
|
||||||
xmodmap -e "keysym Tab = Tab Find"
|
xmodmap -e "keysym Tab = Tab Find"
|
||||||
And this in your .vimrc: >
|
And this in your vimrc: >
|
||||||
:cmap <Esc>[1~ <C-P>
|
:cmap <Esc>[1~ <C-P>
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
@@ -823,8 +823,8 @@ These modifiers can be given, in this order:
|
|||||||
precede any :r or :e.
|
precede any :r or :e.
|
||||||
:r Root of the file name (the last extension removed). When
|
:r Root of the file name (the last extension removed). When
|
||||||
there is only an extension (file name that starts with '.',
|
there is only an extension (file name that starts with '.',
|
||||||
e.g., ".vimrc"), it is not removed. Can be repeated to remove
|
e.g., ".nvimrc"), it is not removed. Can be repeated to
|
||||||
several extensions (last one first).
|
remove several extensions (last one first).
|
||||||
:e Extension of the file name. Only makes sense when used alone.
|
:e Extension of the file name. Only makes sense when used alone.
|
||||||
When there is no extension the result is empty.
|
When there is no extension the result is empty.
|
||||||
When there is only an extension (file name that starts with
|
When there is only an extension (file name that starts with
|
||||||
|
@@ -52,7 +52,7 @@ Use this command to start Vim:
|
|||||||
>
|
>
|
||||||
valgrind --log-file=valgrind.log --leak-check=full ./vim
|
valgrind --log-file=valgrind.log --leak-check=full ./vim
|
||||||
|
|
||||||
Note: Vim will run much slower. If your .vimrc is big or you have several
|
Note: Vim will run much slower. If your vimrc is big or you have several
|
||||||
plugins you need to be patient for startup, or run with the "-u NONE"
|
plugins you need to be patient for startup, or run with the "-u NONE"
|
||||||
argument.
|
argument.
|
||||||
|
|
||||||
|
@@ -66,7 +66,7 @@ make changes after loading a file, these will be included in the displayed
|
|||||||
diffs. You might have to do ":diffupdate" now and then, not all changes are
|
diffs. You might have to do ":diffupdate" now and then, not all changes are
|
||||||
immediately taken into account.
|
immediately taken into account.
|
||||||
|
|
||||||
In your .vimrc file you could do something special when Vim was started in
|
In your vimrc file you could do something special when Vim was started in
|
||||||
diff mode. You could use a construct like this: >
|
diff mode. You could use a construct like this: >
|
||||||
|
|
||||||
if &diff
|
if &diff
|
||||||
|
@@ -3441,7 +3441,7 @@ getfperm({fname}) *getfperm()*
|
|||||||
If a user does not have a given permission the flag for this
|
If a user does not have a given permission the flag for this
|
||||||
is replaced with the string "-". Examples: >
|
is replaced with the string "-". Examples: >
|
||||||
:echo getfperm("/etc/passwd")
|
:echo getfperm("/etc/passwd")
|
||||||
:echo getfperm(expand("~/.vimrc"))
|
:echo getfperm(expand("~/.config/nvim/init.vim"))
|
||||||
< This will hopefully (from a security point of view) display
|
< This will hopefully (from a security point of view) display
|
||||||
the string "rw-r--r--" or even "rw-------".
|
the string "rw-r--r--" or even "rw-------".
|
||||||
|
|
||||||
@@ -4668,10 +4668,10 @@ msgpackdump({list}) {Nvim} *msgpackdump()*
|
|||||||
msgpackparse({list}) {Nvim} *msgpackparse()*
|
msgpackparse({list}) {Nvim} *msgpackparse()*
|
||||||
Convert a |readfile()|-style list to a list of VimL objects.
|
Convert a |readfile()|-style list to a list of VimL objects.
|
||||||
Example: >
|
Example: >
|
||||||
let fname = expand('~/.nvim/shada/main.shada')
|
let fname = expand('~/.config/nvim/shada/main.shada')
|
||||||
let mpack = readfile(fname, 'b')
|
let mpack = readfile(fname, 'b')
|
||||||
let shada_objects = msgpackparse(mpack)
|
let shada_objects = msgpackparse(mpack)
|
||||||
< This will read ~/.nvim/shada/main.shada file to
|
< This will read ~/.config/nvim/shada/main.shada file to
|
||||||
`shada_objects` list.
|
`shada_objects` list.
|
||||||
|
|
||||||
Limitations:
|
Limitations:
|
||||||
@@ -4770,8 +4770,8 @@ pathshorten({expr}) *pathshorten()*
|
|||||||
result. The tail, the file name, is kept as-is. The other
|
result. The tail, the file name, is kept as-is. The other
|
||||||
components in the path are reduced to single letters. Leading
|
components in the path are reduced to single letters. Leading
|
||||||
'~' and '.' characters are kept. Example: >
|
'~' and '.' characters are kept. Example: >
|
||||||
:echo pathshorten('~/.vim/autoload/myfile.vim')
|
:echo pathshorten('~/.config/nvim/autoload/file1.vim')
|
||||||
< ~/.v/a/myfile.vim ~
|
< ~/.v/a/file1.vim ~
|
||||||
It doesn't matter if the path exists or not.
|
It doesn't matter if the path exists or not.
|
||||||
|
|
||||||
pow({x}, {y}) *pow()*
|
pow({x}, {y}) *pow()*
|
||||||
@@ -7274,8 +7274,8 @@ like this: >
|
|||||||
|
|
||||||
When such a function is called, and it is not defined yet, Vim will search the
|
When such a function is called, and it is not defined yet, Vim will search the
|
||||||
"autoload" directories in 'runtimepath' for a script file called
|
"autoload" directories in 'runtimepath' for a script file called
|
||||||
"filename.vim". For example "~/.vim/autoload/filename.vim". That file should
|
"filename.vim". For example "~/.config/nvim/autoload/filename.vim". That
|
||||||
then define the function like this: >
|
file should then define the function like this: >
|
||||||
|
|
||||||
function filename#funcname()
|
function filename#funcname()
|
||||||
echo "Done!"
|
echo "Done!"
|
||||||
@@ -9080,7 +9080,7 @@ A few options contain an expression. When this expression is evaluated it may
|
|||||||
have to be done in the sandbox to avoid a security risk. But the sandbox is
|
have to be done in the sandbox to avoid a security risk. But the sandbox is
|
||||||
restrictive, thus this only happens when the option was set from an insecure
|
restrictive, thus this only happens when the option was set from an insecure
|
||||||
location. Insecure in this context are:
|
location. Insecure in this context are:
|
||||||
- sourcing a .vimrc or .exrc in the current directory
|
- sourcing a .nvimrc or .exrc in the current directory
|
||||||
- while executing in the sandbox
|
- while executing in the sandbox
|
||||||
- value coming from a modeline
|
- value coming from a modeline
|
||||||
|
|
||||||
|
@@ -122,8 +122,7 @@ o Setting the Farsi fonts
|
|||||||
':set guifont=far-a01' in the Vim window.
|
':set guifont=far-a01' in the Vim window.
|
||||||
|
|
||||||
You can have 'guifont' set to far-a01 by Vim during the Vim startup
|
You can have 'guifont' set to far-a01 by Vim during the Vim startup
|
||||||
by appending the ':set guifont=far-a01' into your .vimrc file
|
by appending the ':set guifont=far-a01' into your vimrc file.
|
||||||
(in case of NT/95/98 platforms _vimrc).
|
|
||||||
|
|
||||||
Under the X Window environment, you can also start Vim with the
|
Under the X Window environment, you can also start Vim with the
|
||||||
'-fn far-a01' option.
|
'-fn far-a01' option.
|
||||||
@@ -139,7 +138,7 @@ o Farsi Keymapping Activation
|
|||||||
To activate the Farsi keymapping, set either 'altkeymap' or 'fkmap'.
|
To activate the Farsi keymapping, set either 'altkeymap' or 'fkmap'.
|
||||||
This is done by entering ':set akm' or ':set fk' in the Vim window.
|
This is done by entering ':set akm' or ':set fk' in the Vim window.
|
||||||
You can have 'altkeymap' or 'fkmap' set as default by appending ':set akm'
|
You can have 'altkeymap' or 'fkmap' set as default by appending ':set akm'
|
||||||
or ':set fk' in your .vimrc file or _vimrc in case of NT/95/98 platforms.
|
or ':set fk' in your vimrc file.
|
||||||
|
|
||||||
To turn off the Farsi keymapping as a default second language keymapping,
|
To turn off the Farsi keymapping as a default second language keymapping,
|
||||||
reset the 'altkeymap' by entering ':set noakm'.
|
reset the 'altkeymap' by entering ':set noakm'.
|
||||||
@@ -156,8 +155,8 @@ o right-to-left Farsi Mode
|
|||||||
+ While in Left-to-right mode, enter 'set rl' in the command line ('rl' is
|
+ While in Left-to-right mode, enter 'set rl' in the command line ('rl' is
|
||||||
the abbreviation for rightleft).
|
the abbreviation for rightleft).
|
||||||
|
|
||||||
+ Put the 'set rl' line in your '.vimrc' file to start Vim in
|
+ Put the 'set rl' line in your vimrc file to start Vim in right-to-left
|
||||||
right-to-left mode permanently.
|
mode permanently.
|
||||||
|
|
||||||
Encoding
|
Encoding
|
||||||
--------
|
--------
|
||||||
|
@@ -162,8 +162,7 @@ A. If you want to overrule all default file type checks.
|
|||||||
1. Create your user runtime directory. You would normally use the first
|
1. Create your user runtime directory. You would normally use the first
|
||||||
item of the 'runtimepath' option. Then create the directory "ftdetect"
|
item of the 'runtimepath' option. Then create the directory "ftdetect"
|
||||||
inside it. Example for Unix: >
|
inside it. Example for Unix: >
|
||||||
:!mkdir ~/.vim
|
:!mkdir -p ~/.config/nvim/ftdetect
|
||||||
:!mkdir ~/.vim/ftdetect
|
|
||||||
<
|
<
|
||||||
2. Create a file that contains an autocommand to detect the file type.
|
2. Create a file that contains an autocommand to detect the file type.
|
||||||
Example: >
|
Example: >
|
||||||
@@ -173,7 +172,7 @@ A. If you want to overrule all default file type checks.
|
|||||||
check the contents of the file to recognize it.
|
check the contents of the file to recognize it.
|
||||||
Write this file as "mine.vim" in the "ftdetect" directory in your user
|
Write this file as "mine.vim" in the "ftdetect" directory in your user
|
||||||
runtime directory. For example, for Unix: >
|
runtime directory. For example, for Unix: >
|
||||||
:w ~/.vim/ftdetect/mine.vim
|
:w ~/.config/nvim/ftdetect/mine.vim
|
||||||
|
|
||||||
< 3. To use the new filetype detection you must restart Vim.
|
< 3. To use the new filetype detection you must restart Vim.
|
||||||
|
|
||||||
@@ -196,7 +195,7 @@ B. If you want to detect your file after the default file type checks.
|
|||||||
C. If your file type can be detected by the file name.
|
C. If your file type can be detected by the file name.
|
||||||
1. Create your user runtime directory. You would normally use the first
|
1. Create your user runtime directory. You would normally use the first
|
||||||
item of the 'runtimepath' option. Example for Unix: >
|
item of the 'runtimepath' option. Example for Unix: >
|
||||||
:!mkdir ~/.vim
|
:!mkdir -p ~/.config/nvim
|
||||||
<
|
<
|
||||||
2. Create a file that contains autocommands to detect the file type.
|
2. Create a file that contains autocommands to detect the file type.
|
||||||
Example: >
|
Example: >
|
||||||
@@ -210,7 +209,7 @@ C. If your file type can be detected by the file name.
|
|||||||
augroup END
|
augroup END
|
||||||
< Write this file as "filetype.vim" in your user runtime directory. For
|
< Write this file as "filetype.vim" in your user runtime directory. For
|
||||||
example, for Unix: >
|
example, for Unix: >
|
||||||
:w ~/.vim/filetype.vim
|
:w ~/.config/nvim/filetype.vim
|
||||||
|
|
||||||
< 3. To use the new filetype detection you must restart Vim.
|
< 3. To use the new filetype detection you must restart Vim.
|
||||||
|
|
||||||
@@ -224,7 +223,7 @@ D. If your filetype can only be detected by inspecting the contents of the
|
|||||||
|
|
||||||
1. Create your user runtime directory. You would normally use the first
|
1. Create your user runtime directory. You would normally use the first
|
||||||
item of the 'runtimepath' option. Example for Unix: >
|
item of the 'runtimepath' option. Example for Unix: >
|
||||||
:!mkdir ~/.vim
|
:!mkdir -p ~/.config/nvim
|
||||||
<
|
<
|
||||||
2. Create a vim script file for doing this. Example: >
|
2. Create a vim script file for doing this. Example: >
|
||||||
if did_filetype() " filetype already set..
|
if did_filetype() " filetype already set..
|
||||||
@@ -238,7 +237,7 @@ D. If your filetype can only be detected by inspecting the contents of the
|
|||||||
< See $VIMRUNTIME/scripts.vim for more examples.
|
< See $VIMRUNTIME/scripts.vim for more examples.
|
||||||
Write this file as "scripts.vim" in your user runtime directory. For
|
Write this file as "scripts.vim" in your user runtime directory. For
|
||||||
example, for Unix: >
|
example, for Unix: >
|
||||||
:w ~/.vim/scripts.vim
|
:w ~/.config/nvim/scripts.vim
|
||||||
<
|
<
|
||||||
3. The detection will work right away, no need to restart Vim.
|
3. The detection will work right away, no need to restart Vim.
|
||||||
|
|
||||||
@@ -268,12 +267,12 @@ all loaded. For example, if this command: >
|
|||||||
|
|
||||||
produces this output:
|
produces this output:
|
||||||
|
|
||||||
runtimepath=/etc/vim,~/.vim,/usr/local/share/vim/vim60 ~
|
runtimepath=/etc/vim,~/.config/nvim,/usr/local/share/vim/vim60 ~
|
||||||
|
|
||||||
then Vim will load all plugins in these directories and below:
|
then Vim will load all plugins in these directories and below:
|
||||||
|
|
||||||
/etc/vim/plugin/ ~
|
/etc/vim/plugin/ ~
|
||||||
~/.vim/plugin/ ~
|
~/.config/nvim/plugin/ ~
|
||||||
/usr/local/share/vim/vim60/plugin/ ~
|
/usr/local/share/vim/vim60/plugin/ ~
|
||||||
|
|
||||||
Note that the last one is the value of $VIMRUNTIME which has been expanded.
|
Note that the last one is the value of $VIMRUNTIME which has been expanded.
|
||||||
@@ -329,7 +328,7 @@ ways to change this:
|
|||||||
1. Add a few settings.
|
1. Add a few settings.
|
||||||
You must create a new filetype plugin in a directory early in
|
You must create a new filetype plugin in a directory early in
|
||||||
'runtimepath'. For Unix, for example you could use this file: >
|
'runtimepath'. For Unix, for example you could use this file: >
|
||||||
vim ~/.vim/ftplugin/fortran.vim
|
vim ~/.config/nvim/ftplugin/fortran.vim
|
||||||
< You can set those settings and mappings that you would like to add. Note
|
< You can set those settings and mappings that you would like to add. Note
|
||||||
that the global plugin will be loaded after this, it may overrule the
|
that the global plugin will be loaded after this, it may overrule the
|
||||||
settings that you do here. If this is the case, you need to use one of the
|
settings that you do here. If this is the case, you need to use one of the
|
||||||
@@ -338,7 +337,7 @@ ways to change this:
|
|||||||
2. Make a copy of the plugin and change it.
|
2. Make a copy of the plugin and change it.
|
||||||
You must put the copy in a directory early in 'runtimepath'. For Unix, for
|
You must put the copy in a directory early in 'runtimepath'. For Unix, for
|
||||||
example, you could do this: >
|
example, you could do this: >
|
||||||
cp $VIMRUNTIME/ftplugin/fortran.vim ~/.vim/ftplugin/fortran.vim
|
cp $VIMRUNTIME/ftplugin/fortran.vim ~/.config/nvim/ftplugin/fortran.vim
|
||||||
< Then you can edit the copied file to your liking. Since the b:did_ftplugin
|
< Then you can edit the copied file to your liking. Since the b:did_ftplugin
|
||||||
variable will be set, the global plugin will not be loaded.
|
variable will be set, the global plugin will not be loaded.
|
||||||
A disadvantage of this method is that when the distributed plugin gets
|
A disadvantage of this method is that when the distributed plugin gets
|
||||||
@@ -347,7 +346,7 @@ ways to change this:
|
|||||||
3. Overrule the settings after loading the global plugin.
|
3. Overrule the settings after loading the global plugin.
|
||||||
You must create a new filetype plugin in a directory from the end of
|
You must create a new filetype plugin in a directory from the end of
|
||||||
'runtimepath'. For Unix, for example, you could use this file: >
|
'runtimepath'. For Unix, for example, you could use this file: >
|
||||||
vim ~/.vim/after/ftplugin/fortran.vim
|
vim ~/.config/nvim/after/ftplugin/fortran.vim
|
||||||
< In this file you can change just those settings that you want to change.
|
< In this file you can change just those settings that you want to change.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
@@ -376,7 +375,7 @@ Global mappings:
|
|||||||
NOTE: The global mappings are accessed by sourcing the
|
NOTE: The global mappings are accessed by sourcing the
|
||||||
ftplugin/changelog.vim file first, e.g. with >
|
ftplugin/changelog.vim file first, e.g. with >
|
||||||
runtime ftplugin/changelog.vim
|
runtime ftplugin/changelog.vim
|
||||||
< in your |.vimrc|.
|
< in your |init.vim|.
|
||||||
<Leader>o Switches to the ChangeLog buffer opened for the
|
<Leader>o Switches to the ChangeLog buffer opened for the
|
||||||
current directory, or opens it in a new buffer if it
|
current directory, or opens it in a new buffer if it
|
||||||
exists in the current directory. Then it does the
|
exists in the current directory. Then it does the
|
||||||
@@ -478,7 +477,7 @@ FORTRAN *ft-fortran-plugin*
|
|||||||
|
|
||||||
Options:
|
Options:
|
||||||
'expandtab' is switched on to avoid tabs as required by the Fortran
|
'expandtab' is switched on to avoid tabs as required by the Fortran
|
||||||
standards unless the user has set fortran_have_tabs in .vimrc.
|
standards unless the user has set fortran_have_tabs in vimrc.
|
||||||
'textwidth' is set to 72 for fixed source format as required by the
|
'textwidth' is set to 72 for fixed source format as required by the
|
||||||
Fortran standards and to 80 for free source format.
|
Fortran standards and to 80 for free source format.
|
||||||
'formatoptions' is set to break code and comment lines and to preserve long
|
'formatoptions' is set to break code and comment lines and to preserve long
|
||||||
|
@@ -58,7 +58,7 @@ To disable them use ":unlet". Example:
|
|||||||
|
|
||||||
You can just use ":" and type these into the command line to set these
|
You can just use ":" and type these into the command line to set these
|
||||||
temporarily before loading an Ada file. You can make these option settings
|
temporarily before loading an Ada file. You can make these option settings
|
||||||
permanent by adding the "let" command(s), without a colon, to your "~/.vimrc"
|
permanent by adding the "let" command(s), without a colon, to your |init.vim|
|
||||||
file.
|
file.
|
||||||
|
|
||||||
Even on a slow (90Mhz) PC this mode works quickly, but if you find the
|
Even on a slow (90Mhz) PC this mode works quickly, but if you find the
|
||||||
|
@@ -149,7 +149,7 @@ The above will also handle these cases: >
|
|||||||
);
|
);
|
||||||
|
|
||||||
By default, the ftplugin only searches for CREATE statements. You can also
|
By default, the ftplugin only searches for CREATE statements. You can also
|
||||||
override this via your |vimrc| with the following: >
|
override this via your |init.vim| with the following: >
|
||||||
let g:ftplugin_sql_statements = 'create,alter'
|
let g:ftplugin_sql_statements = 'create,alter'
|
||||||
|
|
||||||
The filetype plugin defines three types of comments: >
|
The filetype plugin defines three types of comments: >
|
||||||
@@ -227,7 +227,7 @@ you must either create:
|
|||||||
3. Manual steps / commands
|
3. Manual steps / commands
|
||||||
|
|
||||||
The majority of people work with only one vendor's database product, it would
|
The majority of people work with only one vendor's database product, it would
|
||||||
be nice to specify a default in your |vimrc|.
|
be nice to specify a default in your |init.vim|.
|
||||||
|
|
||||||
|
|
||||||
2.1 SQLSetType *sqlsettype* *SQLSetType*
|
2.1 SQLSetType *sqlsettype* *SQLSetType*
|
||||||
@@ -273,12 +273,12 @@ This will echo: >
|
|||||||
-----------------------
|
-----------------------
|
||||||
As mentioned earlier, the default syntax rules for Vim is based on Oracle
|
As mentioned earlier, the default syntax rules for Vim is based on Oracle
|
||||||
(PL/SQL). You can override this default by placing one of the following in
|
(PL/SQL). You can override this default by placing one of the following in
|
||||||
your |vimrc|: >
|
your |init.vim|: >
|
||||||
let g:sql_type_default = 'sqlanywhere'
|
let g:sql_type_default = 'sqlanywhere'
|
||||||
let g:sql_type_default = 'sqlinformix'
|
let g:sql_type_default = 'sqlinformix'
|
||||||
let g:sql_type_default = 'mysql'
|
let g:sql_type_default = 'mysql'
|
||||||
|
|
||||||
If you added the following to your |vimrc|: >
|
If you added the following to your |init.vim|: >
|
||||||
let g:sql_type_default = 'sqlinformix'
|
let g:sql_type_default = 'sqlinformix'
|
||||||
|
|
||||||
The next time edit a SQL file the following scripts will be automatically
|
The next time edit a SQL file the following scripts will be automatically
|
||||||
@@ -304,11 +304,8 @@ To help identify these scripts, try to create the files with a "sql" prefix.
|
|||||||
If you decide you wish to create customizations for the SQLite database, you
|
If you decide you wish to create customizations for the SQLite database, you
|
||||||
can create any of the following: >
|
can create any of the following: >
|
||||||
Unix
|
Unix
|
||||||
~/.vim/syntax/sqlite.vim
|
~/.config/nvim/syntax/sqlite.vim
|
||||||
~/.vim/indent/sqlite.vim
|
~/.config/nvim/indent/sqlite.vim
|
||||||
Windows
|
|
||||||
$VIM/vimfiles/syntax/sqlite.vim
|
|
||||||
$VIM/vimfiles/indent/sqlite.vim
|
|
||||||
|
|
||||||
No changes are necessary to the SQLSetType function. It will automatically
|
No changes are necessary to the SQLSetType function. It will automatically
|
||||||
pickup the new SQL files and load them when you issue the SQLSetType command.
|
pickup the new SQL files and load them when you issue the SQLSetType command.
|
||||||
@@ -341,8 +338,8 @@ The defaults static maps are: >
|
|||||||
imap <buffer> <C-C>T <C-\><C-O>:call sqlcomplete#Map('sqlType')<CR><C-X><C-O>
|
imap <buffer> <C-C>T <C-\><C-O>:call sqlcomplete#Map('sqlType')<CR><C-X><C-O>
|
||||||
imap <buffer> <C-C>s <C-\><C-O>:call sqlcomplete#Map('sqlStatement')<CR><C-X><C-O>
|
imap <buffer> <C-C>s <C-\><C-O>:call sqlcomplete#Map('sqlStatement')<CR><C-X><C-O>
|
||||||
|
|
||||||
The use of "<C-C>" can be user chosen by using the following in your |.vimrc| as it
|
The use of "<C-C>" can be user chosen by using the following in your
|
||||||
may not work properly on all platforms: >
|
|init.vim| as it may not work properly on all platforms: >
|
||||||
let g:ftplugin_sql_omni_key = '<C-C>'
|
let g:ftplugin_sql_omni_key = '<C-C>'
|
||||||
>
|
>
|
||||||
The static maps (which are based on the syntax highlight groups) follow this
|
The static maps (which are based on the syntax highlight groups) follow this
|
||||||
@@ -440,7 +437,7 @@ the space bar):
|
|||||||
- This allows you to quickly drill down into a
|
- This allows you to quickly drill down into a
|
||||||
table to view its columns and back again.
|
table to view its columns and back again.
|
||||||
- <Right> and <Left> can be also be chosen via
|
- <Right> and <Left> can be also be chosen via
|
||||||
your |.vimrc| >
|
your |init.vim| >
|
||||||
let g:ftplugin_sql_omni_key_right = '<Right>'
|
let g:ftplugin_sql_omni_key_right = '<Right>'
|
||||||
let g:ftplugin_sql_omni_key_left = '<Left>'
|
let g:ftplugin_sql_omni_key_left = '<Left>'
|
||||||
|
|
||||||
@@ -604,7 +601,7 @@ database.
|
|||||||
----------------------------
|
----------------------------
|
||||||
|
|
||||||
The SQL completion plugin can be customized through various options set in
|
The SQL completion plugin can be customized through various options set in
|
||||||
your |vimrc|: >
|
your |init.vim|: >
|
||||||
omni_sql_no_default_maps
|
omni_sql_no_default_maps
|
||||||
< - Default: This variable is not defined
|
< - Default: This variable is not defined
|
||||||
- If this variable is defined, no maps are created for OMNI
|
- If this variable is defined, no maps are created for OMNI
|
||||||
@@ -723,7 +720,7 @@ will be specifying different syntax highlight groups.
|
|||||||
|
|
||||||
If you do not wish the default maps created or the key choices do not work on
|
If you do not wish the default maps created or the key choices do not work on
|
||||||
your platform (often a case on *nix) you define the following variable in
|
your platform (often a case on *nix) you define the following variable in
|
||||||
your |vimrc|: >
|
your |init.vim|: >
|
||||||
let g:omni_sql_no_default_maps = 1
|
let g:omni_sql_no_default_maps = 1
|
||||||
|
|
||||||
Do no edit ftplugin/sql.vim directly! If you change this file your changes
|
Do no edit ftplugin/sql.vim directly! If you change this file your changes
|
||||||
|
@@ -26,10 +26,10 @@ How to start the GUI depends on the system used. Mostly you can run the
|
|||||||
GUI version of Vim with:
|
GUI version of Vim with:
|
||||||
gvim [options] [files...]
|
gvim [options] [files...]
|
||||||
|
|
||||||
*gui-init* *gvimrc* *.gvimrc* *_gvimrc* *$MYGVIMRC*
|
*ginit.vim* *gui-init* *gvimrc* *$MYGVIMRC*
|
||||||
The gvimrc file is where GUI-specific startup commands should be placed. It
|
The gvimrc file is where GUI-specific startup commands should be placed. It
|
||||||
is always sourced after the |vimrc| file. If you have one then the $MYGVIMRC
|
is always sourced after the |init.vim| file. If you have one then the
|
||||||
environment variable has its name.
|
$MYGVIMRC environment variable has its name.
|
||||||
|
|
||||||
When the GUI starts up initializations are carried out, in this order:
|
When the GUI starts up initializations are carried out, in this order:
|
||||||
- The 'term' option is set to "builtin_gui" and terminal options are reset to
|
- The 'term' option is set to "builtin_gui" and terminal options are reset to
|
||||||
@@ -39,7 +39,7 @@ When the GUI starts up initializations are carried out, in this order:
|
|||||||
see |$VIMRUNTIME|. To skip loading the system menu include 'M' in
|
see |$VIMRUNTIME|. To skip loading the system menu include 'M' in
|
||||||
'guioptions'. *buffers-menu* *no_buffers_menu*
|
'guioptions'. *buffers-menu* *no_buffers_menu*
|
||||||
The system menu file includes a "Buffers" menu. If you don't want this, set
|
The system menu file includes a "Buffers" menu. If you don't want this, set
|
||||||
the "no_buffers_menu" variable in your .vimrc (not .gvimrc!): >
|
the "no_buffers_menu" variable in your init.vim (not ginit.vim!): >
|
||||||
:let no_buffers_menu = 1
|
:let no_buffers_menu = 1
|
||||||
< NOTE: Switching on syntax highlighting also loads the menu file, thus
|
< NOTE: Switching on syntax highlighting also loads the menu file, thus
|
||||||
disabling the Buffers menu must be done before ":syntax on".
|
disabling the Buffers menu must be done before ":syntax on".
|
||||||
@@ -51,29 +51,26 @@ When the GUI starts up initializations are carried out, in this order:
|
|||||||
initializations are skipped. When {gvimrc} is "NONE" no file will be read
|
initializations are skipped. When {gvimrc} is "NONE" no file will be read
|
||||||
for initializations.
|
for initializations.
|
||||||
- For Unix and MS-Windows, if the system gvimrc exists, it is sourced. The
|
- For Unix and MS-Windows, if the system gvimrc exists, it is sourced. The
|
||||||
name of this file is normally "$VIM/gvimrc". You can check this with
|
name of this file is normally "$VIM/ginit.vim". You can check this with
|
||||||
":version". Also see |$VIM|.
|
":version". Also see |$VIM|.
|
||||||
- The following are tried, and only the first one that exists is used:
|
- The following are tried, and only the first one that exists is used:
|
||||||
- If the GVIMINIT environment variable exists and is not empty, it is
|
- If the GVIMINIT environment variable exists and is not empty, it is
|
||||||
executed as an Ex command.
|
executed as an Ex command.
|
||||||
- If the user gvimrc file exists, it is sourced. The name of this file is
|
- If the user gvimrc file exists, it is sourced. The name of this file is
|
||||||
normally "$HOME/.gvimrc". You can check this with ":version".
|
normally "$XDG_CONFIG_HOME/nvim/ginit.vim" ($XDG_CONFIG_HOME defaults to
|
||||||
- For Win32, when $HOME is not set, "$VIM\_gvimrc" is used.
|
~/.config).
|
||||||
- When a "_gvimrc" file is not found, ".gvimrc" is tried too. And vice
|
|
||||||
versa.
|
|
||||||
The name of the first file found is stored in $MYGVIMRC, unless it was
|
The name of the first file found is stored in $MYGVIMRC, unless it was
|
||||||
already set.
|
already set.
|
||||||
- If the 'exrc' option is set (which is NOT the default) the file ./.gvimrc
|
- If the 'exrc' option is set (which is NOT the default) the file ./.ngvimrc
|
||||||
is sourced, if it exists and isn't the same file as the system or user
|
is sourced, if it exists and isn't the same file as the system or user
|
||||||
gvimrc file. If this file is not owned by you, some security restrictions
|
gvimrc file. If this file is not owned by you, some security restrictions
|
||||||
apply. When ".gvimrc" is not found, "_gvimrc" is tried too. For Macintosh
|
apply. When ".ngvimrc" is not found, "_ngvimrc" is tried too.
|
||||||
and DOS/Win32 "_gvimrc" is tried first.
|
|
||||||
|
|
||||||
NOTE: All but the first one are not carried out if Vim was started with
|
NOTE: All but the first one are not carried out if Vim was started with
|
||||||
"-u NONE" and no "-U" argument was given, or when started with "-U NONE".
|
"-u NONE" and no "-U" argument was given, or when started with "-U NONE".
|
||||||
|
|
||||||
All this happens AFTER the normal Vim initializations, like reading your
|
All this happens AFTER the normal Vim initializations, like reading your
|
||||||
.vimrc file. See |initialization|.
|
vimrc file. See |initialization|.
|
||||||
But the GUI window is only opened after all the initializations have been
|
But the GUI window is only opened after all the initializations have been
|
||||||
carried out. If you want some commands to be executed just after opening the
|
carried out. If you want some commands to be executed just after opening the
|
||||||
GUI window, use the |GUIEnter| autocommand event. Example: >
|
GUI window, use the |GUIEnter| autocommand event. Example: >
|
||||||
@@ -84,9 +81,8 @@ and initialize other things that you may want to set up differently from the
|
|||||||
terminal version.
|
terminal version.
|
||||||
|
|
||||||
Recommended place for your personal GUI initializations:
|
Recommended place for your personal GUI initializations:
|
||||||
Unix $HOME/.gvimrc or $HOME/.vim/gvimrc
|
Unix $XDG_CONFIG_HOME/.config/nvim/ginit.vim
|
||||||
MS-DOS and Win32 $HOME/_gvimrc, $HOME/vimfiles/gvimrc
|
(default for $XDG_CONFIG_HOME is ~/.config)
|
||||||
or $VIM/_gvimrc
|
|
||||||
|
|
||||||
The personal initialization files are searched in the order specified above
|
The personal initialization files are searched in the order specified above
|
||||||
and only the first one that is found is read.
|
and only the first one that is found is read.
|
||||||
@@ -464,7 +460,7 @@ The default menus are read from the file "$VIMRUNTIME/menu.vim". See
|
|||||||
Starting off with the default set is a good idea. You can add more items, or,
|
Starting off with the default set is a good idea. You can add more items, or,
|
||||||
if you don't like the defaults at all, start with removing all menus
|
if you don't like the defaults at all, start with removing all menus
|
||||||
|:unmenu-all|. You can also avoid the default menus being loaded by adding
|
|:unmenu-all|. You can also avoid the default menus being loaded by adding
|
||||||
this line to your .vimrc file (NOT your .gvimrc file!): >
|
this line to your vimrc file (NOT your gvimrc file!): >
|
||||||
:let did_install_default_menus = 1
|
:let did_install_default_menus = 1
|
||||||
If you also want to avoid the Syntax menu: >
|
If you also want to avoid the Syntax menu: >
|
||||||
:let did_install_syntax_menu = 1
|
:let did_install_syntax_menu = 1
|
||||||
@@ -479,7 +475,7 @@ Although this documentation is in the GUI section, you can actually use menus
|
|||||||
in console mode too. You will have to load |menu.vim| explicitly then, it is
|
in console mode too. You will have to load |menu.vim| explicitly then, it is
|
||||||
not done by default. You can use the |:emenu| command and command-line
|
not done by default. You can use the |:emenu| command and command-line
|
||||||
completion with 'wildmenu' to access the menu entries almost like a real menu
|
completion with 'wildmenu' to access the menu entries almost like a real menu
|
||||||
system. To do this, put these commands in your .vimrc file: >
|
system. To do this, put these commands in your vimrc file: >
|
||||||
:source $VIMRUNTIME/menu.vim
|
:source $VIMRUNTIME/menu.vim
|
||||||
:set wildmenu
|
:set wildmenu
|
||||||
:set cpo-=<
|
:set cpo-=<
|
||||||
|
@@ -316,7 +316,7 @@ When referring to a Vim option in the help file, place the option name between
|
|||||||
two single quotes, eg. 'statusline'
|
two single quotes, eg. 'statusline'
|
||||||
|
|
||||||
When referring to any other technical term, such as a filename or function
|
When referring to any other technical term, such as a filename or function
|
||||||
parameter, surround it in backticks (`), eg. `~/.path/to/nvimrc`.
|
parameter, surround it in backticks (`), eg. `~/.path/to/init.vim`.
|
||||||
|
|
||||||
|
|
||||||
HIGHLIGHTING
|
HIGHLIGHTING
|
||||||
|
@@ -241,8 +241,8 @@ through your tags file(s).
|
|||||||
3. Cscope options *cscope-options*
|
3. Cscope options *cscope-options*
|
||||||
|
|
||||||
Use the |:set| command to set all cscope options. Ideally, you would do
|
Use the |:set| command to set all cscope options. Ideally, you would do
|
||||||
this in one of your startup files (e.g., .vimrc). Some cscope related
|
this in one of your startup files (e.g., vimrc). Some cscope related
|
||||||
variables are only valid within |.vimrc|. Setting them after vim has
|
variables are only valid within |init.vim|. Setting them after vim has
|
||||||
started will have no effect!
|
started will have no effect!
|
||||||
|
|
||||||
*cscopeprg* *csprg*
|
*cscopeprg* *csprg*
|
||||||
@@ -292,10 +292,10 @@ Examples: >
|
|||||||
*cscopeverbose* *csverb*
|
*cscopeverbose* *csverb*
|
||||||
If 'cscopeverbose' is not set (the default), messages will not be printed
|
If 'cscopeverbose' is not set (the default), messages will not be printed
|
||||||
indicating success or failure when adding a cscope database. Ideally, you
|
indicating success or failure when adding a cscope database. Ideally, you
|
||||||
should reset this option in your |.vimrc| before adding any cscope databases,
|
should reset this option in your |init.vim| before adding any cscope
|
||||||
and after adding them, set it. From then on, when you add more databases
|
databases, and after adding them, set it. From then on, when you add more
|
||||||
within Vim, you will get a (hopefully) useful message should the database fail
|
databases within Vim, you will get a (hopefully) useful message should the
|
||||||
to be added. Examples: >
|
database fail to be added. Examples: >
|
||||||
:set csverb
|
:set csverb
|
||||||
:set nocsverb
|
:set nocsverb
|
||||||
<
|
<
|
||||||
@@ -317,7 +317,7 @@ refer to the cscope man page for more details.
|
|||||||
|
|
||||||
Assuming you have a cscope database, you need to "add" the database to Vim.
|
Assuming you have a cscope database, you need to "add" the database to Vim.
|
||||||
This establishes a cscope "connection" and makes it available for Vim to use.
|
This establishes a cscope "connection" and makes it available for Vim to use.
|
||||||
You can do this in your .vimrc file, or you can do it manually after starting
|
You can do this in your vimrc file, or you can do it manually after starting
|
||||||
vim. For example, to add the cscope database "cscope.out", you would do:
|
vim. For example, to add the cscope database "cscope.out", you would do:
|
||||||
|
|
||||||
:cs add cscope.out
|
:cs add cscope.out
|
||||||
@@ -366,7 +366,7 @@ is not configurable (e.g., you can't do a tselect instead).
|
|||||||
==============================================================================
|
==============================================================================
|
||||||
6. Suggested usage *cscope-suggestions*
|
6. Suggested usage *cscope-suggestions*
|
||||||
|
|
||||||
Put these entries in your .vimrc (adjust the pathname accordingly to your
|
Put these entries in your vimrc (adjust the pathname accordingly to your
|
||||||
setup): >
|
setup): >
|
||||||
|
|
||||||
if has("cscope")
|
if has("cscope")
|
||||||
|
@@ -718,7 +718,7 @@ also left unindented because continue statements are also used for purposes
|
|||||||
other than ending a do loop. Programs such as Tidy can convert structured
|
other than ending a do loop. Programs such as Tidy can convert structured
|
||||||
do/continue loops to the do/enddo form. Do loops of the do/enddo variety can
|
do/continue loops to the do/enddo form. Do loops of the do/enddo variety can
|
||||||
be indented. If you use only structured loops of the do/enddo form, you should
|
be indented. If you use only structured loops of the do/enddo form, you should
|
||||||
declare this by setting the fortran_do_enddo variable in your .vimrc as
|
declare this by setting the fortran_do_enddo variable in your vimrc as
|
||||||
follows >
|
follows >
|
||||||
|
|
||||||
let fortran_do_enddo=1
|
let fortran_do_enddo=1
|
||||||
@@ -737,7 +737,7 @@ The indenting of program units (subroutines, functions, modules, and program
|
|||||||
blocks) is enabled by default but can be suppressed if a lighter, screen-width
|
blocks) is enabled by default but can be suppressed if a lighter, screen-width
|
||||||
preserving indent style is desired. To suppress the indenting of program
|
preserving indent style is desired. To suppress the indenting of program
|
||||||
units for all fortran files set the global fortran_indent_less variable in
|
units for all fortran files set the global fortran_indent_less variable in
|
||||||
your .vimrc as follows >
|
your vimrc as follows >
|
||||||
|
|
||||||
let fortran_indent_less=1
|
let fortran_indent_less=1
|
||||||
|
|
||||||
@@ -969,7 +969,7 @@ VERILOG *ft-verilog-indent*
|
|||||||
General block statements such as if, for, case, always, initial, function,
|
General block statements such as if, for, case, always, initial, function,
|
||||||
specify and begin, etc., are indented. The module block statements (first
|
specify and begin, etc., are indented. The module block statements (first
|
||||||
level blocks) are not indented by default. you can turn on the indent with
|
level blocks) are not indented by default. you can turn on the indent with
|
||||||
setting a variable in the .vimrc as follows: >
|
setting a variable in the vimrc as follows: >
|
||||||
|
|
||||||
let b:verilog_indent_modules = 1
|
let b:verilog_indent_modules = 1
|
||||||
|
|
||||||
@@ -1017,7 +1017,7 @@ To turn this off, add >
|
|||||||
|
|
||||||
let g:vhdl_indent_genportmap = 0
|
let g:vhdl_indent_genportmap = 0
|
||||||
|
|
||||||
to the .vimrc file, which causes the previous alignment example to change: >
|
to the vimrc file, which causes the previous alignment example to change: >
|
||||||
|
|
||||||
ENTITY sync IS
|
ENTITY sync IS
|
||||||
PORT (
|
PORT (
|
||||||
@@ -1041,7 +1041,7 @@ To turn this off, add >
|
|||||||
|
|
||||||
let g:vhdl_indent_rhsassign = 0
|
let g:vhdl_indent_rhsassign = 0
|
||||||
|
|
||||||
to the .vimrc file, which causes the previous alignment example to change: >
|
to the vimrc file, which causes the previous alignment example to change: >
|
||||||
|
|
||||||
sig_out <= (bus_a(1) AND
|
sig_out <= (bus_a(1) AND
|
||||||
(sig_b OR sig_c)) OR
|
(sig_b OR sig_c)) OR
|
||||||
|
@@ -1257,9 +1257,9 @@ A compiled .exe for MS-Windows can be found at:
|
|||||||
|
|
||||||
If you want to complete system functions you can do something like this. Use
|
If you want to complete system functions you can do something like this. Use
|
||||||
ctags to generate a tags file for all the system header files: >
|
ctags to generate a tags file for all the system header files: >
|
||||||
% ctags -R -f ~/.vim/systags /usr/include /usr/local/include
|
% ctags -R -f ~/.config/nvim/systags /usr/include /usr/local/include
|
||||||
In your vimrc file add this tags file to the 'tags' option: >
|
In your vimrc file add this tags file to the 'tags' option: >
|
||||||
set tags+=~/.vim/systags
|
set tags+=~/.config/nvim/systags
|
||||||
|
|
||||||
When using CTRL-X CTRL-O after a name without any "." or "->" it is completed
|
When using CTRL-X CTRL-O after a name without any "." or "->" it is completed
|
||||||
from the tags file directly. This works for any identifier, also function
|
from the tags file directly. This works for any identifier, also function
|
||||||
@@ -1459,7 +1459,7 @@ minimal language-sensitive completion.
|
|||||||
To enable syntax code completion you can run: >
|
To enable syntax code completion you can run: >
|
||||||
setlocal omnifunc=syntaxcomplete#Complete
|
setlocal omnifunc=syntaxcomplete#Complete
|
||||||
|
|
||||||
You can automate this by placing the following in your |.vimrc| (after any
|
You can automate this by placing the following in your |init.vim| (after any
|
||||||
":filetype" command): >
|
":filetype" command): >
|
||||||
if has("autocmd") && exists("+omnifunc")
|
if has("autocmd") && exists("+omnifunc")
|
||||||
autocmd Filetype *
|
autocmd Filetype *
|
||||||
|
@@ -435,7 +435,7 @@ last defined. Example: >
|
|||||||
|
|
||||||
:verbose map <C-W>*
|
:verbose map <C-W>*
|
||||||
n <C-W>* * <C-W><C-S>*
|
n <C-W>* * <C-W><C-S>*
|
||||||
Last set from /home/abcd/.vimrc
|
Last set from ~/.config/nvim/init.vim
|
||||||
|
|
||||||
See |:verbose-cmd| for more information.
|
See |:verbose-cmd| for more information.
|
||||||
|
|
||||||
@@ -1046,7 +1046,7 @@ You type: ab esc ^V^V^V^V^V^[
|
|||||||
You see: ab esc ^V^V^[
|
You see: ab esc ^V^V^[
|
||||||
|
|
||||||
The command-line contains two actual ^Vs before the ^[. This is
|
The command-line contains two actual ^Vs before the ^[. This is
|
||||||
how it should appear in your .exrc file, if you choose to go that
|
how it should appear in your vimrc file, if you choose to go that
|
||||||
route. The first ^V is there to quote the second ^V; the :ab
|
route. The first ^V is there to quote the second ^V; the :ab
|
||||||
command uses ^V as its own quote character, so you can include quoted
|
command uses ^V as its own quote character, so you can include quoted
|
||||||
whitespace or the | character in the abbreviation. The :ab command
|
whitespace or the | character in the abbreviation. The :ab command
|
||||||
|
@@ -222,7 +222,7 @@ To use a locale in Vim only, use the |:language| command: >
|
|||||||
|
|
||||||
:language ko
|
:language ko
|
||||||
|
|
||||||
Put this in your ~/.vimrc file to use it always.
|
Put this in your |init.vim| file to use it always.
|
||||||
|
|
||||||
Or specify $LANG when starting Vim:
|
Or specify $LANG when starting Vim:
|
||||||
|
|
||||||
@@ -684,7 +684,7 @@ that works well you can use this command to see its name: >
|
|||||||
|
|
||||||
:set guifont
|
:set guifont
|
||||||
|
|
||||||
Then add a command to your |gvimrc| file to set 'guifont': >
|
Then add a command to your |ginit.vim| file to set 'guifont': >
|
||||||
|
|
||||||
:set guifont=courier_new:h12
|
:set guifont=courier_new:h12
|
||||||
|
|
||||||
@@ -928,7 +928,7 @@ Cursor color when IME or XIM is on *CursorIM*
|
|||||||
This works in the same way when using XIM.
|
This works in the same way when using XIM.
|
||||||
|
|
||||||
You can select cursor color when status is on by using highlight group
|
You can select cursor color when status is on by using highlight group
|
||||||
CursorIM. For example, add these lines to your |gvimrc|: >
|
CursorIM. For example, add these lines to your |ginit.vim|: >
|
||||||
|
|
||||||
if has('multi_byte_ime')
|
if has('multi_byte_ime')
|
||||||
highlight Cursor guifg=NONE guibg=Green
|
highlight Cursor guifg=NONE guibg=Green
|
||||||
|
@@ -216,7 +216,7 @@ there is no different error message for that.
|
|||||||
Command not allowed from exrc/vimrc in current dir or tag search
|
Command not allowed from exrc/vimrc in current dir or tag search
|
||||||
|
|
||||||
Some commands are not allowed for security reasons. These commands mostly
|
Some commands are not allowed for security reasons. These commands mostly
|
||||||
come from a .exrc or .vimrc file in the current directory, or from a tags
|
come from a .exrc or .nvimrc file in the current directory, or from a tags
|
||||||
file. Also see 'secure'.
|
file. Also see 'secure'.
|
||||||
|
|
||||||
*E74* >
|
*E74* >
|
||||||
|
@@ -149,7 +149,7 @@ If you find a menu translation file for your language with a different name,
|
|||||||
create a file in your own runtime directory to load that one. The name of
|
create a file in your own runtime directory to load that one. The name of
|
||||||
that file could be: >
|
that file could be: >
|
||||||
|
|
||||||
~/.vim/lang/menu_<v:lang>.vim
|
~/.config/nvim/lang/menu_<v:lang>.vim
|
||||||
|
|
||||||
Check the 'runtimepath' option for directories which are searched. In that
|
Check the 'runtimepath' option for directories which are searched. In that
|
||||||
file put a command to load the menu file with the other name: >
|
file put a command to load the menu file with the other name: >
|
||||||
|
@@ -12,8 +12,9 @@ good.
|
|||||||
To start the transition, link your previous configuration so Nvim can use
|
To start the transition, link your previous configuration so Nvim can use
|
||||||
it:
|
it:
|
||||||
>
|
>
|
||||||
ln -s ~/.vimrc ~/.nvimrc
|
mkdir -p ${XDG_CONFIG_HOME:=$HOME/.config}
|
||||||
ln -s ~/.vim ~/.nvim
|
ln -s ~/.vim $XDG_CONFIG_HOME/nvim
|
||||||
|
ln -s ~/.vimrc $XDG_CONFIG_HOME/nvim/init.vim
|
||||||
<
|
<
|
||||||
See |nvim-intro|, especially |nvim-python| and |nvim-clipboard|, for
|
See |nvim-intro|, especially |nvim-python| and |nvim-clipboard|, for
|
||||||
additional software you might need to install to use all of Nvim's features.
|
additional software you might need to install to use all of Nvim's features.
|
||||||
|
@@ -775,12 +775,12 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
in other cases Vim might not be able to guess the right value.
|
in other cases Vim might not be able to guess the right value.
|
||||||
|
|
||||||
When starting the GUI, the default value for 'background' will be
|
When starting the GUI, the default value for 'background' will be
|
||||||
"light". When the value is not set in the .gvimrc, and Vim detects
|
"light". When the value is not set in the gvimrc, and Vim detects
|
||||||
that the background is actually quite dark, 'background' is set to
|
that the background is actually quite dark, 'background' is set to
|
||||||
"dark". But this happens only AFTER the .gvimrc file has been read
|
"dark". But this happens only AFTER the gvimrc file has been read
|
||||||
(because the window needs to be opened to find the actual background
|
(because the window needs to be opened to find the actual background
|
||||||
color). To get around this, force the GUI window to be opened by
|
color). To get around this, force the GUI window to be opened by
|
||||||
putting a ":gui" command in the .gvimrc file, before where the value
|
putting a ":gui" command in the gvimrc file, before where the value
|
||||||
of 'background' is used (e.g., before ":syntax on").
|
of 'background' is used (e.g., before ":syntax on").
|
||||||
|
|
||||||
For MS-DOS and Windows the default is "dark".
|
For MS-DOS and Windows the default is "dark".
|
||||||
@@ -788,7 +788,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
"screen.linux", "cygwin" or "putty", or $COLORFGBG suggests a dark
|
"screen.linux", "cygwin" or "putty", or $COLORFGBG suggests a dark
|
||||||
background. Otherwise the default is "light".
|
background. Otherwise the default is "light".
|
||||||
|
|
||||||
Normally this option would be set in the .vimrc file. Possibly
|
Normally this option would be set in the vimrc file. Possibly
|
||||||
depending on the terminal name. Example: >
|
depending on the terminal name. Example: >
|
||||||
:if &term == "pcterm"
|
:if &term == "pcterm"
|
||||||
: set background=dark
|
: set background=dark
|
||||||
@@ -901,8 +901,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
again not rename the file.
|
again not rename the file.
|
||||||
|
|
||||||
*'backupdir'* *'bdir'*
|
*'backupdir'* *'bdir'*
|
||||||
'backupdir' 'bdir' string (default for MS-DOS and Win32: ".,$TEMP,c:/tmp,c:/temp",
|
'backupdir' 'bdir' string (default "$XDG_DATA_HOME/nvim/backup")
|
||||||
for Unix: ".,~/tmp,~/")
|
|
||||||
global
|
global
|
||||||
List of directories for the backup file, separated with commas.
|
List of directories for the backup file, separated with commas.
|
||||||
- The backup file will be created in the first directory in the list
|
- The backup file will be created in the first directory in the list
|
||||||
@@ -1479,7 +1478,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
initialization and does not have to be set by hand.
|
initialization and does not have to be set by hand.
|
||||||
When Vim is running in the GUI or in a resizable window, setting this
|
When Vim is running in the GUI or in a resizable window, setting this
|
||||||
option will cause the window size to be changed. When you only want
|
option will cause the window size to be changed. When you only want
|
||||||
to use the size for the GUI, put the command in your |gvimrc| file.
|
to use the size for the GUI, put the command in your |ginit.vim| file.
|
||||||
When you set this option and Vim is unable to change the physical
|
When you set this option and Vim is unable to change the physical
|
||||||
number of columns of the display, the display may be messed up. For
|
number of columns of the display, the display may be messed up. For
|
||||||
the GUI it is always possible and Vim limits the number of columns to
|
the GUI it is always possible and Vim limits the number of columns to
|
||||||
@@ -2130,12 +2129,12 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
{char2}. See |digraphs|.
|
{char2}. See |digraphs|.
|
||||||
|
|
||||||
*'directory'* *'dir'*
|
*'directory'* *'dir'*
|
||||||
'directory' 'dir' string (default for MS-DOS and Win32: ".,$TEMP,c:\tmp,c:\temp",
|
'directory' 'dir' string (default "$XDG_DATA_HOME/nvim/swap//")
|
||||||
for Unix: ".,~/tmp,/var/tmp,/tmp")
|
|
||||||
global
|
global
|
||||||
List of directory names for the swap file, separated with commas.
|
List of directory names for the swap file, separated with commas.
|
||||||
- The swap file will be created in the first directory where this is
|
- The swap file will be created in the first directory where this is
|
||||||
possible.
|
possible. If it is not possible in any directory, but last
|
||||||
|
directory listed in the option does not exist, it is created.
|
||||||
- Empty means that no swap file will be used (recovery is
|
- Empty means that no swap file will be used (recovery is
|
||||||
impossible!).
|
impossible!).
|
||||||
- A directory "." means to put the swap file in the same directory as
|
- A directory "." means to put the swap file in the same directory as
|
||||||
@@ -2351,11 +2350,11 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
*'exrc'* *'ex'* *'noexrc'* *'noex'*
|
*'exrc'* *'ex'* *'noexrc'* *'noex'*
|
||||||
'exrc' 'ex' boolean (default off)
|
'exrc' 'ex' boolean (default off)
|
||||||
global
|
global
|
||||||
Enables the reading of .vimrc, .exrc and .gvimrc in the current
|
Enables the reading of .nvimrc, .exrc and .ngvimrc in the current
|
||||||
directory. If you switch this option on you should also consider
|
directory. If you switch this option on you should also consider
|
||||||
setting the 'secure' option (see |initialization|). Using a local
|
setting the 'secure' option (see |initialization|). Using a local
|
||||||
.exrc, .vimrc or .gvimrc is a potential security leak, use with care!
|
.exrc, .nvimrc or .ngvimrc is a potential security leak, use with care!
|
||||||
also see |.vimrc| and |gui-init|.
|
also see |init.vim| and |gui-init|.
|
||||||
This option cannot be set from a |modeline| or in the |sandbox|, for
|
This option cannot be set from a |modeline| or in the |sandbox|, for
|
||||||
security reasons.
|
security reasons.
|
||||||
|
|
||||||
@@ -2531,7 +2530,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
When 'binary' is set, the value of 'fileformats' is not used.
|
When 'binary' is set, the value of 'fileformats' is not used.
|
||||||
|
|
||||||
Note that when Vim starts up with an empty buffer this option is not
|
Note that when Vim starts up with an empty buffer this option is not
|
||||||
used. Set 'fileformat' in your .vimrc instead.
|
used. Set 'fileformat' in your vimrc instead.
|
||||||
|
|
||||||
For systems with a Dos-like <EOL> (<CR><NL>), when reading files that
|
For systems with a Dos-like <EOL> (<CR><NL>), when reading files that
|
||||||
are ":source"ed and for vimrc files, automatic <EOL> detection may be
|
are ":source"ed and for vimrc files, automatic <EOL> detection may be
|
||||||
@@ -3211,7 +3210,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
'm' Menu bar is present.
|
'm' Menu bar is present.
|
||||||
*'go-M'*
|
*'go-M'*
|
||||||
'M' The system menu "$VIMRUNTIME/menu.vim" is not sourced. Note
|
'M' The system menu "$VIMRUNTIME/menu.vim" is not sourced. Note
|
||||||
that this flag must be added in the .vimrc file, before
|
that this flag must be added in the vimrc file, before
|
||||||
switching on syntax or filetype recognition (when the |gvimrc|
|
switching on syntax or filetype recognition (when the |gvimrc|
|
||||||
file is sourced the system menu has already been loaded; the
|
file is sourced the system menu has already been loaded; the
|
||||||
":syntax on" and ":filetype on" commands load the menu too).
|
":syntax on" and ":filetype on" commands load the menu too).
|
||||||
@@ -3835,8 +3834,8 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
option.
|
option.
|
||||||
Careful: If you change this option, it might break expanding
|
Careful: If you change this option, it might break expanding
|
||||||
environment variables. E.g., when '/' is included and Vim tries to
|
environment variables. E.g., when '/' is included and Vim tries to
|
||||||
expand "$HOME/.nvim/shada/main.shada". Maybe you should change
|
expand "$HOME/.local/share/nvim/shada/main.shada". Maybe you should
|
||||||
'iskeyword' instead.
|
change 'iskeyword' instead.
|
||||||
|
|
||||||
*'iskeyword'* *'isk'*
|
*'iskeyword'* *'isk'*
|
||||||
'iskeyword' 'isk' string (Vim default for
|
'iskeyword' 'isk' string (Vim default for
|
||||||
@@ -4670,7 +4669,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
being set. The same is true for a terminal where Vim handles the
|
being set. The same is true for a terminal where Vim handles the
|
||||||
mouse clicks itself.
|
mouse clicks itself.
|
||||||
This option is reset when starting the GUI. Thus if you set it in
|
This option is reset when starting the GUI. Thus if you set it in
|
||||||
your .vimrc it will work in a terminal, but not in the GUI. Setting
|
your vimrc it will work in a terminal, but not in the GUI. Setting
|
||||||
'paste' in the GUI has side effects: e.g., the Paste toolbar button
|
'paste' in the GUI has side effects: e.g., the Paste toolbar button
|
||||||
will no longer work in Insert mode, because it uses a mapping.
|
will no longer work in Insert mode, because it uses a mapping.
|
||||||
When the 'paste' option is switched on (also when it was already on):
|
When the 'paste' option is switched on (also when it was already on):
|
||||||
@@ -5010,7 +5009,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
happens when executing external commands.
|
happens when executing external commands.
|
||||||
|
|
||||||
For non-Windows Vim: You can set or reset the 't_ti' and 't_te'
|
For non-Windows Vim: You can set or reset the 't_ti' and 't_te'
|
||||||
options in your .vimrc. To disable restoring:
|
options in your vimrc. To disable restoring:
|
||||||
set t_ti= t_te=
|
set t_ti= t_te=
|
||||||
To enable restoring (for an xterm):
|
To enable restoring (for an xterm):
|
||||||
set t_ti=^[7^[[r^[[?47h t_te=^[[?47l^[8
|
set t_ti=^[7^[[r^[[?47h t_te=^[[?47l^[8
|
||||||
@@ -5090,14 +5089,23 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
<
|
<
|
||||||
*'runtimepath'* *'rtp'* *vimfiles*
|
*'runtimepath'* *'rtp'* *vimfiles*
|
||||||
'runtimepath' 'rtp' string (default:
|
'runtimepath' 'rtp' string (default:
|
||||||
Unix: "$HOME/.vim,
|
Unix: "$XDG_CONFIG_HOME/nvim,
|
||||||
$VIM/vimfiles,
|
$XDG_CONFIG_DIRS[1]/nvim,
|
||||||
$VIMRUNTIME,
|
$XDG_CONFIG_DIRS[2]/nvim,
|
||||||
$VIM/vimfiles/after,
|
…
|
||||||
$HOME/.vim/after"
|
$XDG_DATA_HOME/nvim,
|
||||||
Macintosh: "$VIM:vimfiles,
|
$XDG_DATA_DIRS[1]/nvim/site,
|
||||||
$VIMRUNTIME,
|
$XDG_DATA_DIRS[2]/nvim/site,
|
||||||
$VIM:vimfiles:after")
|
…
|
||||||
|
$VIMRUNTIME,
|
||||||
|
…
|
||||||
|
$XDG_DATA_DIRS[2]/nvim/site/after,
|
||||||
|
$XDG_DATA_DIRS[1]/nvim/site/after,
|
||||||
|
$XDG_DATA_HOME/nvim/after,
|
||||||
|
…
|
||||||
|
$XDG_CONFIG_DIRS[2]/nvim/after,
|
||||||
|
$XDG_CONFIG_DIRS[1]/nvim/after,
|
||||||
|
$XDG_CONFIG_HOME/nvim/after")
|
||||||
global
|
global
|
||||||
This is a list of directories which will be searched for runtime
|
This is a list of directories which will be searched for runtime
|
||||||
files:
|
files:
|
||||||
@@ -5120,18 +5128,23 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
|
|
||||||
And any other file searched for with the |:runtime| command.
|
And any other file searched for with the |:runtime| command.
|
||||||
|
|
||||||
The defaults for most systems are setup to search five locations:
|
The defaults for most systems are setup to search these locations:
|
||||||
1. In your home directory, for your personal preferences.
|
1. In your home directory (XDG_CONFIG_HOME defaults to $HOME/.config),
|
||||||
2. In a system-wide Vim directory, for preferences from the system
|
for your personal preferences.
|
||||||
administrator.
|
2. In directories which must contain configuration files according to
|
||||||
3. In $VIMRUNTIME, for files distributed with Vim.
|
XDG ($XDG_CONFIG_DIRS). This also contains preferences from system
|
||||||
|
administrator (XDG_CONFIG_DIRS defaults to /etc/xdg).
|
||||||
|
3. In data home directory, for plugins installed by user.
|
||||||
|
4. In nvim/site subdirectories for each directory in $XDG_DATA_DIRS.
|
||||||
|
This is for plugins which were installed by system administrator,
|
||||||
|
but are not part of the Neovim distribution. XDG_DATA_DIRS defaults
|
||||||
|
to /usr/local/share/:/usr/share/, so system administrators are
|
||||||
|
expected to install site plugins to /usr/share/nvim/site.
|
||||||
|
5. In $VIMRUNTIME, for files distributed with Neovim.
|
||||||
*after-directory*
|
*after-directory*
|
||||||
4. In the "after" directory in the system-wide Vim directory. This is
|
6, 7, 8, 9. In after/ subdirectories of 1, 2, 3 and 4, with reverse
|
||||||
for the system administrator to overrule or add to the distributed
|
ordering. This is for preferences to overrule or add to the
|
||||||
defaults (rarely needed)
|
distributed defaults or system-wide settings (rarely needed).
|
||||||
5. In the "after" directory in your home directory. This is for
|
|
||||||
personal preferences to overrule or add to the distributed defaults
|
|
||||||
or system-wide settings (rarely needed).
|
|
||||||
|
|
||||||
Note that, unlike 'path', no wildcards like "**" are allowed. Normal
|
Note that, unlike 'path', no wildcards like "**" are allowed. Normal
|
||||||
wildcards are allowed, but can significantly slow down searching for
|
wildcards are allowed, but can significantly slow down searching for
|
||||||
@@ -5240,12 +5253,12 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
'secure' boolean (default off)
|
'secure' boolean (default off)
|
||||||
global
|
global
|
||||||
When on, ":autocmd", shell and write commands are not allowed in
|
When on, ":autocmd", shell and write commands are not allowed in
|
||||||
".vimrc" and ".exrc" in the current directory and map commands are
|
".nvimrc" and ".exrc" in the current directory and map commands are
|
||||||
displayed. Switch it off only if you know that you will not run into
|
displayed. Switch it off only if you know that you will not run into
|
||||||
problems, or when the 'exrc' option is off. On Unix this option is
|
problems, or when the 'exrc' option is off. On Unix this option is
|
||||||
only used if the ".vimrc" or ".exrc" is not owned by you. This can be
|
only used if the ".nvimrc" or ".exrc" is not owned by you. This can be
|
||||||
dangerous if the systems allows users to do a "chown". You better set
|
dangerous if the systems allows users to do a "chown". You better set
|
||||||
'secure' at the end of your ~/.vimrc then.
|
'secure' at the end of your |init.vim| then.
|
||||||
This option cannot be set from a |modeline| or in the |sandbox|, for
|
This option cannot be set from a |modeline| or in the |sandbox|, for
|
||||||
security reasons.
|
security reasons.
|
||||||
|
|
||||||
@@ -5502,7 +5515,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
default becomes "2>&1| tee". This means that stderr is also included.
|
default becomes "2>&1| tee". This means that stderr is also included.
|
||||||
Before using the 'shell' option a path is removed, thus "/bin/sh" uses
|
Before using the 'shell' option a path is removed, thus "/bin/sh" uses
|
||||||
"sh".
|
"sh".
|
||||||
The initialization of this option is done after reading the ".vimrc"
|
The initialization of this option is done after reading the vimrc
|
||||||
and the other initializations, so that when the 'shell' option is set
|
and the other initializations, so that when the 'shell' option is set
|
||||||
there, the 'shellpipe' option changes automatically, unless it was
|
there, the 'shellpipe' option changes automatically, unless it was
|
||||||
explicitly set before.
|
explicitly set before.
|
||||||
@@ -5548,7 +5561,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
For Win32, the Unix checks are done and additionally "cmd" is checked
|
For Win32, the Unix checks are done and additionally "cmd" is checked
|
||||||
for, which makes the default ">%s 2>&1". Also, the same names with
|
for, which makes the default ">%s 2>&1". Also, the same names with
|
||||||
".exe" appended are checked for.
|
".exe" appended are checked for.
|
||||||
The initialization of this option is done after reading the ".vimrc"
|
The initialization of this option is done after reading the vimrc
|
||||||
and the other initializations, so that when the 'shell' option is set
|
and the other initializations, so that when the 'shell' option is set
|
||||||
there, the 'shellredir' option changes automatically unless it was
|
there, the 'shellredir' option changes automatically unless it was
|
||||||
explicitly set before.
|
explicitly set before.
|
||||||
@@ -6023,7 +6036,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
|
|
||||||
Only one of "best", "double" or "fast" may be used. The others may
|
Only one of "best", "double" or "fast" may be used. The others may
|
||||||
appear several times in any order. Example: >
|
appear several times in any order. Example: >
|
||||||
:set sps=file:~/.vim/sugg,best,expr:MySuggest()
|
:set sps=file:~/.config/nvim/sugg,best,expr:MySuggest()
|
||||||
<
|
<
|
||||||
This option cannot be set from a |modeline| or in the |sandbox|, for
|
This option cannot be set from a |modeline| or in the |sandbox|, for
|
||||||
security reasons.
|
security reasons.
|
||||||
@@ -6198,7 +6211,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
|
|
||||||
Watch out for errors in expressions. They may render Vim unusable!
|
Watch out for errors in expressions. They may render Vim unusable!
|
||||||
If you are stuck, hold down ':' or 'Q' to get a prompt, then quit and
|
If you are stuck, hold down ':' or 'Q' to get a prompt, then quit and
|
||||||
edit your .vimrc or whatever with "vim -u NONE" to get it right.
|
edit your vimrc or whatever with "vim -u NONE" to get it right.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
Emulate standard status line with 'ruler' set >
|
Emulate standard status line with 'ruler' set >
|
||||||
@@ -6804,8 +6817,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
displayed when 'verbosefile' is set.
|
displayed when 'verbosefile' is set.
|
||||||
|
|
||||||
*'viewdir'* *'vdir'*
|
*'viewdir'* *'vdir'*
|
||||||
'viewdir' 'vdir' string (default for MS-DOS and Win32: "$VIM/vimfiles/view",
|
'viewdir' 'vdir' string (default: "$XDG_DATA_HOME/nvim/view")
|
||||||
for Unix: "~/.vim/view")
|
|
||||||
global
|
global
|
||||||
{not available when compiled without the |+mksession|
|
{not available when compiled without the |+mksession|
|
||||||
feature}
|
feature}
|
||||||
|
@@ -40,7 +40,7 @@ Setting a map *spec-setting-a-map*
|
|||||||
As you should know, you can easily set a map to access any Vim command (or
|
As you should know, you can easily set a map to access any Vim command (or
|
||||||
anything, for that matter). If you don't like the default map of
|
anything, for that matter). If you don't like the default map of
|
||||||
<LocalLeader>c, you may just set up your own key. The following line
|
<LocalLeader>c, you may just set up your own key. The following line
|
||||||
shows you how you could do this in your .vimrc file, mapping the plugin to
|
shows you how you could do this in your vimrc file, mapping the plugin to
|
||||||
the <F5> key:
|
the <F5> key:
|
||||||
|
|
||||||
au FileType spec map <buffer> <F5> <Plug>SpecChangelog
|
au FileType spec map <buffer> <F5> <Plug>SpecChangelog
|
||||||
@@ -58,7 +58,7 @@ The format string *spec_chglog_format*
|
|||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
You can easily customize how your spec file entry will look like. To do
|
You can easily customize how your spec file entry will look like. To do
|
||||||
this just set the variable "spec_chglog_format" in your .vimrc file like
|
this just set the variable "spec_chglog_format" in your vimrc file like
|
||||||
this: >
|
this: >
|
||||||
|
|
||||||
let spec_chglog_format = "%a %b %d %Y My Name <my@email.com>"
|
let spec_chglog_format = "%a %b %d %Y My Name <my@email.com>"
|
||||||
@@ -92,7 +92,7 @@ that it may control if the release has been updated after the last
|
|||||||
change in the package or not. If you have not updated the package
|
change in the package or not. If you have not updated the package
|
||||||
version or release, it will ask you if it should update the package
|
version or release, it will ask you if it should update the package
|
||||||
release for you. To turn this feature on, just insert the following
|
release for you. To turn this feature on, just insert the following
|
||||||
code in your .vimrc: >
|
code in your vimrc: >
|
||||||
|
|
||||||
let spec_chglog_release_info = 1
|
let spec_chglog_release_info = 1
|
||||||
|
|
||||||
|
@@ -133,15 +133,17 @@ If there is no error, return zero or an empty string.
|
|||||||
The default for non MS-Windows systems is to simply use "lpr" to print the
|
The default for non MS-Windows systems is to simply use "lpr" to print the
|
||||||
file: >
|
file: >
|
||||||
|
|
||||||
system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice)
|
system(['lpr']
|
||||||
. ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error
|
+ (empty(&printdevice)?[]:['-P', &printdevice])
|
||||||
|
+ [v:fname_in])
|
||||||
|
. delete(v:fname_in)
|
||||||
|
+ v:shell_error
|
||||||
|
|
||||||
On MS-Dos and MS-Windows machines the default is to copy the file to the
|
On MS-Dos and MS-Windows machines the default is to copy the file to the
|
||||||
currently specified printdevice: >
|
currently specified printdevice: >
|
||||||
|
|
||||||
system('copy' . ' ' . v:fname_in . (&printdevice == ''
|
system(['copy', v:fname_in, empty(&printdevice)?'LPT1':&printdevice])
|
||||||
? ' LPT1:' : (' \"' . &printdevice . '\"')))
|
. delete(v:fname_in)
|
||||||
. delete(v:fname_in)
|
|
||||||
|
|
||||||
If you change this option, using a function is an easy way to avoid having to
|
If you change this option, using a function is an easy way to avoid having to
|
||||||
escape all the spaces. Example: >
|
escape all the spaces. Example: >
|
||||||
|
@@ -1277,7 +1277,7 @@ Jikes(TM), a source-to-bytecode Java compiler published by IBM Research,
|
|||||||
produces simple multi-line error messages.
|
produces simple multi-line error messages.
|
||||||
|
|
||||||
An 'errorformat' string matching the produced messages is shown below.
|
An 'errorformat' string matching the produced messages is shown below.
|
||||||
The following lines can be placed in the user's |vimrc| to overwrite Vim's
|
The following lines can be placed in the user's |init.vim| to overwrite Vim's
|
||||||
recognized default formats, or see |:set+=| how to install this format
|
recognized default formats, or see |:set+=| how to install this format
|
||||||
additionally to the default. >
|
additionally to the default. >
|
||||||
|
|
||||||
|
@@ -548,7 +548,7 @@ In Insert or Command-line mode:
|
|||||||
settings to [file] (default: ".exrc";
|
settings to [file] (default: ".exrc";
|
||||||
use ! to overwrite)
|
use ! to overwrite)
|
||||||
|:mkvimrc| :mkv[imrc][!] [file]
|
|:mkvimrc| :mkv[imrc][!] [file]
|
||||||
same as ":mkexrc", but with default ".vimrc"
|
same as :mkexrc, but with default ".nvimrc"
|
||||||
|:mksession| :mks[ession][!] [file]
|
|:mksession| :mks[ession][!] [file]
|
||||||
like ":mkvimrc", but store current files,
|
like ":mkvimrc", but store current files,
|
||||||
windows, etc. too, to be able to continue
|
windows, etc. too, to be able to continue
|
||||||
@@ -681,7 +681,7 @@ Short explanation of each option: *option-list*
|
|||||||
'esckeys' 'ek' recognize function keys in Insert mode
|
'esckeys' 'ek' recognize function keys in Insert mode
|
||||||
'eventignore' 'ei' autocommand events that are ignored
|
'eventignore' 'ei' autocommand events that are ignored
|
||||||
'expandtab' 'et' use spaces when <Tab> is inserted
|
'expandtab' 'et' use spaces when <Tab> is inserted
|
||||||
'exrc' 'ex' read .vimrc and .exrc in the current directory
|
'exrc' 'ex' read .nvimrc and .exrc in the current directory
|
||||||
'fileencoding' 'fenc' file encoding for multi-byte text
|
'fileencoding' 'fenc' file encoding for multi-byte text
|
||||||
'fileencodings' 'fencs' automatically detected character encodings
|
'fileencodings' 'fencs' automatically detected character encodings
|
||||||
'fileformat' 'ff' file format used for file I/O
|
'fileformat' 'ff' file format used for file I/O
|
||||||
|
@@ -204,7 +204,7 @@ Colon, USA)
|
|||||||
VIM is a joy to use, it is so well thought and practical that I wonder why
|
VIM is a joy to use, it is so well thought and practical that I wonder why
|
||||||
anybody would use visual development tools. VIM is powerful and elegant, it
|
anybody would use visual development tools. VIM is powerful and elegant, it
|
||||||
looks deceptively simple but is almost as complex as a 747 (especially when I
|
looks deceptively simple but is almost as complex as a 747 (especially when I
|
||||||
look at my growing .vimrc), keep up that wonderful job, VIM is a centerpiece
|
look at my growing vimrc), keep up that wonderful job, VIM is a centerpiece
|
||||||
of the free software world. (Louis-David Mitterand, USA)
|
of the free software world. (Louis-David Mitterand, USA)
|
||||||
|
|
||||||
I cannot believe how great it is to use VIM. I think the guys at work are
|
I cannot believe how great it is to use VIM. I think the guys at work are
|
||||||
|
@@ -58,7 +58,7 @@ Disadvantages:
|
|||||||
message.
|
message.
|
||||||
|
|
||||||
If you want to put swap files in a fixed place, put a command resembling the
|
If you want to put swap files in a fixed place, put a command resembling the
|
||||||
following ones in your .vimrc:
|
following ones in your vimrc:
|
||||||
:set dir=~/tmp (for Unix)
|
:set dir=~/tmp (for Unix)
|
||||||
:set dir=c:\\tmp (for MS-DOS and Win32)
|
:set dir=c:\\tmp (for MS-DOS and Win32)
|
||||||
This is also very handy when editing files on floppy. Of course you will have
|
This is also very handy when editing files on floppy. Of course you will have
|
||||||
|
@@ -93,8 +93,9 @@ approach with |rpcnotify()|, meaning return values or exceptions raised in the
|
|||||||
handler function are ignored.
|
handler function are ignored.
|
||||||
|
|
||||||
To test the above plugin, it must be saved in "rplugin/python" in a
|
To test the above plugin, it must be saved in "rplugin/python" in a
|
||||||
'runtimepath' directory (~/.nvim/rplugin/python/limit.py for example). Then,
|
'runtimepath' directory (~/.config/nvim/rplugin/python/limit.py for example).
|
||||||
the remote plugin manifest must be generated with `:UpdateRemotePlugins`.
|
Then, the remote plugin manifest must be generated with
|
||||||
|
`:UpdateRemotePlugins`.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
4. Remote plugin manifest *remote-plugin-manifest*
|
4. Remote plugin manifest *remote-plugin-manifest*
|
||||||
|
@@ -274,8 +274,8 @@ nested as deep as the number of files that can be opened at one time (about
|
|||||||
You can use the "<sfile>" string (literally, this is not a special key) inside
|
You can use the "<sfile>" string (literally, this is not a special key) inside
|
||||||
of the sourced file, in places where a file name is expected. It will be
|
of the sourced file, in places where a file name is expected. It will be
|
||||||
replaced by the file name of the sourced file. For example, if you have a
|
replaced by the file name of the sourced file. For example, if you have a
|
||||||
"other.vimrc" file in the same directory as your ".vimrc" file, you can source
|
"other.vimrc" file in the same directory as your |init.vim| file, you can
|
||||||
it from your ".vimrc" file with this command: >
|
source it from your |init.vim| file with this command: >
|
||||||
:source <sfile>:h/other.vimrc
|
:source <sfile>:h/other.vimrc
|
||||||
|
|
||||||
In script files terminal-dependent key codes are represented by
|
In script files terminal-dependent key codes are represented by
|
||||||
@@ -482,7 +482,7 @@ DEFINING BREAKPOINTS
|
|||||||
|
|
||||||
:breaka[dd] file [lnum] {name}
|
:breaka[dd] file [lnum] {name}
|
||||||
Set a breakpoint in a sourced file. Example: >
|
Set a breakpoint in a sourced file. Example: >
|
||||||
:breakadd file 43 .vimrc
|
:breakadd file 43 init.vim
|
||||||
|
|
||||||
:breaka[dd] here
|
:breaka[dd] here
|
||||||
Set a breakpoint in the current line of the current file.
|
Set a breakpoint in the current line of the current file.
|
||||||
|
@@ -307,26 +307,26 @@ Exceptions:
|
|||||||
spell file is used.
|
spell file is used.
|
||||||
|
|
||||||
For example, with these values:
|
For example, with these values:
|
||||||
'runtimepath' is "~/.vim,/usr/share/vim70,~/.vim/after"
|
'runtimepath' is "~/.config/nvim,/usr/share/vim70,~/.config/nvim/after"
|
||||||
'encoding' is "iso-8859-2"
|
'encoding' is "iso-8859-2"
|
||||||
'spelllang' is "pl"
|
'spelllang' is "pl"
|
||||||
|
|
||||||
Vim will look for:
|
Vim will look for:
|
||||||
1. ~/.vim/spell/pl.iso-8859-2.spl
|
1. ~/.config/nvim/spell/pl.iso-8859-2.spl
|
||||||
2. /usr/share/vim70/spell/pl.iso-8859-2.spl
|
2. /usr/share/vim70/spell/pl.iso-8859-2.spl
|
||||||
3. ~/.vim/spell/pl.iso-8859-2.add.spl
|
3. ~/.config/nvim/spell/pl.iso-8859-2.add.spl
|
||||||
4. /usr/share/vim70/spell/pl.iso-8859-2.add.spl
|
4. /usr/share/vim70/spell/pl.iso-8859-2.add.spl
|
||||||
5. ~/.vim/after/spell/pl.iso-8859-2.add.spl
|
5. ~/.config/nvim/after/spell/pl.iso-8859-2.add.spl
|
||||||
|
|
||||||
This assumes 1. is not found and 2. is found.
|
This assumes 1. is not found and 2. is found.
|
||||||
|
|
||||||
If 'encoding' is "latin1" Vim will look for:
|
If 'encoding' is "latin1" Vim will look for:
|
||||||
1. ~/.vim/spell/pl.latin1.spl
|
1. ~/.config/nvim/spell/pl.latin1.spl
|
||||||
2. /usr/share/vim70/spell/pl.latin1.spl
|
2. /usr/share/vim70/spell/pl.latin1.spl
|
||||||
3. ~/.vim/after/spell/pl.latin1.spl
|
3. ~/.config/nvim/after/spell/pl.latin1.spl
|
||||||
4. ~/.vim/spell/pl.ascii.spl
|
4. ~/.config/nvim/spell/pl.ascii.spl
|
||||||
5. /usr/share/vim70/spell/pl.ascii.spl
|
5. /usr/share/vim70/spell/pl.ascii.spl
|
||||||
6. ~/.vim/after/spell/pl.ascii.spl
|
6. ~/.config/nvim/after/spell/pl.ascii.spl
|
||||||
|
|
||||||
This assumes none of them are found (Polish doesn't make sense when leaving
|
This assumes none of them are found (Polish doesn't make sense when leaving
|
||||||
out the non-ASCII characters).
|
out the non-ASCII characters).
|
||||||
|
@@ -106,7 +106,7 @@ argument.
|
|||||||
--startuptime {fname} *--startuptime*
|
--startuptime {fname} *--startuptime*
|
||||||
During startup write timing messages to the file {fname}.
|
During startup write timing messages to the file {fname}.
|
||||||
This can be used to find out where time is spent while loading
|
This can be used to find out where time is spent while loading
|
||||||
your .vimrc, plugins and opening the first file.
|
your |init.vim|, plugins and opening the first file.
|
||||||
When {fname} already exists new messages are appended.
|
When {fname} already exists new messages are appended.
|
||||||
(Only available when compiled with the |+startuptime|
|
(Only available when compiled with the |+startuptime|
|
||||||
feature).
|
feature).
|
||||||
@@ -232,8 +232,8 @@ argument.
|
|||||||
-b Binary mode. File I/O will only recognize <NL> to separate
|
-b Binary mode. File I/O will only recognize <NL> to separate
|
||||||
lines. The 'expandtab' option will be reset. The 'textwidth'
|
lines. The 'expandtab' option will be reset. The 'textwidth'
|
||||||
option is set to 0. 'modeline' is reset. The 'binary' option
|
option is set to 0. 'modeline' is reset. The 'binary' option
|
||||||
is set. This is done after reading the vimrc/exrc files but
|
is set. This is done after reading the init.vim/exrc files
|
||||||
before reading any file in the arglist. See also
|
but before reading any file in the arglist. See also
|
||||||
|edit-binary|.
|
|edit-binary|.
|
||||||
|
|
||||||
*-l*
|
*-l*
|
||||||
@@ -312,11 +312,11 @@ argument.
|
|||||||
be used to start Vim in a special mode, with special
|
be used to start Vim in a special mode, with special
|
||||||
mappings and settings. A shell alias can be used to make
|
mappings and settings. A shell alias can be used to make
|
||||||
this easy to use. For example: >
|
this easy to use. For example: >
|
||||||
alias vimc vim -u ~/.c_vimrc !*
|
alias vimc vim -u ~/.config/nvim/c_init.vim !*
|
||||||
< Also consider using autocommands; see |autocommand|.
|
< Also consider using autocommands; see |autocommand|.
|
||||||
When {vimrc} is equal to "NONE" (all uppercase), all
|
When {vimrc} is equal to "NONE" (all uppercase), all
|
||||||
initializations from files and environment variables are
|
initializations from files and environment variables are
|
||||||
skipped, including reading the |gvimrc| file when the GUI
|
skipped, including reading the |ginit.vim| file when the GUI
|
||||||
starts. Loading plugins is also skipped.
|
starts. Loading plugins is also skipped.
|
||||||
When {vimrc} is equal to "NORC" (all uppercase), this has the
|
When {vimrc} is equal to "NORC" (all uppercase), this has the
|
||||||
same effect as "NONE", but loading plugins is not skipped.
|
same effect as "NONE", but loading plugins is not skipped.
|
||||||
@@ -373,24 +373,24 @@ accordingly. Vim proceeds in this order:
|
|||||||
3. Execute Ex commands, from environment variables and/or files
|
3. Execute Ex commands, from environment variables and/or files
|
||||||
An environment variable is read as one Ex command line, where multiple
|
An environment variable is read as one Ex command line, where multiple
|
||||||
commands must be separated with '|' or "<NL>".
|
commands must be separated with '|' or "<NL>".
|
||||||
*vimrc* *exrc*
|
*init.vim* *vimrc* *exrc*
|
||||||
A file that contains initialization commands is called a "vimrc" file.
|
A file that contains initialization commands is called a "vimrc" file.
|
||||||
Each line in a vimrc file is executed as an Ex command line. It is
|
Each line in a vimrc file is executed as an Ex command line. It is
|
||||||
sometimes also referred to as "exrc" file. They are the same type of
|
sometimes also referred to as "exrc" file. They are the same type of
|
||||||
file, but "exrc" is what Vi always used, "vimrc" is a Vim specific
|
file, but "exrc" is what Vi always used, "vimrc" is a Vim specific
|
||||||
name. Also see |vimrc-intro|.
|
name, "init.vim" is Neovim specific location for vimrc file. Also see
|
||||||
|
|vimrc-intro|.
|
||||||
|
|
||||||
Places for your personal initializations:
|
Places for your personal initializations:
|
||||||
Unix $HOME/.vimrc or $HOME/.vim/vimrc
|
Unix $XDG_CONFIG_HOME/nvim/init.vim
|
||||||
MS-Windows $HOME/_vimrc, $HOME/vimfiles/vimrc
|
(default for $XDG_CONFIG_HOME is ~/.config)
|
||||||
or $VIM/_vimrc
|
|
||||||
|
|
||||||
The files are searched in the order specified above and only the first
|
The files are searched in the order specified above and only the first
|
||||||
one that is found is read.
|
one that is found is read.
|
||||||
|
|
||||||
RECOMMENDATION: Put all your Vim configuration stuff in the
|
RECOMMENDATION: Put all your Vim configuration stuff in the
|
||||||
$HOME/.vim/ directory ($HOME/vimfiles/ for MS-Windows). That makes it
|
$HOME/.config/nvim/ directory. That makes it easy to copy it to
|
||||||
easy to copy it to another system.
|
another system.
|
||||||
|
|
||||||
If Vim was started with "-u filename", the file "filename" is used.
|
If Vim was started with "-u filename", the file "filename" is used.
|
||||||
All following initializations until 4. are skipped. $MYVIMRC is not
|
All following initializations until 4. are skipped. $MYVIMRC is not
|
||||||
@@ -407,39 +407,26 @@ accordingly. Vim proceeds in this order:
|
|||||||
":version" command. Mostly it's "$VIM/vimrc".
|
":version" command. Mostly it's "$VIM/vimrc".
|
||||||
For the Macintosh the $VIMRUNTIME/macmap.vim is read.
|
For the Macintosh the $VIMRUNTIME/macmap.vim is read.
|
||||||
|
|
||||||
*VIMINIT* *.vimrc* *_vimrc* *EXINIT* *.exrc* *_exrc* *$MYVIMRC*
|
*VIMINIT* *EXINIT* *$MYVIMRC*
|
||||||
b. Four places are searched for initializations. The first that exists
|
b. Four places are searched for initializations. The first that exists
|
||||||
is used, the others are ignored. The $MYVIMRC environment variable is
|
is used, the others are ignored. The $MYVIMRC environment variable is
|
||||||
set to the file that was first found, unless $MYVIMRC was already set
|
set to the file that was first found, unless $MYVIMRC was already set
|
||||||
and when using VIMINIT.
|
and when using VIMINIT.
|
||||||
- The environment variable VIMINIT
|
- The environment variable VIMINIT
|
||||||
The value of $VIMINIT is used as an Ex command line.
|
The value of $VIMINIT is used as an Ex command line.
|
||||||
- The user vimrc file(s):
|
- The user vimrc file: $XDG_CONFIG_HOME/nvim/init.vim.
|
||||||
"$HOME/.vimrc" (for Unix)
|
- Other vimrc file: {xdg_config_dir}/nvim/init.vim where
|
||||||
"$HOME/.vim/vimrc" (for Unix)
|
{xdg_config_dir} is one of the directories in $XDG_CONFIG_DIRS.
|
||||||
"$HOME/_vimrc" (for Win32)
|
|
||||||
"$HOME/vimfiles/vimrc" (for Win32)
|
|
||||||
"$VIM/_vimrc" (for Win32)
|
|
||||||
Note: For Unix, when ".vimrc" does not exist,
|
|
||||||
"_vimrc" is also tried, in case an MS-DOS compatible file
|
|
||||||
system is used. For MS-DOS and Win32 ".vimrc" is checked
|
|
||||||
after "_vimrc", in case long file names are used.
|
|
||||||
Note: For MS-DOS and Win32, "$HOME" is checked first. If no
|
|
||||||
"_vimrc" or ".vimrc" is found there, "$VIM" is tried.
|
|
||||||
See |$VIM| for when $VIM is not set.
|
|
||||||
- The environment variable EXINIT.
|
- The environment variable EXINIT.
|
||||||
The value of $EXINIT is used as an Ex command line.
|
The value of $EXINIT is used as an Ex command line.
|
||||||
- The user exrc file(s). Same as for the user vimrc file, but with
|
|
||||||
"vimrc" replaced by "exrc". But only one of ".exrc" and "_exrc" is
|
|
||||||
used, depending on the system.
|
|
||||||
|
|
||||||
c. If the 'exrc' option is on (which is not the default), the current
|
c. If the 'exrc' option is on (which is not the default), the current
|
||||||
directory is searched for three files. The first that exists is used,
|
directory is searched for three files. The first that exists is used,
|
||||||
the others are ignored.
|
the others are ignored.
|
||||||
- The file ".vimrc" (for Unix)
|
- The file ".nvimrc" (for Unix)
|
||||||
"_vimrc" (for Win32)
|
"_nvimrc" (for Win32)
|
||||||
- The file "_vimrc" (for Unix)
|
- The file "_nvimrc" (for Unix)
|
||||||
".vimrc" (for Win32)
|
".nvimrc" (for Win32)
|
||||||
- The file ".exrc" (for Unix)
|
- The file ".exrc" (for Unix)
|
||||||
"_exrc" (for Win32)
|
"_exrc" (for Win32)
|
||||||
|
|
||||||
@@ -504,12 +491,12 @@ Some hints on using initializations:
|
|||||||
Standard setup:
|
Standard setup:
|
||||||
Create a vimrc file to set the default settings and mappings for all your edit
|
Create a vimrc file to set the default settings and mappings for all your edit
|
||||||
sessions. Put it in a place so that it will be found by 3b:
|
sessions. Put it in a place so that it will be found by 3b:
|
||||||
~/.vimrc (Unix)
|
~/.config/nvim/init.vim (Unix)
|
||||||
$VIM\_vimrc (MS-DOS and Win32)
|
~/AppData/Local/nvim/init.vim (Win32)
|
||||||
|
|
||||||
Local setup:
|
Local setup:
|
||||||
Put all commands that you need for editing a specific directory only into a
|
Put all commands that you need for editing a specific directory only into a
|
||||||
vimrc file and place it in that directory under the name ".vimrc" ("_vimrc"
|
vimrc file and place it in that directory under the name ".nvimrc" ("_nvimrc"
|
||||||
for MS-DOS and Win32). NOTE: To make Vim look for these special files you
|
for MS-DOS and Win32). NOTE: To make Vim look for these special files you
|
||||||
have to turn on the option 'exrc'. See |trojan-horse| too.
|
have to turn on the option 'exrc'. See |trojan-horse| too.
|
||||||
|
|
||||||
@@ -517,7 +504,9 @@ System setup:
|
|||||||
This only applies if you are managing a Unix system with several users and
|
This only applies if you are managing a Unix system with several users and
|
||||||
want to set the defaults for all users. Create a vimrc file with commands
|
want to set the defaults for all users. Create a vimrc file with commands
|
||||||
for default settings and mappings and put it in the place that is given with
|
for default settings and mappings and put it in the place that is given with
|
||||||
the ":version" command.
|
the ":version" command. NOTE: System vimrc file needs specific compilation
|
||||||
|
options (one needs to define SYS_VIMRC_FILE macros). If :version command does
|
||||||
|
not show anything like this, consider contacting the nvim package maintainer.
|
||||||
|
|
||||||
Saving the current state of Vim to a file:
|
Saving the current state of Vim to a file:
|
||||||
Whenever you have changed values of options or when you have created a
|
Whenever you have changed values of options or when you have created a
|
||||||
@@ -526,7 +515,8 @@ mapping, then you may want to save them in a vimrc file for later use. See
|
|||||||
|
|
||||||
Avoiding setup problems for Vi users:
|
Avoiding setup problems for Vi users:
|
||||||
Vi uses the variable EXINIT and the file "~/.exrc". So if you do not want to
|
Vi uses the variable EXINIT and the file "~/.exrc". So if you do not want to
|
||||||
interfere with Vi, then use the variable VIMINIT and the file "vimrc" instead.
|
interfere with Vi, then use the variable VIMINIT and the file init.vim
|
||||||
|
instead.
|
||||||
|
|
||||||
MS-DOS line separators:
|
MS-DOS line separators:
|
||||||
On MS-DOS-like systems (MS-DOS itself and Win32), Vim assumes that all
|
On MS-DOS-like systems (MS-DOS itself and Win32), Vim assumes that all
|
||||||
@@ -538,7 +528,7 @@ The $MYVIMRC or $MYGVIMRC file will be set to the first found vimrc and/or
|
|||||||
gvimrc file.
|
gvimrc file.
|
||||||
|
|
||||||
Avoiding trojan horses: *trojan-horse*
|
Avoiding trojan horses: *trojan-horse*
|
||||||
While reading the "vimrc" or the "exrc" file in the current directory, some
|
While reading the vimrc or the exrc file in the current directory, some
|
||||||
commands can be disabled for security reasons by setting the 'secure' option.
|
commands can be disabled for security reasons by setting the 'secure' option.
|
||||||
This is always done when executing the command from a tags file. Otherwise it
|
This is always done when executing the command from a tags file. Otherwise it
|
||||||
would be possible that you accidentally use a vimrc or tags file that somebody
|
would be possible that you accidentally use a vimrc or tags file that somebody
|
||||||
@@ -547,8 +537,8 @@ that start a shell, the ones that write to a file, and ":autocmd". The ":map"
|
|||||||
commands are echoed, so you can see which keys are being mapped.
|
commands are echoed, so you can see which keys are being mapped.
|
||||||
If you want Vim to execute all commands in a local vimrc file, you
|
If you want Vim to execute all commands in a local vimrc file, you
|
||||||
can reset the 'secure' option in the EXINIT or VIMINIT environment variable or
|
can reset the 'secure' option in the EXINIT or VIMINIT environment variable or
|
||||||
in the global "exrc" or "vimrc" file. This is not possible in "vimrc" or
|
in the global exrc or vimrc file. This is not possible in vimrc or
|
||||||
"exrc" in the current directory, for obvious reasons.
|
exrc in the current directory, for obvious reasons.
|
||||||
On Unix systems, this only happens if you are not the owner of the
|
On Unix systems, this only happens if you are not the owner of the
|
||||||
vimrc file. Warning: If you unpack an archive that contains a vimrc or exrc
|
vimrc file. Warning: If you unpack an archive that contains a vimrc or exrc
|
||||||
file, it will be owned by you. You won't have the security protection. Check
|
file, it will be owned by you. You won't have the security protection. Check
|
||||||
@@ -603,7 +593,7 @@ though.
|
|||||||
4. $VIM and $VIMRUNTIME
|
4. $VIM and $VIMRUNTIME
|
||||||
*$VIM*
|
*$VIM*
|
||||||
The environment variable "$VIM" is used to locate various user files for Vim,
|
The environment variable "$VIM" is used to locate various user files for Vim,
|
||||||
such as the user startup script ".vimrc". This depends on the system, see
|
such as the user startup script |init.vim|. This depends on the system, see
|
||||||
|startup|.
|
|startup|.
|
||||||
|
|
||||||
To avoid the need for every user to set the $VIM environment variable, Vim
|
To avoid the need for every user to set the $VIM environment variable, Vim
|
||||||
@@ -712,7 +702,7 @@ vimrc file.
|
|||||||
directory).
|
directory).
|
||||||
|
|
||||||
*:mkv* *:mkvimrc*
|
*:mkv* *:mkvimrc*
|
||||||
:mkv[imrc][!] [file] Like ":mkexrc", but the default is ".vimrc" in the
|
:mkv[imrc][!] [file] Like ":mkexrc", but the default is ".nvimrc" in the
|
||||||
current directory. The ":version" command is also
|
current directory. The ":version" command is also
|
||||||
written to the file.
|
written to the file.
|
||||||
|
|
||||||
@@ -731,13 +721,13 @@ can be used with different terminals.
|
|||||||
|
|
||||||
Only global mappings are stored, not mappings local to a buffer.
|
Only global mappings are stored, not mappings local to a buffer.
|
||||||
|
|
||||||
A common method is to use a default ".vimrc" file, make some modifications
|
A common method is to use a default |init.vim| file, make some modifications
|
||||||
with ":map" and ":set" commands and write the modified file. First read the
|
with ":map" and ":set" commands and write the modified file. First read the
|
||||||
default ".vimrc" in with a command like ":source ~piet/.vimrc.Cprogs", change
|
default vimrc in with a command like ":source ~piet/.vimrc.Cprogs", change
|
||||||
the settings and then save them in the current directory with ":mkvimrc!". If
|
the settings and then save them in the current directory with ":mkvimrc!". If
|
||||||
you want to make this file your default .vimrc, move it to your home directory
|
you want to make this file your default |init.vim|, move it to
|
||||||
(on Unix) or $VIM directory (MS-DOS). You could also use
|
$XDG_CONFIG_HOME/nvim. You could also use autocommands |autocommand| and/or
|
||||||
autocommands |autocommand| and/or modelines |modeline|.
|
modelines |modeline|.
|
||||||
|
|
||||||
*vimrc-option-example*
|
*vimrc-option-example*
|
||||||
If you only want to add a single option setting to your vimrc, you can use
|
If you only want to add a single option setting to your vimrc, you can use
|
||||||
@@ -1057,10 +1047,8 @@ even if other entries (with known name/type/etc) are merged. |shada-merging|
|
|||||||
|
|
||||||
SHADA FILE NAME *shada-file-name*
|
SHADA FILE NAME *shada-file-name*
|
||||||
|
|
||||||
- The default name of the ShaDa file is "$HOME/.nvim/shada/main.shada" for
|
- The default name of the ShaDa file is "$XDG_DATA_HOME/nvim/shada/main.shada"
|
||||||
Unix, "$HOME\_nvim\shada\main.shada" for MS-DOS and Win32. For the last
|
for Unix. Default for $XDG_DATA_HOME is ~/.local/share.
|
||||||
two, when $HOME is not set, "$VIM\_nvim\shada\main.shada" is used. When
|
|
||||||
$VIM is also not set, "c:\_nvim\shada\main.shada" is used.
|
|
||||||
- The 'n' flag in the 'shada' option can be used to specify another ShaDa
|
- The 'n' flag in the 'shada' option can be used to specify another ShaDa
|
||||||
file name |'shada'|.
|
file name |'shada'|.
|
||||||
- The "-i" Vim argument can be used to set another file name, |-i|. When the
|
- The "-i" Vim argument can be used to set another file name, |-i|. When the
|
||||||
@@ -1103,7 +1091,7 @@ do this. This can be useful in order to create a second file, say
|
|||||||
"~/.my.shada" which could contain certain settings that you always want when
|
"~/.my.shada" which could contain certain settings that you always want when
|
||||||
you first start Neovim. For example, you can preload registers with
|
you first start Neovim. For example, you can preload registers with
|
||||||
particular data, or put certain commands in the command line history. A line
|
particular data, or put certain commands in the command line history. A line
|
||||||
in your .nvimrc file like >
|
in your |init.vim| file like >
|
||||||
:rshada! ~/.my.shada
|
:rshada! ~/.my.shada
|
||||||
can be used to load this information. You could even have different ShaDa
|
can be used to load this information. You could even have different ShaDa
|
||||||
files for different types of files (e.g., C code) and load them based on the
|
files for different types of files (e.g., C code) and load them based on the
|
||||||
@@ -1167,7 +1155,8 @@ running) you have additional options:
|
|||||||
empty, marks for up to 100 files will be written.
|
empty, marks for up to 100 files will be written.
|
||||||
When you get error "E138: All .tmp.X files exist,
|
When you get error "E138: All .tmp.X files exist,
|
||||||
cannot write ShaDa file!" check that no old temp files
|
cannot write ShaDa file!" check that no old temp files
|
||||||
were left behind (e.g. ~/.nvim/shada/main.shada.tmp*).
|
were left behind (e.g.
|
||||||
|
~/.local/share/nvim/shada/main.shada.tmp*).
|
||||||
|
|
||||||
Note: Executing :wshada will reset all |'quote| marks.
|
Note: Executing :wshada will reset all |'quote| marks.
|
||||||
|
|
||||||
|
@@ -143,14 +143,14 @@ automatically with ":syntax enable", do this:
|
|||||||
|
|
||||||
1. Create your user runtime directory. You would normally use the first item
|
1. Create your user runtime directory. You would normally use the first item
|
||||||
of the 'runtimepath' option. Example for Unix: >
|
of the 'runtimepath' option. Example for Unix: >
|
||||||
mkdir ~/.vim
|
mkdir ~/.config/nvim
|
||||||
|
|
||||||
2. Create a directory in there called "syntax". For Unix: >
|
2. Create a directory in there called "syntax". For Unix: >
|
||||||
mkdir ~/.vim/syntax
|
mkdir ~/.config/nvim/syntax
|
||||||
|
|
||||||
3. Write the Vim syntax file. Or download one from the internet. Then write
|
3. Write the Vim syntax file. Or download one from the internet. Then write
|
||||||
it in your syntax directory. For example, for the "mine" syntax: >
|
it in your syntax directory. For example, for the "mine" syntax: >
|
||||||
:w ~/.vim/syntax/mine.vim
|
:w ~/.config/nvim/syntax/mine.vim
|
||||||
|
|
||||||
Now you can start using your syntax file manually: >
|
Now you can start using your syntax file manually: >
|
||||||
:set syntax=mine
|
:set syntax=mine
|
||||||
@@ -170,8 +170,8 @@ add a few items or change the highlighting, follow these steps:
|
|||||||
1. Create your user directory from 'runtimepath', see above.
|
1. Create your user directory from 'runtimepath', see above.
|
||||||
|
|
||||||
2. Create a directory in there called "after/syntax". For Unix: >
|
2. Create a directory in there called "after/syntax". For Unix: >
|
||||||
mkdir ~/.vim/after
|
mkdir ~/.config/nvim/after
|
||||||
mkdir ~/.vim/after/syntax
|
mkdir ~/.config/nvim/after/syntax
|
||||||
|
|
||||||
3. Write a Vim script that contains the commands you want to use. For
|
3. Write a Vim script that contains the commands you want to use. For
|
||||||
example, to change the colors for the C syntax: >
|
example, to change the colors for the C syntax: >
|
||||||
@@ -179,15 +179,15 @@ add a few items or change the highlighting, follow these steps:
|
|||||||
|
|
||||||
4. Write that file in the "after/syntax" directory. Use the name of the
|
4. Write that file in the "after/syntax" directory. Use the name of the
|
||||||
syntax, with ".vim" added. For our C syntax: >
|
syntax, with ".vim" added. For our C syntax: >
|
||||||
:w ~/.vim/after/syntax/c.vim
|
:w ~/.config/nvim/after/syntax/c.vim
|
||||||
|
|
||||||
That's it. The next time you edit a C file the Comment color will be
|
That's it. The next time you edit a C file the Comment color will be
|
||||||
different. You don't even have to restart Vim.
|
different. You don't even have to restart Vim.
|
||||||
|
|
||||||
If you have multiple files, you can use the filetype as the directory name.
|
If you have multiple files, you can use the filetype as the directory name.
|
||||||
All the "*.vim" files in this directory will be used, for example:
|
All the "*.vim" files in this directory will be used, for example:
|
||||||
~/.vim/after/syntax/c/one.vim
|
~/.config/nvim/after/syntax/c/one.vim
|
||||||
~/.vim/after/syntax/c/two.vim
|
~/.config/nvim/after/syntax/c/two.vim
|
||||||
|
|
||||||
|
|
||||||
REPLACING AN EXISTING SYNTAX FILE *mysyntaxfile-replace*
|
REPLACING AN EXISTING SYNTAX FILE *mysyntaxfile-replace*
|
||||||
@@ -471,7 +471,7 @@ moves through the buffer, switches windows, and the like: >
|
|||||||
|
|
||||||
vim -E -s -c "let g:html_no_progress=1" -c "syntax on" -c "set ft=c" -c "runtime syntax/2html.vim" -cwqa myfile.c
|
vim -E -s -c "let g:html_no_progress=1" -c "syntax on" -c "set ft=c" -c "runtime syntax/2html.vim" -cwqa myfile.c
|
||||||
<
|
<
|
||||||
Note that the -s flag prevents loading your .vimrc and any plugins, so you
|
Note that the -s flag prevents loading your vimrc and any plugins, so you
|
||||||
need to explicitly source/enable anything that will affect the HTML
|
need to explicitly source/enable anything that will affect the HTML
|
||||||
conversion. See |-E| and |-s-ex| for details. It is probably best to create a
|
conversion. See |-E| and |-s-ex| for details. It is probably best to create a
|
||||||
script to replace all the -c commands and use it with the -u flag instead of
|
script to replace all the -c commands and use it with the -u flag instead of
|
||||||
@@ -874,13 +874,13 @@ for both 3 GL and 4 GL programming. Large number of standard defines/constants
|
|||||||
are supported.
|
are supported.
|
||||||
|
|
||||||
Some special violation of coding standards will be signalled when one specify
|
Some special violation of coding standards will be signalled when one specify
|
||||||
in ones |.vimrc|: >
|
in ones |init.vim|: >
|
||||||
let baan_code_stds=1
|
let baan_code_stds=1
|
||||||
|
|
||||||
*baan-folding*
|
*baan-folding*
|
||||||
|
|
||||||
Syntax folding can be enabled at various levels through the variables
|
Syntax folding can be enabled at various levels through the variables
|
||||||
mentioned below (Set those in your |.vimrc|). The more complex folding on
|
mentioned below (Set those in your |init.vim|). The more complex folding on
|
||||||
source blocks and SQL can be CPU intensive.
|
source blocks and SQL can be CPU intensive.
|
||||||
|
|
||||||
To allow any folding and enable folding at function level use: >
|
To allow any folding and enable folding at function level use: >
|
||||||
@@ -894,8 +894,8 @@ SELECTEMPTY, ... The indentation preceding the begin/end keywords has to
|
|||||||
match (spaces are not considered equal to a tab). >
|
match (spaces are not considered equal to a tab). >
|
||||||
let baan_fold_sql=1
|
let baan_fold_sql=1
|
||||||
Note: Block folding can result in many small folds. It is suggested to |:set|
|
Note: Block folding can result in many small folds. It is suggested to |:set|
|
||||||
the options 'foldminlines' and 'foldnestmax' in |.vimrc| or use |:setlocal| in
|
the options 'foldminlines' and 'foldnestmax' in |init.vim| or use |:setlocal|
|
||||||
.../after/syntax/baan.vim (see |after-directory|). Eg: >
|
in .../after/syntax/baan.vim (see |after-directory|). Eg: >
|
||||||
set foldminlines=5
|
set foldminlines=5
|
||||||
set foldnestmax=6
|
set foldnestmax=6
|
||||||
|
|
||||||
@@ -977,7 +977,7 @@ highlighting for cErrInParen and cErrInBracket.
|
|||||||
|
|
||||||
If you want to use folding in your C files, you can add these lines in a file
|
If you want to use folding in your C files, you can add these lines in a file
|
||||||
in the "after" directory in 'runtimepath'. For Unix this would be
|
in the "after" directory in 'runtimepath'. For Unix this would be
|
||||||
~/.vim/after/syntax/c.vim. >
|
~/.config/nvim/after/syntax/c.vim. >
|
||||||
syn sync fromstart
|
syn sync fromstart
|
||||||
set foldmethod=syntax
|
set foldmethod=syntax
|
||||||
|
|
||||||
@@ -1004,7 +1004,7 @@ chill_minlines like c_minlines
|
|||||||
CHANGELOG *changelog.vim* *ft-changelog-syntax*
|
CHANGELOG *changelog.vim* *ft-changelog-syntax*
|
||||||
|
|
||||||
ChangeLog supports highlighting spaces at the start of a line.
|
ChangeLog supports highlighting spaces at the start of a line.
|
||||||
If you do not like this, add following line to your .vimrc: >
|
If you do not like this, add following line to your vimrc: >
|
||||||
let g:changelog_spacing_errors = 0
|
let g:changelog_spacing_errors = 0
|
||||||
This works the next time you edit a changelog file. You can also use
|
This works the next time you edit a changelog file. You can also use
|
||||||
"b:changelog_spacing_errors" to set this per buffer (before loading the syntax
|
"b:changelog_spacing_errors" to set this per buffer (before loading the syntax
|
||||||
@@ -1037,7 +1037,7 @@ COBOL *cobol.vim* *ft-cobol-syntax*
|
|||||||
COBOL highlighting has different needs for legacy code than it does for fresh
|
COBOL highlighting has different needs for legacy code than it does for fresh
|
||||||
development. This is due to differences in what is being done (maintenance
|
development. This is due to differences in what is being done (maintenance
|
||||||
versus development) and other factors. To enable legacy code highlighting,
|
versus development) and other factors. To enable legacy code highlighting,
|
||||||
add this line to your .vimrc: >
|
add this line to your vimrc: >
|
||||||
:let cobol_legacy_code = 1
|
:let cobol_legacy_code = 1
|
||||||
To disable it again, use this: >
|
To disable it again, use this: >
|
||||||
:unlet cobol_legacy_code
|
:unlet cobol_legacy_code
|
||||||
@@ -1090,7 +1090,7 @@ Cynlib files are C++ files that use the Cynlib class library to enable
|
|||||||
hardware modelling and simulation using C++. Typically Cynlib files have a .cc
|
hardware modelling and simulation using C++. Typically Cynlib files have a .cc
|
||||||
or a .cpp extension, which makes it very difficult to distinguish them from a
|
or a .cpp extension, which makes it very difficult to distinguish them from a
|
||||||
normal C++ file. Thus, to enable Cynlib highlighting for .cc files, add this
|
normal C++ file. Thus, to enable Cynlib highlighting for .cc files, add this
|
||||||
line to your .vimrc file: >
|
line to your vimrc file: >
|
||||||
|
|
||||||
:let cynlib_cyntax_for_cc=1
|
:let cynlib_cyntax_for_cc=1
|
||||||
|
|
||||||
@@ -1202,7 +1202,7 @@ or >
|
|||||||
|
|
||||||
It can also be done automatically for C, C++, C#, IDL and PHP files by setting
|
It can also be done automatically for C, C++, C#, IDL and PHP files by setting
|
||||||
the global or buffer-local variable load_doxygen_syntax. This is done by
|
the global or buffer-local variable load_doxygen_syntax. This is done by
|
||||||
adding the following to your .vimrc. >
|
adding the following to your vimrc. >
|
||||||
:let g:load_doxygen_syntax=1
|
:let g:load_doxygen_syntax=1
|
||||||
|
|
||||||
There are a couple of variables that have an effect on syntax highlighting, and
|
There are a couple of variables that have an effect on syntax highlighting, and
|
||||||
@@ -1355,7 +1355,7 @@ start of a new paragraph, so the ftplugin sets 'tw'=0 (unlimited line length),
|
|||||||
and so on. It also includes some keymaps that are disabled by default.
|
and so on. It also includes some keymaps that are disabled by default.
|
||||||
|
|
||||||
If you want to enable the keymaps that make "j" and "k" and the cursor keys
|
If you want to enable the keymaps that make "j" and "k" and the cursor keys
|
||||||
move up and down by display lines, add this to your .vimrc: >
|
move up and down by display lines, add this to your vimrc: >
|
||||||
:let flexwiki_maps = 1
|
:let flexwiki_maps = 1
|
||||||
|
|
||||||
|
|
||||||
@@ -1407,10 +1407,10 @@ syntax highlighting will not be correct if the form is incorrectly set.
|
|||||||
When you create a new fortran file, the syntax script assumes fixed source
|
When you create a new fortran file, the syntax script assumes fixed source
|
||||||
form. If you always use free source form, then >
|
form. If you always use free source form, then >
|
||||||
:let fortran_free_source=1
|
:let fortran_free_source=1
|
||||||
in your .vimrc prior to the :syntax on command. If you always use fixed source
|
in your vimrc prior to the :syntax on command. If you always use fixed source
|
||||||
form, then >
|
form, then >
|
||||||
:let fortran_fixed_source=1
|
:let fortran_fixed_source=1
|
||||||
in your .vimrc prior to the :syntax on command.
|
in your vimrc prior to the :syntax on command.
|
||||||
|
|
||||||
If the form of the source code depends upon the file extension, then it is
|
If the form of the source code depends upon the file extension, then it is
|
||||||
most convenient to set fortran_free_source in a ftplugin file. For more
|
most convenient to set fortran_free_source in a ftplugin file. For more
|
||||||
@@ -1426,7 +1426,7 @@ rest in fixed source form, add the following code to your ftplugin file >
|
|||||||
unlet! fortran_free_source
|
unlet! fortran_free_source
|
||||||
endif
|
endif
|
||||||
Note that this will work only if the "filetype plugin indent on" command
|
Note that this will work only if the "filetype plugin indent on" command
|
||||||
precedes the "syntax on" command in your .vimrc file.
|
precedes the "syntax on" command in your vimrc file.
|
||||||
|
|
||||||
When you edit an existing fortran file, the syntax script will assume free
|
When you edit an existing fortran file, the syntax script will assume free
|
||||||
source form if the fortran_free_source variable has been set, and assumes
|
source form if the fortran_free_source variable has been set, and assumes
|
||||||
@@ -1446,7 +1446,7 @@ Tabs are not recognized by the Fortran standards. Tabs are not a good idea in
|
|||||||
fixed format fortran source code which requires fixed column boundaries.
|
fixed format fortran source code which requires fixed column boundaries.
|
||||||
Therefore, tabs are marked as errors. Nevertheless, some programmers like
|
Therefore, tabs are marked as errors. Nevertheless, some programmers like
|
||||||
using tabs. If your fortran files contain tabs, then you should set the
|
using tabs. If your fortran files contain tabs, then you should set the
|
||||||
variable fortran_have_tabs in your .vimrc with a command such as >
|
variable fortran_have_tabs in your vimrc with a command such as >
|
||||||
:let fortran_have_tabs=1
|
:let fortran_have_tabs=1
|
||||||
placed prior to the :syntax on command. Unfortunately, the use of tabs will
|
placed prior to the :syntax on command. Unfortunately, the use of tabs will
|
||||||
mean that the syntax file will not be able to detect incorrect margins.
|
mean that the syntax file will not be able to detect incorrect margins.
|
||||||
@@ -1492,7 +1492,7 @@ other legacy features excluded from F will be highlighted as todo items and
|
|||||||
that free source form will be assumed.
|
that free source form will be assumed.
|
||||||
|
|
||||||
The dialect can be selected in various ways. If all your fortran files use
|
The dialect can be selected in various ways. If all your fortran files use
|
||||||
the same dialect, set the global variable fortran_dialect in your .vimrc prior
|
the same dialect, set the global variable fortran_dialect in your vimrc prior
|
||||||
to your syntax on statement. The case-sensitive, permissible values of
|
to your syntax on statement. The case-sensitive, permissible values of
|
||||||
fortran_dialect are "f08" or "F". Invalid values of fortran_dialect are
|
fortran_dialect are "f08" or "F". Invalid values of fortran_dialect are
|
||||||
ignored.
|
ignored.
|
||||||
@@ -1509,7 +1509,7 @@ contain the code >
|
|||||||
unlet! b:fortran_dialect
|
unlet! b:fortran_dialect
|
||||||
endif
|
endif
|
||||||
Note that this will work only if the "filetype plugin indent on" command
|
Note that this will work only if the "filetype plugin indent on" command
|
||||||
precedes the "syntax on" command in your .vimrc file.
|
precedes the "syntax on" command in your vimrc file.
|
||||||
|
|
||||||
Finer control is necessary if the file extension does not uniquely identify
|
Finer control is necessary if the file extension does not uniquely identify
|
||||||
the dialect. You can override the default dialect, on a file-by-file basis,
|
the dialect. You can override the default dialect, on a file-by-file basis,
|
||||||
@@ -1561,7 +1561,7 @@ in /usr/X11/lib/X11/, you should add the line >
|
|||||||
|
|
||||||
:let rgb_file = "/usr/X11/lib/X11/rgb.txt"
|
:let rgb_file = "/usr/X11/lib/X11/rgb.txt"
|
||||||
|
|
||||||
to your .vimrc file.
|
to your vimrc file.
|
||||||
|
|
||||||
|
|
||||||
GSP *gsp.vim* *ft-gsp-syntax*
|
GSP *gsp.vim* *ft-gsp-syntax*
|
||||||
@@ -1603,7 +1603,7 @@ Haskell code, the latter in both Bird style and TeX style. The Haskell
|
|||||||
syntax highlighting will also highlight C preprocessor directives.
|
syntax highlighting will also highlight C preprocessor directives.
|
||||||
|
|
||||||
If you want to highlight delimiter characters (useful if you have a
|
If you want to highlight delimiter characters (useful if you have a
|
||||||
light-coloured background), add to your .vimrc: >
|
light-coloured background), add to your vimrc: >
|
||||||
:let hs_highlight_delimiters = 1
|
:let hs_highlight_delimiters = 1
|
||||||
To treat True and False as keywords as opposed to ordinary identifiers,
|
To treat True and False as keywords as opposed to ordinary identifiers,
|
||||||
add: >
|
add: >
|
||||||
@@ -1613,21 +1613,21 @@ To also treat the names of primitive types as keywords: >
|
|||||||
And to treat the names of even more relatively common types as keywords: >
|
And to treat the names of even more relatively common types as keywords: >
|
||||||
:let hs_highlight_more_types = 1
|
:let hs_highlight_more_types = 1
|
||||||
If you want to highlight the names of debugging functions, put in
|
If you want to highlight the names of debugging functions, put in
|
||||||
your .vimrc: >
|
your vimrc: >
|
||||||
:let hs_highlight_debug = 1
|
:let hs_highlight_debug = 1
|
||||||
|
|
||||||
The Haskell syntax highlighting also highlights C preprocessor
|
The Haskell syntax highlighting also highlights C preprocessor
|
||||||
directives, and flags lines that start with # but are not valid
|
directives, and flags lines that start with # but are not valid
|
||||||
directives as erroneous. This interferes with Haskell's syntax for
|
directives as erroneous. This interferes with Haskell's syntax for
|
||||||
operators, as they may start with #. If you want to highlight those
|
operators, as they may start with #. If you want to highlight those
|
||||||
as operators as opposed to errors, put in your .vimrc: >
|
as operators as opposed to errors, put in your vimrc: >
|
||||||
:let hs_allow_hash_operator = 1
|
:let hs_allow_hash_operator = 1
|
||||||
|
|
||||||
The syntax highlighting for literate Haskell code will try to
|
The syntax highlighting for literate Haskell code will try to
|
||||||
automatically guess whether your literate Haskell code contains
|
automatically guess whether your literate Haskell code contains
|
||||||
TeX markup or not, and correspondingly highlight TeX constructs
|
TeX markup or not, and correspondingly highlight TeX constructs
|
||||||
or nothing at all. You can override this globally by putting
|
or nothing at all. You can override this globally by putting
|
||||||
in your .vimrc >
|
in your vimrc >
|
||||||
:let lhs_markup = none
|
:let lhs_markup = none
|
||||||
for no highlighting at all, or >
|
for no highlighting at all, or >
|
||||||
:let lhs_markup = tex
|
:let lhs_markup = tex
|
||||||
@@ -1720,7 +1720,7 @@ The coloring scheme for HTML/OS works as follows:
|
|||||||
Functions and variable names are the same color by default, because VIM
|
Functions and variable names are the same color by default, because VIM
|
||||||
doesn't specify different colors for Functions and Identifiers. To change
|
doesn't specify different colors for Functions and Identifiers. To change
|
||||||
this (which is recommended if you want function names to be recognizable in a
|
this (which is recommended if you want function names to be recognizable in a
|
||||||
different color) you need to add the following line to either your ~/.vimrc: >
|
different color) you need to add the following line to your vimrc: >
|
||||||
:hi Function term=underline cterm=bold ctermfg=LightGray
|
:hi Function term=underline cterm=bold ctermfg=LightGray
|
||||||
|
|
||||||
Of course, the ctermfg can be a different color if you choose.
|
Of course, the ctermfg can be a different color if you choose.
|
||||||
@@ -1739,7 +1739,7 @@ IA64 *ia64.vim* *intel-itanium* *ft-ia64-syntax*
|
|||||||
Highlighting for the Intel Itanium 64 assembly language. See |asm.vim| for
|
Highlighting for the Intel Itanium 64 assembly language. See |asm.vim| for
|
||||||
how to recognize this filetype.
|
how to recognize this filetype.
|
||||||
|
|
||||||
To have *.inc files be recognized as IA64, add this to your .vimrc file: >
|
To have *.inc files be recognized as IA64, add this to your vimrc file: >
|
||||||
:let g:filetype_inc = "ia64"
|
:let g:filetype_inc = "ia64"
|
||||||
|
|
||||||
|
|
||||||
@@ -1901,7 +1901,7 @@ difficulties (such as may happen with large lex files).
|
|||||||
|
|
||||||
LIFELINES *lifelines.vim* *ft-lifelines-syntax*
|
LIFELINES *lifelines.vim* *ft-lifelines-syntax*
|
||||||
|
|
||||||
To highlight deprecated functions as errors, add in your .vimrc: >
|
To highlight deprecated functions as errors, add in your vimrc: >
|
||||||
|
|
||||||
:let g:lifelines_deprecated = 1
|
:let g:lifelines_deprecated = 1
|
||||||
<
|
<
|
||||||
@@ -1944,7 +1944,7 @@ LPC *lpc.vim* *ft-lpc-syntax*
|
|||||||
LPC stands for a simple, memory-efficient language: Lars Pensj| C. The
|
LPC stands for a simple, memory-efficient language: Lars Pensj| C. The
|
||||||
file name of LPC is usually *.c. Recognizing these files as LPC would bother
|
file name of LPC is usually *.c. Recognizing these files as LPC would bother
|
||||||
users writing only C programs. If you want to use LPC syntax in Vim, you
|
users writing only C programs. If you want to use LPC syntax in Vim, you
|
||||||
should set a variable in your .vimrc file: >
|
should set a variable in your vimrc file: >
|
||||||
|
|
||||||
:let lpc_syntax_for_c = 1
|
:let lpc_syntax_for_c = 1
|
||||||
|
|
||||||
@@ -2023,13 +2023,13 @@ MAPLE *maple.vim* *ft-maple-syntax*
|
|||||||
Maple V, by Waterloo Maple Inc, supports symbolic algebra. The language
|
Maple V, by Waterloo Maple Inc, supports symbolic algebra. The language
|
||||||
supports many packages of functions which are selectively loaded by the user.
|
supports many packages of functions which are selectively loaded by the user.
|
||||||
The standard set of packages' functions as supplied in Maple V release 4 may be
|
The standard set of packages' functions as supplied in Maple V release 4 may be
|
||||||
highlighted at the user's discretion. Users may place in their .vimrc file: >
|
highlighted at the user's discretion. Users may place in their vimrc file: >
|
||||||
|
|
||||||
:let mvpkg_all= 1
|
:let mvpkg_all= 1
|
||||||
|
|
||||||
to get all package functions highlighted, or users may select any subset by
|
to get all package functions highlighted, or users may select any subset by
|
||||||
choosing a variable/package from the table below and setting that variable to
|
choosing a variable/package from the table below and setting that variable to
|
||||||
1, also in their .vimrc file (prior to sourcing
|
1, also in their vimrc file (prior to sourcing
|
||||||
$VIMRUNTIME/syntax/syntax.vim).
|
$VIMRUNTIME/syntax/syntax.vim).
|
||||||
|
|
||||||
Table of Maple V Package Function Selectors >
|
Table of Maple V Package Function Selectors >
|
||||||
@@ -2046,7 +2046,7 @@ $VIMRUNTIME/syntax/syntax.vim).
|
|||||||
MATHEMATICA *mma.vim* *ft-mma-syntax* *ft-mathematica-syntax*
|
MATHEMATICA *mma.vim* *ft-mma-syntax* *ft-mathematica-syntax*
|
||||||
|
|
||||||
Empty *.m files will automatically be presumed to be Matlab files unless you
|
Empty *.m files will automatically be presumed to be Matlab files unless you
|
||||||
have the following in your .vimrc: >
|
have the following in your vimrc: >
|
||||||
|
|
||||||
let filetype_m = "mma"
|
let filetype_m = "mma"
|
||||||
|
|
||||||
@@ -2172,7 +2172,7 @@ highlighting definition for the syntax groups "nroffDefinition" and
|
|||||||
\ gui=reverse,bold
|
\ gui=reverse,bold
|
||||||
|
|
||||||
If you want to navigate preprocessor entries in your source file as easily as
|
If you want to navigate preprocessor entries in your source file as easily as
|
||||||
with section markers, you can activate the following option in your .vimrc
|
with section markers, you can activate the following option in your vimrc
|
||||||
file: >
|
file: >
|
||||||
|
|
||||||
let b:preprocs_as_sections = 1
|
let b:preprocs_as_sections = 1
|
||||||
@@ -2625,7 +2625,7 @@ number is that redrawing can become slow.
|
|||||||
|
|
||||||
Vim tries to guess what type a ".r" file is. If it can't be detected (from
|
Vim tries to guess what type a ".r" file is. If it can't be detected (from
|
||||||
comment lines), the default is "r". To make the default rexx add this line to
|
comment lines), the default is "r". To make the default rexx add this line to
|
||||||
your .vimrc: *g:filetype_r*
|
your vimrc: *g:filetype_r*
|
||||||
>
|
>
|
||||||
:let g:filetype_r = "r"
|
:let g:filetype_r = "r"
|
||||||
|
|
||||||
@@ -2808,7 +2808,7 @@ be shell files but the type is not apparent. Furthermore, on many systems
|
|||||||
sh is symbolically linked to "bash" (Linux, Windows+cygwin) or "ksh" (Posix).
|
sh is symbolically linked to "bash" (Linux, Windows+cygwin) or "ksh" (Posix).
|
||||||
|
|
||||||
One may specify a global default by instantiating one of the following three
|
One may specify a global default by instantiating one of the following three
|
||||||
variables in your <.vimrc>:
|
variables in your vimrc:
|
||||||
|
|
||||||
ksh: >
|
ksh: >
|
||||||
let g:is_kornshell = 1
|
let g:is_kornshell = 1
|
||||||
@@ -2823,7 +2823,7 @@ If there's no "#! ..." line, and the user hasn't availed himself/herself of a
|
|||||||
default sh.vim syntax setting as just shown, then syntax/sh.vim will assume
|
default sh.vim syntax setting as just shown, then syntax/sh.vim will assume
|
||||||
the Bourne shell syntax. No need to quote RFCs or market penetration
|
the Bourne shell syntax. No need to quote RFCs or market penetration
|
||||||
statistics in error reports, please -- just select the default version of the
|
statistics in error reports, please -- just select the default version of the
|
||||||
sh your system uses in your <.vimrc>.
|
sh your system uses in your vimrc.
|
||||||
|
|
||||||
The syntax/sh.vim file provides several levels of syntax-based folding: >
|
The syntax/sh.vim file provides several levels of syntax-based folding: >
|
||||||
|
|
||||||
@@ -2869,7 +2869,7 @@ this behavior with: >
|
|||||||
|
|
||||||
You may wish to embed languages into sh. I'll give an example courtesy of
|
You may wish to embed languages into sh. I'll give an example courtesy of
|
||||||
Lorance Stinson on how to do this with awk as an example. Put the following
|
Lorance Stinson on how to do this with awk as an example. Put the following
|
||||||
file into $HOME/.vim/after/syntax/sh/awkembed.vim: >
|
file into $HOME/.config/nvim/after/syntax/sh/awkembed.vim: >
|
||||||
|
|
||||||
" AWK Embedding: {{{1
|
" AWK Embedding: {{{1
|
||||||
" ==============
|
" ==============
|
||||||
@@ -2945,7 +2945,7 @@ for how the filetype is detected.
|
|||||||
|
|
||||||
Tcsh does not allow \" in strings unless the "backslash_quote" shell variable
|
Tcsh does not allow \" in strings unless the "backslash_quote" shell variable
|
||||||
is set. If you want VIM to assume that no backslash quote constructs exist add
|
is set. If you want VIM to assume that no backslash quote constructs exist add
|
||||||
this line to your .vimrc: >
|
this line to your vimrc: >
|
||||||
|
|
||||||
:let tcsh_backslash_quote = 0
|
:let tcsh_backslash_quote = 0
|
||||||
|
|
||||||
@@ -2986,7 +2986,7 @@ TEX *tex.vim* *ft-tex-syntax* *latex-syntax*
|
|||||||
As of version 28 of <syntax/tex.vim>, syntax-based folding of parts, chapters,
|
As of version 28 of <syntax/tex.vim>, syntax-based folding of parts, chapters,
|
||||||
sections, subsections, etc are supported. Put >
|
sections, subsections, etc are supported. Put >
|
||||||
let g:tex_fold_enabled=1
|
let g:tex_fold_enabled=1
|
||||||
in your <.vimrc>, and :set fdm=syntax. I suggest doing the latter via a
|
in your vimrc, and :set fdm=syntax. I suggest doing the latter via a
|
||||||
modeline at the end of your LaTeX file: >
|
modeline at the end of your LaTeX file: >
|
||||||
% vim: fdm=syntax
|
% vim: fdm=syntax
|
||||||
If your system becomes too slow, then you might wish to look into >
|
If your system becomes too slow, then you might wish to look into >
|
||||||
@@ -2997,7 +2997,7 @@ If your system becomes too slow, then you might wish to look into >
|
|||||||
|
|
||||||
If you don't want spell checking anywhere in your LaTeX document, put >
|
If you don't want spell checking anywhere in your LaTeX document, put >
|
||||||
let g:tex_nospell=1
|
let g:tex_nospell=1
|
||||||
into your .vimrc. If you merely wish to suppress spell checking inside
|
into your vimrc. If you merely wish to suppress spell checking inside
|
||||||
comments only, see |g:tex_comment_nospell|.
|
comments only, see |g:tex_comment_nospell|.
|
||||||
|
|
||||||
*tex-nospell* *g:tex_comment_nospell*
|
*tex-nospell* *g:tex_comment_nospell*
|
||||||
@@ -3005,7 +3005,7 @@ comments only, see |g:tex_comment_nospell|.
|
|||||||
|
|
||||||
Some folks like to include things like source code in comments and so would
|
Some folks like to include things like source code in comments and so would
|
||||||
prefer that spell checking be disabled in comments in LaTeX files. To do
|
prefer that spell checking be disabled in comments in LaTeX files. To do
|
||||||
this, put the following in your <.vimrc>: >
|
this, put the following in your vimrc: >
|
||||||
let g:tex_comment_nospell= 1
|
let g:tex_comment_nospell= 1
|
||||||
If you want to suppress spell checking everywhere inside your LaTeX document,
|
If you want to suppress spell checking everywhere inside your LaTeX document,
|
||||||
see |g:tex_nospell|.
|
see |g:tex_nospell|.
|
||||||
@@ -3015,7 +3015,7 @@ see |g:tex_nospell|.
|
|||||||
|
|
||||||
Often verbatim regions are used for things like source code; seldom does
|
Often verbatim regions are used for things like source code; seldom does
|
||||||
one want source code spell-checked. However, for those of you who do
|
one want source code spell-checked. However, for those of you who do
|
||||||
want your verbatim zones spell-checked, put the following in your <.vimrc>: >
|
want your verbatim zones spell-checked, put the following in your vimrc: >
|
||||||
let g:tex_verbspell= 1
|
let g:tex_verbspell= 1
|
||||||
<
|
<
|
||||||
*tex-runon* *tex-stopzone*
|
*tex-runon* *tex-stopzone*
|
||||||
@@ -3050,7 +3050,7 @@ Finally, if syntax highlighting is still too slow, you may set >
|
|||||||
|
|
||||||
:let g:tex_fast= ""
|
:let g:tex_fast= ""
|
||||||
|
|
||||||
in your .vimrc. Used this way, the g:tex_fast variable causes the syntax
|
in your vimrc. Used this way, the g:tex_fast variable causes the syntax
|
||||||
highlighting script to avoid defining any regions and associated
|
highlighting script to avoid defining any regions and associated
|
||||||
synchronization. The result will be much faster syntax highlighting; the
|
synchronization. The result will be much faster syntax highlighting; the
|
||||||
price: you will no longer have as much highlighting or any syntax-based
|
price: you will no longer have as much highlighting or any syntax-based
|
||||||
@@ -3092,7 +3092,7 @@ http://vim.sf.net/.
|
|||||||
The <tex.vim> supports lexical error checking of various sorts. Thus,
|
The <tex.vim> supports lexical error checking of various sorts. Thus,
|
||||||
although the error checking is ofttimes very useful, it can indicate
|
although the error checking is ofttimes very useful, it can indicate
|
||||||
errors where none actually are. If this proves to be a problem for you,
|
errors where none actually are. If this proves to be a problem for you,
|
||||||
you may put in your <.vimrc> the following statement: >
|
you may put in your vimrc the following statement: >
|
||||||
let g:tex_no_error=1
|
let g:tex_no_error=1
|
||||||
and all error checking by <syntax/tex.vim> will be suppressed.
|
and all error checking by <syntax/tex.vim> will be suppressed.
|
||||||
|
|
||||||
@@ -3122,7 +3122,7 @@ such use of @ as an error. To solve this: >
|
|||||||
:let b:tex_stylish = 1
|
:let b:tex_stylish = 1
|
||||||
:set ft=tex
|
:set ft=tex
|
||||||
|
|
||||||
Putting "let g:tex_stylish=1" into your <.vimrc> will make <syntax/tex.vim>
|
Putting "let g:tex_stylish=1" into your vimrc will make <syntax/tex.vim>
|
||||||
always accept such use of @.
|
always accept such use of @.
|
||||||
|
|
||||||
*tex-cchar* *tex-cole* *tex-conceal*
|
*tex-cchar* *tex-cole* *tex-conceal*
|
||||||
@@ -3142,7 +3142,7 @@ with |'conceallevel'| at 0 and the other at 2; and both using |'scrollbind'|.
|
|||||||
Tex: Selective Conceal Mode~
|
Tex: Selective Conceal Mode~
|
||||||
|
|
||||||
You may selectively use conceal mode by setting g:tex_conceal in your
|
You may selectively use conceal mode by setting g:tex_conceal in your
|
||||||
<.vimrc>. By default, g:tex_conceal is set to "admgs" to enable concealment
|
vimrc. By default, g:tex_conceal is set to "admgs" to enable concealment
|
||||||
for the following sets of characters: >
|
for the following sets of characters: >
|
||||||
|
|
||||||
a = accents/ligatures
|
a = accents/ligatures
|
||||||
@@ -3193,8 +3193,8 @@ syntax highlighting script handles this with the following logic:
|
|||||||
For example, I use Luxi Mono Bold; it doesn't support subscript
|
For example, I use Luxi Mono Bold; it doesn't support subscript
|
||||||
characters for "hklmnpst", so I put >
|
characters for "hklmnpst", so I put >
|
||||||
let g:tex_subscripts= "[0-9aeijoruvx,+-/().]"
|
let g:tex_subscripts= "[0-9aeijoruvx,+-/().]"
|
||||||
< in ~/.vim/ftplugin/tex/tex.vim in order to avoid having inscrutable
|
< in ~/.config/nvim/ftplugin/tex/tex.vim in order to avoid having
|
||||||
utf-8 glyphs appear.
|
inscrutable utf-8 glyphs appear.
|
||||||
|
|
||||||
|
|
||||||
TF *tf.vim* *ft-tf-syntax*
|
TF *tf.vim* *ft-tf-syntax*
|
||||||
@@ -3252,7 +3252,7 @@ The syntax of XF86Config file differs in XFree86 v3.x and v4.x. Both
|
|||||||
variants are supported. Automatic detection is used, but is far from perfect.
|
variants are supported. Automatic detection is used, but is far from perfect.
|
||||||
You may need to specify the version manually. Set the variable
|
You may need to specify the version manually. Set the variable
|
||||||
xf86conf_xfree86_version to 3 or 4 according to your XFree86 version in
|
xf86conf_xfree86_version to 3 or 4 according to your XFree86 version in
|
||||||
your .vimrc. Example: >
|
your vimrc. Example: >
|
||||||
:let xf86conf_xfree86_version=3
|
:let xf86conf_xfree86_version=3
|
||||||
When using a mix of versions, set the b:xf86conf_xfree86_version variable.
|
When using a mix of versions, set the b:xf86conf_xfree86_version variable.
|
||||||
|
|
||||||
@@ -4646,7 +4646,7 @@ ctermbg={color-nr} *highlight-ctermbg*
|
|||||||
When you have set "ctermfg" or "ctermbg" for the Normal group, Vim
|
When you have set "ctermfg" or "ctermbg" for the Normal group, Vim
|
||||||
needs to reset the color when exiting. This is done with the "op"
|
needs to reset the color when exiting. This is done with the "op"
|
||||||
termcap entry |t_op|. If this doesn't work correctly, try setting the
|
termcap entry |t_op|. If this doesn't work correctly, try setting the
|
||||||
't_op' option in your .vimrc.
|
't_op' option in your vimrc.
|
||||||
*E419* *E420*
|
*E419* *E420*
|
||||||
When Vim knows the normal foreground and background colors, "fg" and
|
When Vim knows the normal foreground and background colors, "fg" and
|
||||||
"bg" can be used as color names. This only works after setting the
|
"bg" can be used as color names. This only works after setting the
|
||||||
@@ -4979,7 +4979,8 @@ script file to set these colors. Put this file in a directory in
|
|||||||
the default colors. This way these colors will be used after the ":syntax
|
the default colors. This way these colors will be used after the ":syntax
|
||||||
reset" command.
|
reset" command.
|
||||||
|
|
||||||
For Unix you can use the file ~/.vim/after/syntax/syncolor.vim. Example: >
|
For Unix you can use the file ~/.config/nvim/after/syntax/syncolor.vim.
|
||||||
|
Example: >
|
||||||
|
|
||||||
if &background == "light"
|
if &background == "light"
|
||||||
highlight comment ctermfg=darkgreen guifg=darkgreen
|
highlight comment ctermfg=darkgreen guifg=darkgreen
|
||||||
@@ -5036,7 +5037,7 @@ types.vim: *.[ch]
|
|||||||
awk 'BEGIN{printf("syntax keyword Type\t")}\
|
awk 'BEGIN{printf("syntax keyword Type\t")}\
|
||||||
{printf("%s ", $$1)}END{print ""}' > $@
|
{printf("%s ", $$1)}END{print ""}' > $@
|
||||||
|
|
||||||
And put these lines in your .vimrc: >
|
And put these lines in your vimrc: >
|
||||||
|
|
||||||
" load the types.vim highlighting file, if it exists
|
" load the types.vim highlighting file, if it exists
|
||||||
autocmd BufRead,BufNewFile *.[ch] let fname = expand('<afile>:p:h') . '/types.vim'
|
autocmd BufRead,BufNewFile *.[ch] let fname = expand('<afile>:p:h') . '/types.vim'
|
||||||
@@ -5078,7 +5079,7 @@ When splitting the window, the new window will use the original syntax.
|
|||||||
17. Color xterms *xterm-color* *color-xterm*
|
17. Color xterms *xterm-color* *color-xterm*
|
||||||
|
|
||||||
Most color xterms have only eight colors. If you don't get colors with the
|
Most color xterms have only eight colors. If you don't get colors with the
|
||||||
default setup, it should work with these lines in your .vimrc: >
|
default setup, it should work with these lines in your vimrc: >
|
||||||
:if &term =~ "xterm"
|
:if &term =~ "xterm"
|
||||||
: if has("terminfo")
|
: if has("terminfo")
|
||||||
: set t_Co=8
|
: set t_Co=8
|
||||||
@@ -5125,7 +5126,7 @@ supports. >
|
|||||||
If you only get 8 colors, check the xterm compilation settings.
|
If you only get 8 colors, check the xterm compilation settings.
|
||||||
(Also see |UTF8-xterm| for using this xterm with UTF-8 character encoding).
|
(Also see |UTF8-xterm| for using this xterm with UTF-8 character encoding).
|
||||||
|
|
||||||
This xterm should work with these lines in your .vimrc (for 16 colors): >
|
This xterm should work with these lines in your vimrc (for 16 colors): >
|
||||||
:if has("terminfo")
|
:if has("terminfo")
|
||||||
: set t_Co=16
|
: set t_Co=16
|
||||||
: set t_AB=<Esc>[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{92}%+%;%dm
|
: set t_AB=<Esc>[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{92}%+%;%dm
|
||||||
|
@@ -37,7 +37,7 @@ used. Also see |xterm-screens|.
|
|||||||
Settings depending on terminal *term-dependent-settings*
|
Settings depending on terminal *term-dependent-settings*
|
||||||
|
|
||||||
If you want to set options or mappings, depending on the terminal name, you
|
If you want to set options or mappings, depending on the terminal name, you
|
||||||
can do this best in your .vimrc. Example: >
|
can do this best in your vimrc. Example: >
|
||||||
|
|
||||||
if &term == "xterm"
|
if &term == "xterm"
|
||||||
... xterm maps and settings ...
|
... xterm maps and settings ...
|
||||||
|
@@ -98,7 +98,7 @@ What you need:
|
|||||||
- An identifier database file called "ID" in the current directory. You can
|
- An identifier database file called "ID" in the current directory. You can
|
||||||
create it with the shell command "mkid file1 file2 ..".
|
create it with the shell command "mkid file1 file2 ..".
|
||||||
|
|
||||||
Put this in your .vimrc: >
|
Put this in your |init.vim|: >
|
||||||
map _u :call ID_search()<Bar>execute "/\\<" . g:word . "\\>"<CR>
|
map _u :call ID_search()<Bar>execute "/\\<" . g:word . "\\>"<CR>
|
||||||
map _n :n<Bar>execute "/\\<" . g:word . "\\>"<CR>
|
map _n :n<Bar>execute "/\\<" . g:word . "\\>"<CR>
|
||||||
|
|
||||||
@@ -404,7 +404,7 @@ See section |23.4| of the user manual.
|
|||||||
|
|
||||||
If one has a particular extension that one uses for binary files (such as exe,
|
If one has a particular extension that one uses for binary files (such as exe,
|
||||||
bin, etc), you may find it helpful to automate the process with the following
|
bin, etc), you may find it helpful to automate the process with the following
|
||||||
bit of autocmds for your <.vimrc>. Change that "*.bin" to whatever
|
bit of autocmds for your |init.vim|. Change that "*.bin" to whatever
|
||||||
comma-separated list of extension(s) you find yourself wanting to edit: >
|
comma-separated list of extension(s) you find yourself wanting to edit: >
|
||||||
|
|
||||||
" vim -b : edit binary using xxd-format!
|
" vim -b : edit binary using xxd-format!
|
||||||
|
@@ -60,10 +60,7 @@ make them visible with: >
|
|||||||
It's not required for this tutorial, but we provide an example vimrc you may
|
It's not required for this tutorial, but we provide an example vimrc you may
|
||||||
use:
|
use:
|
||||||
|
|
||||||
Unix: >
|
:!cp -i $VIMRUNTIME/vimrc_example.vim ~/.config/nvim/init.vim
|
||||||
:!cp -i $VIMRUNTIME/vimrc_example.vim ~/.vimrc
|
|
||||||
MS-DOS, MS-Windows: >
|
|
||||||
:!copy $VIMRUNTIME/vimrc_example.vim $VIM/_vimrc
|
|
||||||
|
|
||||||
If the file already exists you probably want to keep it.
|
If the file already exists you probably want to keep it.
|
||||||
|
|
||||||
|
@@ -470,7 +470,7 @@ If you like one of the options mentioned before, and set it each time you use
|
|||||||
Vim, you can put the command in your Vim startup file. Edit the file, for
|
Vim, you can put the command in your Vim startup file. Edit the file, for
|
||||||
example with: >
|
example with: >
|
||||||
|
|
||||||
:edit ~/.vimrc
|
:edit ~/.config/nvim/init.vim
|
||||||
|
|
||||||
Then add a line with the command to set the option, just like you typed it in
|
Then add a line with the command to set the option, just like you typed it in
|
||||||
Vim. Example: >
|
Vim. Example: >
|
||||||
|
@@ -22,30 +22,24 @@ Vim's capabilities. Or define your own macros.
|
|||||||
Table of contents: |usr_toc.txt|
|
Table of contents: |usr_toc.txt|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
*05.1* The vimrc file *vimrc-intro*
|
*05.1* The vimrc file *vimrc-intro*
|
||||||
|
|
||||||
You probably got tired of typing commands that you use very often. To start
|
You probably got tired of typing commands that you use very often. To start
|
||||||
Vim with all your favorite option settings and mappings, you write them in
|
Vim with all your favorite option settings and mappings, you write them in
|
||||||
what is called the vimrc file. Vim executes the commands in this file when it
|
what is called the init.vim file. Vim executes the commands in this file when
|
||||||
starts up.
|
it starts up.
|
||||||
|
|
||||||
If you already have a vimrc file (e.g., when your sysadmin has one setup for
|
If you already have a init.vim file (e.g., when your sysadmin has one setup
|
||||||
you), you can edit it this way: >
|
for you), you can edit it this way: >
|
||||||
|
|
||||||
:edit $MYVIMRC
|
:edit $MYVIMRC
|
||||||
|
|
||||||
If you don't have a vimrc file yet, see |vimrc| to find out where you can
|
If you don't have a vimrc file yet, see |init.vim| to find out where you can
|
||||||
create a vimrc file. Also, the ":version" command mentions the name of the
|
create a vimrc file.
|
||||||
"user vimrc file" Vim looks for.
|
|
||||||
|
|
||||||
For Unix and Macintosh this file is always used and is recommended:
|
For Unix and Macintosh this file is always used and is recommended:
|
||||||
|
|
||||||
~/.vimrc ~
|
~/.config/nvim/init.vim ~
|
||||||
|
|
||||||
For MS-DOS and MS-Windows you can use one of these:
|
|
||||||
|
|
||||||
$HOME/_vimrc ~
|
|
||||||
$VIM/_vimrc ~
|
|
||||||
|
|
||||||
The vimrc file can contain all the commands that you type after a colon. The
|
The vimrc file can contain all the commands that you type after a colon. The
|
||||||
most simple ones are for setting options. For example, if you want Vim to
|
most simple ones are for setting options. For example, if you want Vim to
|
||||||
@@ -300,23 +294,20 @@ First read the text in the plugin itself to check for any special conditions.
|
|||||||
Then copy the file to your plugin directory:
|
Then copy the file to your plugin directory:
|
||||||
|
|
||||||
system plugin directory ~
|
system plugin directory ~
|
||||||
Unix ~/.vim/plugin/
|
Unix ~/.local/share/nvim/site/plugin
|
||||||
Macintosh $VIM:vimfiles:plugin
|
|
||||||
Mac OS X ~/.vim/plugin/
|
|
||||||
|
|
||||||
Example for Unix (assuming you didn't have a plugin directory yet): >
|
Example for Unix (assuming you didn't have a plugin directory yet): >
|
||||||
|
|
||||||
mkdir ~/.vim
|
mkdir -p ~/.local/share/nvim/site/plugin
|
||||||
mkdir ~/.vim/plugin
|
cp /usr/local/share/vim/vim60/macros/justify.vim ~/.local/share/nvim/site/plugin
|
||||||
cp /usr/local/share/vim/vim60/macros/justify.vim ~/.vim/plugin
|
|
||||||
|
|
||||||
That's all! Now you can use the commands defined in this plugin to justify
|
That's all! Now you can use the commands defined in this plugin to justify
|
||||||
text.
|
text.
|
||||||
|
|
||||||
Instead of putting plugins directly into the plugin/ directory, you may
|
Instead of putting plugins directly into the plugin/ directory, you may
|
||||||
better organize them by putting them into subdirectories under plugin/.
|
better organize them by putting them into subdirectories under plugin/.
|
||||||
As an example, consider using "~/.vim/plugin/perl/*.vim" for all your Perl
|
As an example, consider using "~/.local/share/nvim/site/plugin/perl/*.vim" for
|
||||||
plugins.
|
all your Perl plugins.
|
||||||
|
|
||||||
|
|
||||||
FILETYPE PLUGINS *add-filetype-plugin* *ftplugins*
|
FILETYPE PLUGINS *add-filetype-plugin* *ftplugins*
|
||||||
@@ -350,25 +341,19 @@ plugins, but the last part is "ftplugin". Suppose you have found a plugin for
|
|||||||
the "stuff" filetype, and you are on Unix. Then you can move this file to the
|
the "stuff" filetype, and you are on Unix. Then you can move this file to the
|
||||||
ftplugin directory: >
|
ftplugin directory: >
|
||||||
|
|
||||||
mv thefile ~/.vim/ftplugin/stuff.vim
|
mkdir -p ~/.local/share/nvim/site/ftplugin
|
||||||
|
mv thefile ~/.local/share/nvim/site/ftplugin/stuff.vim
|
||||||
|
|
||||||
If that file already exists you already have a plugin for "stuff". You might
|
If that file already exists you already have a plugin for "stuff". You might
|
||||||
want to check if the existing plugin doesn't conflict with the one you are
|
want to check if the existing plugin doesn't conflict with the one you are
|
||||||
adding. If it's OK, you can give the new one another name: >
|
adding. If it's OK, you can give the new one another name: >
|
||||||
|
|
||||||
mv thefile ~/.vim/ftplugin/stuff_too.vim
|
mv thefile ~/.local/share/nvim/site/ftplugin/stuff_too.vim
|
||||||
|
|
||||||
The underscore is used to separate the name of the filetype from the rest,
|
The underscore is used to separate the name of the filetype from the rest,
|
||||||
which can be anything. If you use "otherstuff.vim" it wouldn't work, it would
|
which can be anything. If you use "otherstuff.vim" it wouldn't work, it would
|
||||||
be loaded for the "otherstuff" filetype.
|
be loaded for the "otherstuff" filetype.
|
||||||
|
|
||||||
On MS-DOS you cannot use long filenames. You would run into trouble if you
|
|
||||||
add a second plugin and the filetype has more than six characters. You can
|
|
||||||
use an extra directory to get around this: >
|
|
||||||
|
|
||||||
mkdir $VIM/vimfiles/ftplugin/fortran
|
|
||||||
copy thefile $VIM/vimfiles/ftplugin/fortran/too.vim
|
|
||||||
|
|
||||||
The generic names for the filetype plugins are: >
|
The generic names for the filetype plugins are: >
|
||||||
|
|
||||||
ftplugin/<filetype>.vim
|
ftplugin/<filetype>.vim
|
||||||
@@ -378,9 +363,9 @@ The generic names for the filetype plugins are: >
|
|||||||
Here "<name>" can be any name that you prefer.
|
Here "<name>" can be any name that you prefer.
|
||||||
Examples for the "stuff" filetype on Unix: >
|
Examples for the "stuff" filetype on Unix: >
|
||||||
|
|
||||||
~/.vim/ftplugin/stuff.vim
|
~/.local/share/nvim/site/ftplugin/stuff.vim
|
||||||
~/.vim/ftplugin/stuff_def.vim
|
~/.local/share/nvim/site/ftplugin/stuff_def.vim
|
||||||
~/.vim/ftplugin/stuff/header.vim
|
~/.local/share/nvim/site/ftplugin/stuff/header.vim
|
||||||
|
|
||||||
The <filetype> part is the name of the filetype the plugin is to be used for.
|
The <filetype> part is the name of the filetype the plugin is to be used for.
|
||||||
Only files of this filetype will use the settings from the plugin. The <name>
|
Only files of this filetype will use the settings from the plugin. The <name>
|
||||||
@@ -410,16 +395,16 @@ non-standard place (it usually resides in a sub-folder called `doc/`).
|
|||||||
|
|
||||||
First, create a "doc" directory in one of the directories in 'runtimepath': >
|
First, create a "doc" directory in one of the directories in 'runtimepath': >
|
||||||
|
|
||||||
:!mkdir ~/.vim/doc
|
:!mkdir -p ~/.local/share/nvim/site/doc
|
||||||
|
|
||||||
Now, copy the help file to the "doc" directory: >
|
Now, copy the help file to the "doc" directory: >
|
||||||
|
|
||||||
:!cp my-plugin/my-plugin-doc.txt ~/.vim/doc
|
:!cp my-plugin/my-plugin-doc.txt ~/.local/share/nvim/site/doc
|
||||||
|
|
||||||
Here comes the trick, which allows you to jump to the subjects in the new help
|
Here comes the trick, which allows you to jump to the subjects in the new help
|
||||||
file. Generate the local tags file with the |:helptags| command: >
|
file. Generate the local tags file with the |:helptags| command: >
|
||||||
|
|
||||||
:helptags ~/.vim/doc
|
:helptags ~/.local/share/nvim/site/doc
|
||||||
|
|
||||||
You can see an entry for the local help file when you do: >
|
You can see an entry for the local help file when you do: >
|
||||||
|
|
||||||
|
@@ -35,17 +35,17 @@ easy to overview the file. After a while you will find that black&white text
|
|||||||
slows you down!
|
slows you down!
|
||||||
|
|
||||||
If you always want to use syntax highlighting, put the ":syntax enable"
|
If you always want to use syntax highlighting, put the ":syntax enable"
|
||||||
command in your |vimrc| file.
|
command in your |init.vim| file.
|
||||||
|
|
||||||
If you want syntax highlighting only when the terminal supports colors, you
|
If you want syntax highlighting only when the terminal supports colors, you
|
||||||
can put this in your |vimrc| file: >
|
can put this in your |init.vim| file: >
|
||||||
|
|
||||||
if &t_Co > 1
|
if &t_Co > 1
|
||||||
syntax enable
|
syntax enable
|
||||||
endif
|
endif
|
||||||
|
|
||||||
If you want syntax highlighting only in the GUI version, put the ":syntax
|
If you want syntax highlighting only in the GUI version, put the ":syntax
|
||||||
enable" command in your |gvimrc| file.
|
enable" command in your |ginit.vim| file.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
*06.2* No or wrong colors?
|
*06.2* No or wrong colors?
|
||||||
@@ -144,14 +144,14 @@ the GUI use the Edit/Color Scheme menu. You can also type the command: >
|
|||||||
want to try out. Look in the directory $VIMRUNTIME/colors.
|
want to try out. Look in the directory $VIMRUNTIME/colors.
|
||||||
|
|
||||||
When you found the color scheme that you like, add the ":colorscheme" command
|
When you found the color scheme that you like, add the ":colorscheme" command
|
||||||
to your |vimrc| file.
|
to your |init.vim| file.
|
||||||
|
|
||||||
You could also write your own color scheme. This is how you do it:
|
You could also write your own color scheme. This is how you do it:
|
||||||
|
|
||||||
1. Select a color scheme that comes close. Copy this file to your own Vim
|
1. Select a color scheme that comes close. Copy this file to your own Vim
|
||||||
directory. For Unix, this should work: >
|
directory. For Unix, this should work: >
|
||||||
|
|
||||||
!mkdir ~/.vim/colors
|
!mkdir -p ~/.config/nvim/colors
|
||||||
!cp $VIMRUNTIME/colors/morning.vim ~/.vim/colors/mine.vim
|
!cp $VIMRUNTIME/colors/morning.vim ~/.vim/colors/mine.vim
|
||||||
<
|
<
|
||||||
This is done from Vim, because it knows the value of $VIMRUNTIME.
|
This is done from Vim, because it knows the value of $VIMRUNTIME.
|
||||||
|
@@ -169,7 +169,7 @@ exiting Vim, there is a slightly more complicated way. You can see a list of
|
|||||||
files by typing the command: >
|
files by typing the command: >
|
||||||
|
|
||||||
:oldfiles
|
:oldfiles
|
||||||
< 1: ~/.vimrc ~
|
< 1: ~/.config/nvim/init.vim ~
|
||||||
2: ~/text/resume.txt ~
|
2: ~/text/resume.txt ~
|
||||||
3: /tmp/draft ~
|
3: /tmp/draft ~
|
||||||
|
|
||||||
@@ -189,7 +189,7 @@ That #<123 thing is a bit complicated when you just want to edit a file.
|
|||||||
Fortunately there is a simpler way: >
|
Fortunately there is a simpler way: >
|
||||||
|
|
||||||
:browse oldfiles
|
:browse oldfiles
|
||||||
< 1: ~/.vimrc ~
|
< 1: ~/.config/nvim/init.vim ~
|
||||||
2: ~/text/resume.txt ~
|
2: ~/text/resume.txt ~
|
||||||
3: /tmp/draft ~
|
3: /tmp/draft ~
|
||||||
-- More --
|
-- More --
|
||||||
@@ -276,13 +276,13 @@ example, use: >
|
|||||||
SESSION HERE, SESSION THERE
|
SESSION HERE, SESSION THERE
|
||||||
|
|
||||||
The obvious way to use sessions is when working on different projects.
|
The obvious way to use sessions is when working on different projects.
|
||||||
Suppose you store your session files in the directory "~/.vim". You are
|
Suppose you store your session files in the directory "~/.config/nvim". You
|
||||||
currently working on the "secret" project and have to switch to the "boring"
|
are currently working on the "secret" project and have to switch to the
|
||||||
project: >
|
"boring" project: >
|
||||||
|
|
||||||
:wall
|
:wall
|
||||||
:mksession! ~/.vim/secret.vim
|
:mksession! ~/.config/nvim/secret.vim
|
||||||
:source ~/.vim/boring.vim
|
:source ~/.config/nvim/boring.vim
|
||||||
|
|
||||||
This first uses ":wall" to write all modified files. Then the current session
|
This first uses ":wall" to write all modified files. Then the current session
|
||||||
is saved, using ":mksession!". This overwrites the previous session. The
|
is saved, using ":mksession!". This overwrites the previous session. The
|
||||||
@@ -292,7 +292,7 @@ point. And finally you load the new "boring" session.
|
|||||||
If you open help windows, split and close various windows, and generally mess
|
If you open help windows, split and close various windows, and generally mess
|
||||||
up the window layout, you can go back to the last saved session: >
|
up the window layout, you can go back to the last saved session: >
|
||||||
|
|
||||||
:source ~/.vim/boring.vim
|
:source ~/.config/nvim/boring.vim
|
||||||
|
|
||||||
Thus you have complete control over whether you want to continue next time
|
Thus you have complete control over whether you want to continue next time
|
||||||
where you are now, by saving the current setup in a session, or keep the
|
where you are now, by saving the current setup in a session, or keep the
|
||||||
@@ -330,11 +330,11 @@ More about this in the next chapter.
|
|||||||
|
|
||||||
You can resize the windows a bit to your liking. Then save the session with:
|
You can resize the windows a bit to your liking. Then save the session with:
|
||||||
>
|
>
|
||||||
:mksession ~/.vim/mine.vim
|
:mksession ~/.config/nvim/mine.vim
|
||||||
|
|
||||||
Now you can start Vim with this layout: >
|
Now you can start Vim with this layout: >
|
||||||
|
|
||||||
vim -S ~/.vim/mine.vim
|
vim -S ~/.config/nvim/mine.vim
|
||||||
|
|
||||||
Hint: To open a file you see listed in the explorer window in the empty
|
Hint: To open a file you see listed in the explorer window in the empty
|
||||||
window, move the cursor to the filename and press "O". Double clicking with
|
window, move the cursor to the filename and press "O". Double clicking with
|
||||||
@@ -346,8 +346,8 @@ UNIX AND MS-WINDOWS
|
|||||||
Some people have to do work on MS-Windows systems one day and on Unix another
|
Some people have to do work on MS-Windows systems one day and on Unix another
|
||||||
day. If you are one of them, consider adding "slash" and "unix" to
|
day. If you are one of them, consider adding "slash" and "unix" to
|
||||||
'sessionoptions'. The session files will then be written in a format that can
|
'sessionoptions'. The session files will then be written in a format that can
|
||||||
be used on both systems. This is the command to put in your vimrc file: >
|
be used on both systems. This is the command to put in your |init.vim| file:
|
||||||
|
>
|
||||||
:set sessionoptions+=unix,slash
|
:set sessionoptions+=unix,slash
|
||||||
|
|
||||||
Vim will use the Unix format then, because the MS-Windows Vim can read and
|
Vim will use the Unix format then, because the MS-Windows Vim can read and
|
||||||
@@ -368,13 +368,13 @@ another session.
|
|||||||
You might prefer to keep the info with the session. You will have to do
|
You might prefer to keep the info with the session. You will have to do
|
||||||
this yourself then. Example: >
|
this yourself then. Example: >
|
||||||
|
|
||||||
:mksession! ~/.vim/secret.vim
|
:mksession! ~/.config/nvim/secret.vim
|
||||||
:wshada! ~/.vim/secret.shada
|
:wshada! ~/.local/share/nvim/shada/secret.shada
|
||||||
|
|
||||||
And to restore this again: >
|
And to restore this again: >
|
||||||
|
|
||||||
:source ~/.vim/secret.vim
|
:source ~/.config/nvim/secret.vim
|
||||||
:rshada! ~/.vim/secret.shada
|
:rshada! ~/.local/share/nvim/shada/secret.shada
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
*21.5* Views
|
*21.5* Views
|
||||||
@@ -423,11 +423,11 @@ to quickly switch to editing another file, with all its options set as you
|
|||||||
saved them.
|
saved them.
|
||||||
For example, to save the view of the current file: >
|
For example, to save the view of the current file: >
|
||||||
|
|
||||||
:mkview ~/.vim/main.vim
|
:mkview ~/.config/nvim/main.vim
|
||||||
|
|
||||||
You can restore it with: >
|
You can restore it with: >
|
||||||
|
|
||||||
:source ~/.vim/main.vim
|
:source ~/.config/nvim/main.vim
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
*21.6* Modelines
|
*21.6* Modelines
|
||||||
|
@@ -324,11 +324,11 @@ the output of this command: >
|
|||||||
Now use the first item, the name before the first comma. Thus if the output
|
Now use the first item, the name before the first comma. Thus if the output
|
||||||
looks like this:
|
looks like this:
|
||||||
|
|
||||||
runtimepath=~/.vim,/usr/local/share/vim/vim60/runtime,~/.vim/after ~
|
runtimepath=~/.config/nvim,/usr/local/share/vim/vim60/runtime,~/.config/nvim/after ~
|
||||||
|
|
||||||
You use "~/.vim" for {directory}. Then the resulting file name is:
|
You use "~/.config/nvim" for {directory}. Then the resulting file name is:
|
||||||
|
|
||||||
~/.vim/indent/help.vim ~
|
~/.config/nvim/indent/help.vim ~
|
||||||
|
|
||||||
Instead of switching the indenting off, you could write your own indent file.
|
Instead of switching the indenting off, you could write your own indent file.
|
||||||
How to do that is explained here: |indent-expression|.
|
How to do that is explained here: |indent-expression|.
|
||||||
|
@@ -248,7 +248,7 @@ you can set the 'lines' option to set a different window size: >
|
|||||||
You don't want to do this in a terminal, since its size is fixed (except for
|
You don't want to do this in a terminal, since its size is fixed (except for
|
||||||
an xterm that supports resizing).
|
an xterm that supports resizing).
|
||||||
The gvimrc file is searched for in the same locations as the vimrc file.
|
The gvimrc file is searched for in the same locations as the vimrc file.
|
||||||
Normally its name is "~/.gvimrc" for Unix and "$VIM/_gvimrc" for MS-Windows.
|
Normally its name is "~/.config/nvim/ginit.vim".
|
||||||
The $MYGVIMRC environment variable is set to it, thus you can use this command
|
The $MYGVIMRC environment variable is set to it, thus you can use this command
|
||||||
to edit the file, if you have one: >
|
to edit the file, if you have one: >
|
||||||
|
|
||||||
|
@@ -478,7 +478,7 @@ for you. This triggers the Filetype event. Use this to do something when a
|
|||||||
certain type of file is edited. For example, to load a list of abbreviations
|
certain type of file is edited. For example, to load a list of abbreviations
|
||||||
for text files: >
|
for text files: >
|
||||||
|
|
||||||
:autocmd Filetype text source ~/.vim/abbrevs.vim
|
:autocmd Filetype text source ~/.config/nvim/abbrevs.vim
|
||||||
|
|
||||||
When starting to edit a new file, you could make Vim insert a skeleton: >
|
When starting to edit a new file, you could make Vim insert a skeleton: >
|
||||||
|
|
||||||
|
@@ -2051,8 +2051,8 @@ Example: >
|
|||||||
|
|
||||||
Write this single-line file as "ftdetect/foofoo.vim" in the first directory
|
Write this single-line file as "ftdetect/foofoo.vim" in the first directory
|
||||||
that appears in 'runtimepath'. For Unix that would be
|
that appears in 'runtimepath'. For Unix that would be
|
||||||
"~/.vim/ftdetect/foofoo.vim". The convention is to use the name of the
|
"~/.config/nvim/ftdetect/foofoo.vim". The convention is to use the name of
|
||||||
filetype for the script name.
|
the filetype for the script name.
|
||||||
|
|
||||||
You can make more complicated checks if you like, for example to inspect the
|
You can make more complicated checks if you like, for example to inspect the
|
||||||
contents of the file to recognize the language. Also see |new-filetype|.
|
contents of the file to recognize the language. Also see |new-filetype|.
|
||||||
@@ -2122,8 +2122,8 @@ you can write the different setting in a script: >
|
|||||||
|
|
||||||
Now write this in the "after" directory, so that it gets sourced after the
|
Now write this in the "after" directory, so that it gets sourced after the
|
||||||
distributed "vim.vim" ftplugin |after-directory|. For Unix this would be
|
distributed "vim.vim" ftplugin |after-directory|. For Unix this would be
|
||||||
"~/.vim/after/ftplugin/vim.vim". Note that the default plugin will have set
|
"~/.config/nvim/after/ftplugin/vim.vim". Note that the default plugin will
|
||||||
"b:did_ftplugin", but it is ignored here.
|
have set "b:did_ftplugin", but it is ignored here.
|
||||||
|
|
||||||
|
|
||||||
OPTIONS
|
OPTIONS
|
||||||
@@ -2289,8 +2289,8 @@ a user to overrule or add to the default file. The default files start with: >
|
|||||||
:let current_compiler = "mine"
|
:let current_compiler = "mine"
|
||||||
|
|
||||||
When you write a compiler file and put it in your personal runtime directory
|
When you write a compiler file and put it in your personal runtime directory
|
||||||
(e.g., ~/.vim/compiler for Unix), you set the "current_compiler" variable to
|
(e.g., ~/.config/nvim/compiler for Unix), you set the "current_compiler"
|
||||||
make the default file skip the settings.
|
variable to make the default file skip the settings.
|
||||||
*:CompilerSet*
|
*:CompilerSet*
|
||||||
The second mechanism is to use ":set" for ":compiler!" and ":setlocal" for
|
The second mechanism is to use ":set" for ":compiler!" and ":setlocal" for
|
||||||
":compiler". Vim defines the ":CompilerSet" user command for this. However,
|
":compiler". Vim defines the ":CompilerSet" user command for this. However,
|
||||||
@@ -2310,7 +2310,7 @@ runtime directory, use the mechanism mentioned above. When
|
|||||||
When you write a compiler plugin to overrule settings from a default plugin,
|
When you write a compiler plugin to overrule settings from a default plugin,
|
||||||
don't check "current_compiler". This plugin is supposed to be loaded
|
don't check "current_compiler". This plugin is supposed to be loaded
|
||||||
last, thus it should be in a directory at the end of 'runtimepath'. For Unix
|
last, thus it should be in a directory at the end of 'runtimepath'. For Unix
|
||||||
that could be ~/.vim/after/compiler.
|
that could be ~/.config/nvim/after/compiler.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
*41.14* Writing a plugin that loads quickly *write-plugin-quickload*
|
*41.14* Writing a plugin that loads quickly *write-plugin-quickload*
|
||||||
@@ -2428,7 +2428,7 @@ want to use subdirectories. Example: >
|
|||||||
|
|
||||||
For Unix the library script used for this could be:
|
For Unix the library script used for this could be:
|
||||||
|
|
||||||
~/.vim/autoload/netlib/ftp.vim
|
~/.config/nvim/autoload/netlib/ftp.vim
|
||||||
|
|
||||||
Where the function is defined like this: >
|
Where the function is defined like this: >
|
||||||
|
|
||||||
|
@@ -311,7 +311,7 @@ with the name "Compile.bmp". For Unix XPM format is used, the file name is
|
|||||||
"Compile.xpm". The size must be 18 by 18 pixels. On MS-Windows other sizes
|
"Compile.xpm". The size must be 18 by 18 pixels. On MS-Windows other sizes
|
||||||
can be used as well, but it will look ugly.
|
can be used as well, but it will look ugly.
|
||||||
Put the bitmap in the directory "bitmaps" in one of the directories from
|
Put the bitmap in the directory "bitmaps" in one of the directories from
|
||||||
'runtimepath'. E.g., for Unix "~/.vim/bitmaps/Compile.xpm".
|
'runtimepath'. E.g., for Unix "~/.config/nvim/bitmaps/Compile.xpm".
|
||||||
|
|
||||||
You can define tooltips for the items in the toolbar. A tooltip is a short
|
You can define tooltips for the items in the toolbar. A tooltip is a short
|
||||||
text that explains what a toolbar item will do. For example "Open file". It
|
text that explains what a toolbar item will do. For example "Open file". It
|
||||||
|
@@ -27,22 +27,21 @@ want to set the 'softtabstop' option to 4 and define a mapping to insert a
|
|||||||
three-line comment. You do this with only two steps:
|
three-line comment. You do this with only two steps:
|
||||||
|
|
||||||
*your-runtime-dir*
|
*your-runtime-dir*
|
||||||
1. Create your own runtime directory. On Unix this usually is "~/.vim". In
|
1. Create your own runtime directory. On Unix this usually is
|
||||||
this directory create the "ftplugin" directory: >
|
"~/.config/nvim". In this directory create the "ftplugin" directory: >
|
||||||
|
|
||||||
mkdir ~/.vim
|
mkdir -p ~/.config/nvim/ftplugin
|
||||||
mkdir ~/.vim/ftplugin
|
|
||||||
<
|
<
|
||||||
When you are not on Unix, check the value of the 'runtimepath' option to
|
When you are not on Unix, check the value of the 'runtimepath' option to
|
||||||
see where Vim will look for the "ftplugin" directory: >
|
see where Vim will look for the "ftplugin" directory: >
|
||||||
|
|
||||||
set runtimepath
|
set runtimepath?
|
||||||
|
|
||||||
< You would normally use the first directory name (before the first comma).
|
< You would normally use the first directory name (before the first comma).
|
||||||
You might want to prepend a directory name to the 'runtimepath' option in
|
You might want to prepend a directory name to the 'runtimepath' option in
|
||||||
your |vimrc| file if you don't like the default value.
|
your |init.vim| file if you don't like the default value.
|
||||||
|
|
||||||
2. Create the file "~/.vim/ftplugin/c.vim", with the contents: >
|
2. Create the file "~/.config/nvim/ftplugin/c.vim", with the contents: >
|
||||||
|
|
||||||
setlocal softtabstop=4
|
setlocal softtabstop=4
|
||||||
noremap <buffer> <LocalLeader>c o/**************<CR><CR>/<Esc>
|
noremap <buffer> <LocalLeader>c o/**************<CR><CR>/<Esc>
|
||||||
@@ -102,26 +101,26 @@ However, if you now edit a file /usr/share/scripts/README.txt, this is not a
|
|||||||
ruby file. The danger of a pattern ending in "*" is that it quickly matches
|
ruby file. The danger of a pattern ending in "*" is that it quickly matches
|
||||||
too many files. To avoid trouble with this, put the filetype.vim file in
|
too many files. To avoid trouble with this, put the filetype.vim file in
|
||||||
another directory, one that is at the end of 'runtimepath'. For Unix for
|
another directory, one that is at the end of 'runtimepath'. For Unix for
|
||||||
example, you could use "~/.vim/after/filetype.vim".
|
example, you could use "~/.config/nvim/after/filetype.vim".
|
||||||
You now put the detection of text files in ~/.vim/filetype.vim: >
|
You now put the detection of text files in ~/.config/nvim/filetype.vim: >
|
||||||
|
|
||||||
augroup filetypedetect
|
augroup filetypedetect
|
||||||
au BufNewFile,BufRead *.txt setf text
|
au BufNewFile,BufRead *.txt setf text
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
That file is found in 'runtimepath' first. Then use this in
|
That file is found in 'runtimepath' first. Then use this in
|
||||||
~/.vim/after/filetype.vim, which is found last: >
|
~/.config/nvim/after/filetype.vim, which is found last: >
|
||||||
|
|
||||||
augroup filetypedetect
|
augroup filetypedetect
|
||||||
au BufNewFile,BufRead /usr/share/scripts/* setf ruby
|
au BufNewFile,BufRead /usr/share/scripts/* setf ruby
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
What will happen now is that Vim searches for "filetype.vim" files in each
|
What will happen now is that Vim searches for "filetype.vim" files in each
|
||||||
directory in 'runtimepath'. First ~/.vim/filetype.vim is found. The
|
directory in 'runtimepath'. First ~/.config/nvim/filetype.vim is found. The
|
||||||
autocommand to catch *.txt files is defined there. Then Vim finds the
|
autocommand to catch *.txt files is defined there. Then Vim finds the
|
||||||
filetype.vim file in $VIMRUNTIME, which is halfway 'runtimepath'. Finally
|
filetype.vim file in $VIMRUNTIME, which is halfway 'runtimepath'. Finally
|
||||||
~/.vim/after/filetype.vim is found and the autocommand for detecting ruby
|
~/.config/nvim/after/filetype.vim is found and the autocommand for detecting
|
||||||
files in /usr/share/scripts is added.
|
ruby files in /usr/share/scripts is added.
|
||||||
When you now edit /usr/share/scripts/README.txt, the autocommands are
|
When you now edit /usr/share/scripts/README.txt, the autocommands are
|
||||||
checked in the order in which they were defined. The *.txt pattern matches,
|
checked in the order in which they were defined. The *.txt pattern matches,
|
||||||
thus "setf text" is executed to set the filetype to "text". The pattern for
|
thus "setf text" is executed to set the filetype to "text". The pattern for
|
||||||
|
@@ -610,11 +610,11 @@ More about synchronizing in the reference manual: |:syn-sync|.
|
|||||||
*44.11* Installing a syntax file
|
*44.11* Installing a syntax file
|
||||||
|
|
||||||
When your new syntax file is ready to be used, drop it in a "syntax" directory
|
When your new syntax file is ready to be used, drop it in a "syntax" directory
|
||||||
in 'runtimepath'. For Unix that would be "~/.vim/syntax".
|
in 'runtimepath'. For Unix that would be "~/.config/nvim/syntax".
|
||||||
The name of the syntax file must be equal to the file type, with ".vim"
|
The name of the syntax file must be equal to the file type, with ".vim"
|
||||||
added. Thus for the x language, the full path of the file would be:
|
added. Thus for the x language, the full path of the file would be:
|
||||||
|
|
||||||
~/.vim/syntax/x.vim ~
|
~/.config/nvim/syntax/x.vim ~
|
||||||
|
|
||||||
You must also make the file type be recognized. See |43.2|.
|
You must also make the file type be recognized. See |43.2|.
|
||||||
|
|
||||||
@@ -640,7 +640,7 @@ Write the file with the same name as the original syntax file. In this case
|
|||||||
"c.vim". Place it in a directory near the end of 'runtimepath'. This makes
|
"c.vim". Place it in a directory near the end of 'runtimepath'. This makes
|
||||||
it loaded after the original syntax file. For Unix this would be:
|
it loaded after the original syntax file. For Unix this would be:
|
||||||
|
|
||||||
~/.vim/after/syntax/c.vim ~
|
~/.config/nvim/after/syntax/c.vim ~
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
*44.12* Portable syntax file layout
|
*44.12* Portable syntax file layout
|
||||||
|
@@ -129,7 +129,7 @@ this name, but with all letters made lowercase. Then copy the file to your
|
|||||||
own runtime directory, as found early in 'runtimepath'. For example, for Unix
|
own runtime directory, as found early in 'runtimepath'. For example, for Unix
|
||||||
you would do: >
|
you would do: >
|
||||||
|
|
||||||
:!cp $VIMRUNTIME/lang/menu_ko_kr.euckr.vim ~/.vim/lang/menu_nl_be.iso_8859-1.vim
|
:!cp $VIMRUNTIME/lang/menu_ko_kr.euckr.vim ~/.config/nvim/lang/menu_nl_be.iso_8859-1.vim
|
||||||
|
|
||||||
You will find hints for the translation in "$VIMRUNTIME/lang/README.txt".
|
You will find hints for the translation in "$VIMRUNTIME/lang/README.txt".
|
||||||
|
|
||||||
@@ -359,7 +359,7 @@ DO-IT-YOURSELF KEYMAPS
|
|||||||
You can create your own keymap file. It's not very difficult. Start with
|
You can create your own keymap file. It's not very difficult. Start with
|
||||||
a keymap file that is similar to the language you want to use. Copy it to the
|
a keymap file that is similar to the language you want to use. Copy it to the
|
||||||
"keymap" directory in your runtime directory. For example, for Unix, you
|
"keymap" directory in your runtime directory. For example, for Unix, you
|
||||||
would use the directory "~/.vim/keymap".
|
would use the directory "~/.config/nvim/keymap".
|
||||||
The name of the keymap file must look like this:
|
The name of the keymap file must look like this:
|
||||||
|
|
||||||
keymap/{name}.vim ~
|
keymap/{name}.vim ~
|
||||||
|
@@ -33,7 +33,7 @@ CTRL-L Clear and redraw the screen. The redraw may happen
|
|||||||
*N<Del>*
|
*N<Del>*
|
||||||
<Del> When entering a number: Remove the last digit.
|
<Del> When entering a number: Remove the last digit.
|
||||||
Note: if you like to use <BS> for this, add this
|
Note: if you like to use <BS> for this, add this
|
||||||
mapping to your .vimrc: >
|
mapping to your vimrc: >
|
||||||
:map CTRL-V <BS> CTRL-V <Del>
|
:map CTRL-V <BS> CTRL-V <Del>
|
||||||
<
|
<
|
||||||
:as[cii] or *ga* *:as* *:ascii*
|
:as[cii] or *ga* *:as* *:ascii*
|
||||||
|
@@ -21,10 +21,11 @@ these differences.
|
|||||||
==============================================================================
|
==============================================================================
|
||||||
1. Configuration *nvim-configuration*
|
1. Configuration *nvim-configuration*
|
||||||
|
|
||||||
- Use `.nvimrc` instead of `.vimrc` for storing configuration.
|
- Use `$XDG_CONFIG_HOME/nvim/init.vim` instead of `.vimrc` for storing
|
||||||
- Use `.nvim` instead of `.vim` to store configuration files.
|
configuration.
|
||||||
- Use `.nvim/shada/main.shada` instead of `.viminfo` for persistent session
|
- Use `$XDG_CONFIG_HOME/nvim` instead of `.vim` to store configuration files.
|
||||||
information.
|
- Use `$XDG_DATA_HOME/shada/main.shada` instead of `.viminfo` for persistent
|
||||||
|
session information.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
2. Option defaults *nvim-option-defaults*
|
2. Option defaults *nvim-option-defaults*
|
||||||
|
211
src/nvim/main.c
211
src/nvim/main.c
@@ -287,8 +287,8 @@ int main(int argc, char **argv)
|
|||||||
* Set the default values for the options that use Rows and Columns.
|
* Set the default values for the options that use Rows and Columns.
|
||||||
*/
|
*/
|
||||||
win_init_size();
|
win_init_size();
|
||||||
/* Set the 'diff' option now, so that it can be checked for in a .vimrc
|
// Set the 'diff' option now, so that it can be checked for in a vimrc
|
||||||
* file. There is no buffer yet though. */
|
// file. There is no buffer yet though.
|
||||||
if (params.diff_mode)
|
if (params.diff_mode)
|
||||||
diff_win_options(firstwin, FALSE);
|
diff_win_options(firstwin, FALSE);
|
||||||
|
|
||||||
@@ -345,7 +345,7 @@ int main(int argc, char **argv)
|
|||||||
*/
|
*/
|
||||||
load_plugins();
|
load_plugins();
|
||||||
|
|
||||||
/* Decide about window layout for diff mode after reading vimrc. */
|
// Decide about window layout for diff mode after reading vimrc.
|
||||||
set_window_layout(¶ms);
|
set_window_layout(¶ms);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -358,10 +358,8 @@ int main(int argc, char **argv)
|
|||||||
mch_exit(0);
|
mch_exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Set a few option defaults after reading vimrc files:
|
||||||
* Set a few option defaults after reading .vimrc files:
|
// 'title' and 'icon', Unix: 'shellpipe' and 'shellredir'.
|
||||||
* 'title' and 'icon', Unix: 'shellpipe' and 'shellredir'.
|
|
||||||
*/
|
|
||||||
set_init_3();
|
set_init_3();
|
||||||
TIME_MSG("inits 3");
|
TIME_MSG("inits 3");
|
||||||
|
|
||||||
@@ -1551,8 +1549,8 @@ static void create_windows(mparm_T *parmp)
|
|||||||
if (parmp->window_count == 0)
|
if (parmp->window_count == 0)
|
||||||
parmp->window_count = GARGCOUNT;
|
parmp->window_count = GARGCOUNT;
|
||||||
if (parmp->window_count > 1) {
|
if (parmp->window_count > 1) {
|
||||||
/* Don't change the windows if there was a command in .vimrc that
|
// Don't change the windows if there was a command in vimrc that
|
||||||
* already split some windows */
|
// already split some windows
|
||||||
if (parmp->window_layout == 0)
|
if (parmp->window_layout == 0)
|
||||||
parmp->window_layout = WIN_HOR;
|
parmp->window_layout = WIN_HOR;
|
||||||
if (parmp->window_layout == WIN_TABS) {
|
if (parmp->window_layout == WIN_TABS) {
|
||||||
@@ -1574,14 +1572,11 @@ static void create_windows(mparm_T *parmp)
|
|||||||
getout(1);
|
getout(1);
|
||||||
do_modelines(0); /* do modelines */
|
do_modelines(0); /* do modelines */
|
||||||
} else {
|
} else {
|
||||||
/*
|
// Open a buffer for windows that don't have one yet.
|
||||||
* Open a buffer for windows that don't have one yet.
|
// Commands in the vimrc might have loaded a file or split the window.
|
||||||
* Commands in the .vimrc might have loaded a file or split the window.
|
// Watch out for autocommands that delete a window.
|
||||||
* Watch out for autocommands that delete a window.
|
//
|
||||||
*/
|
// Don't execute Win/Buf Enter/Leave autocommands here
|
||||||
/*
|
|
||||||
* Don't execute Win/Buf Enter/Leave autocommands here
|
|
||||||
*/
|
|
||||||
++autocmd_no_enter;
|
++autocmd_no_enter;
|
||||||
++autocmd_no_leave;
|
++autocmd_no_leave;
|
||||||
dorewind = TRUE;
|
dorewind = TRUE;
|
||||||
@@ -1691,8 +1686,8 @@ static void edit_buffers(mparm_T *parmp)
|
|||||||
}
|
}
|
||||||
advance = TRUE;
|
advance = TRUE;
|
||||||
|
|
||||||
/* Only open the file if there is no file in this window yet (that can
|
// Only open the file if there is no file in this window yet (that can
|
||||||
* happen when .vimrc contains ":sall"). */
|
// happen when vimrc contains ":sall").
|
||||||
if (curbuf == firstwin->w_buffer || curbuf->b_ffname == NULL) {
|
if (curbuf == firstwin->w_buffer || curbuf->b_ffname == NULL) {
|
||||||
curwin->w_arg_idx = arg_idx;
|
curwin->w_arg_idx = arg_idx;
|
||||||
/* Edit file from arg list, if there is one. When "Quit" selected
|
/* Edit file from arg list, if there is one. When "Quit" selected
|
||||||
@@ -1801,117 +1796,121 @@ static void exe_commands(mparm_T *parmp)
|
|||||||
TIME_MSG("executing command arguments");
|
TIME_MSG("executing command arguments");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// Source vimrc or do other user initialization
|
||||||
* Source startup scripts.
|
///
|
||||||
*/
|
/// Does one of the following things, stops after whichever succeeds:
|
||||||
static void source_startup_scripts(mparm_T *parmp)
|
///
|
||||||
|
/// 1. Execution of VIMINIT environment variable.
|
||||||
|
/// 2. Sourcing user vimrc file ($XDG_CONFIG_HOME/nvim/init.vim).
|
||||||
|
/// 3. Sourcing other vimrc files ($XDG_CONFIG_DIRS[1]/nvim/init.vim, …).
|
||||||
|
/// 4. Execution of EXINIT environment variable.
|
||||||
|
///
|
||||||
|
/// @return True if it is needed to attempt to source exrc file according to
|
||||||
|
/// 'exrc' option definition.
|
||||||
|
static bool do_user_initialization(void)
|
||||||
|
FUNC_ATTR_WARN_UNUSED_RESULT
|
||||||
{
|
{
|
||||||
int i;
|
bool do_exrc = p_exrc;
|
||||||
|
if (process_env("VIMINIT", true) == OK) {
|
||||||
|
return do_exrc;
|
||||||
|
}
|
||||||
|
char_u *user_vimrc = (char_u *)stdpaths_user_conf_subpath("init.vim");
|
||||||
|
if (do_source(user_vimrc, true, DOSO_VIMRC) != FAIL) {
|
||||||
|
if (do_exrc) {
|
||||||
|
do_exrc = (path_full_compare((char_u *)VIMRC_FILE, user_vimrc, false)
|
||||||
|
!= kEqualFiles);
|
||||||
|
}
|
||||||
|
xfree(user_vimrc);
|
||||||
|
return do_exrc;
|
||||||
|
}
|
||||||
|
xfree(user_vimrc);
|
||||||
|
char *const config_dirs = stdpaths_get_xdg_var(kXDGConfigDirs);
|
||||||
|
if (config_dirs != NULL) {
|
||||||
|
const void *iter = NULL;
|
||||||
|
do {
|
||||||
|
const char *dir;
|
||||||
|
size_t dir_len;
|
||||||
|
iter = vim_colon_env_iter(config_dirs, iter, &dir, &dir_len);
|
||||||
|
if (dir == NULL || dir_len == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
const char path_tail[] = { 'n', 'v', 'i', 'm', PATHSEP,
|
||||||
|
'i', 'n', 'i', 't', '.', 'v', 'i', 'm', NUL };
|
||||||
|
char *vimrc = xmalloc(dir_len + sizeof(path_tail) + 1);
|
||||||
|
memmove(vimrc, dir, dir_len);
|
||||||
|
vimrc[dir_len] = PATHSEP;
|
||||||
|
memmove(vimrc + dir_len + 1, path_tail, sizeof(path_tail));
|
||||||
|
if (do_source((char_u *) vimrc, true, DOSO_VIMRC) != FAIL) {
|
||||||
|
if (do_exrc) {
|
||||||
|
do_exrc = (path_full_compare((char_u *)VIMRC_FILE, (char_u *)vimrc,
|
||||||
|
false) != kEqualFiles);
|
||||||
|
}
|
||||||
|
xfree(vimrc);
|
||||||
|
xfree(config_dirs);
|
||||||
|
return do_exrc;
|
||||||
|
}
|
||||||
|
xfree(vimrc);
|
||||||
|
} while (iter != NULL);
|
||||||
|
xfree(config_dirs);
|
||||||
|
}
|
||||||
|
if (process_env("EXINIT", false) == OK) {
|
||||||
|
return do_exrc;
|
||||||
|
}
|
||||||
|
return do_exrc;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/// Source startup scripts
|
||||||
* If -u argument given, use only the initializations from that file and
|
///
|
||||||
* nothing else.
|
/// @param[in]
|
||||||
*/
|
static void source_startup_scripts(const mparm_T *const parmp)
|
||||||
|
FUNC_ATTR_NONNULL_ALL
|
||||||
|
{
|
||||||
|
// If -u argument given, use only the initializations from that file and
|
||||||
|
// nothing else.
|
||||||
if (parmp->use_vimrc != NULL) {
|
if (parmp->use_vimrc != NULL) {
|
||||||
if (strcmp(parmp->use_vimrc, "NONE") == 0
|
if (strcmp(parmp->use_vimrc, "NONE") == 0
|
||||||
|| strcmp(parmp->use_vimrc, "NORC") == 0) {
|
|| strcmp(parmp->use_vimrc, "NORC") == 0) {
|
||||||
if (parmp->use_vimrc[2] == 'N')
|
if (parmp->use_vimrc[2] == 'N')
|
||||||
p_lpl = FALSE; // don't load plugins either
|
p_lpl = false; // don't load plugins either
|
||||||
} else {
|
} else {
|
||||||
if (do_source((char_u *)parmp->use_vimrc, FALSE, DOSO_NONE) != OK)
|
if (do_source((char_u *)parmp->use_vimrc, FALSE, DOSO_NONE) != OK)
|
||||||
EMSG2(_("E282: Cannot read from \"%s\""), parmp->use_vimrc);
|
EMSG2(_("E282: Cannot read from \"%s\""), parmp->use_vimrc);
|
||||||
}
|
}
|
||||||
} else if (!silent_mode) {
|
} else if (!silent_mode) {
|
||||||
|
|
||||||
/*
|
|
||||||
* Get system wide defaults, if the file name is defined.
|
|
||||||
*/
|
|
||||||
#ifdef SYS_VIMRC_FILE
|
#ifdef SYS_VIMRC_FILE
|
||||||
(void)do_source((char_u *)SYS_VIMRC_FILE, FALSE, DOSO_NONE);
|
// Get system wide defaults, if the file name is defined.
|
||||||
|
(void) do_source((char_u *)SYS_VIMRC_FILE, false, DOSO_NONE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
if (do_user_initialization()) {
|
||||||
* Try to read initialization commands from the following places:
|
// Read initialization commands from ".vimrc" or ".exrc" in current
|
||||||
* - environment variable VIMINIT
|
// directory. This is only done if the 'exrc' option is set.
|
||||||
* - user vimrc file (~/.vimrc)
|
// Because of security reasons we disallow shell and write commands
|
||||||
* - second user vimrc file ($VIM/.vimrc for Dos)
|
// now, except for unix if the file is owned by the user or 'secure'
|
||||||
* - environment variable EXINIT
|
// option has been reset in environment of global "exrc" or "vimrc".
|
||||||
* - user exrc file (~/.exrc)
|
// Only do this if VIMRC_FILE is not the same as vimrc file sourced in
|
||||||
* - second user exrc file ($VIM/.exrc for Dos)
|
// do_user_initialization.
|
||||||
* The first that exists is used, the rest is ignored.
|
|
||||||
*/
|
|
||||||
if (process_env("VIMINIT", true) != OK) {
|
|
||||||
if (do_source((char_u *)USR_VIMRC_FILE, TRUE, DOSO_VIMRC) == FAIL
|
|
||||||
#ifdef USR_VIMRC_FILE2
|
|
||||||
&& do_source((char_u *)USR_VIMRC_FILE2, TRUE,
|
|
||||||
DOSO_VIMRC) == FAIL
|
|
||||||
#endif
|
|
||||||
#ifdef USR_VIMRC_FILE3
|
|
||||||
&& do_source((char_u *)USR_VIMRC_FILE3, TRUE,
|
|
||||||
DOSO_VIMRC) == FAIL
|
|
||||||
#endif
|
|
||||||
&& process_env("EXINIT", FALSE) == FAIL
|
|
||||||
&& do_source((char_u *)USR_EXRC_FILE, FALSE, DOSO_NONE) == FAIL) {
|
|
||||||
#ifdef USR_EXRC_FILE2
|
|
||||||
(void)do_source((char_u *)USR_EXRC_FILE2, FALSE, DOSO_NONE);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Read initialization commands from ".vimrc" or ".exrc" in current
|
|
||||||
* directory. This is only done if the 'exrc' option is set.
|
|
||||||
* Because of security reasons we disallow shell and write commands
|
|
||||||
* now, except for unix if the file is owned by the user or 'secure'
|
|
||||||
* option has been reset in environment of global ".exrc" or ".vimrc".
|
|
||||||
* Only do this if VIMRC_FILE is not the same as USR_VIMRC_FILE or
|
|
||||||
* SYS_VIMRC_FILE.
|
|
||||||
*/
|
|
||||||
if (p_exrc) {
|
|
||||||
#if defined(UNIX)
|
#if defined(UNIX)
|
||||||
/* If ".vimrc" file is not owned by user, set 'secure' mode. */
|
// If vimrc file is not owned by user, set 'secure' mode.
|
||||||
if (!file_owned(VIMRC_FILE))
|
if (!file_owned(VIMRC_FILE))
|
||||||
#endif
|
#endif
|
||||||
secure = p_secure;
|
secure = p_secure;
|
||||||
|
|
||||||
i = FAIL;
|
if (do_source((char_u *)VIMRC_FILE, true, DOSO_VIMRC) == FAIL) {
|
||||||
if (path_full_compare((char_u *)USR_VIMRC_FILE,
|
|
||||||
(char_u *)VIMRC_FILE, FALSE) != kEqualFiles
|
|
||||||
#ifdef USR_VIMRC_FILE2
|
|
||||||
&& path_full_compare((char_u *)USR_VIMRC_FILE2,
|
|
||||||
(char_u *)VIMRC_FILE, FALSE) != kEqualFiles
|
|
||||||
#endif
|
|
||||||
#ifdef USR_VIMRC_FILE3
|
|
||||||
&& path_full_compare((char_u *)USR_VIMRC_FILE3,
|
|
||||||
(char_u *)VIMRC_FILE, FALSE) != kEqualFiles
|
|
||||||
#endif
|
|
||||||
#ifdef SYS_VIMRC_FILE
|
|
||||||
&& path_full_compare((char_u *)SYS_VIMRC_FILE,
|
|
||||||
(char_u *)VIMRC_FILE, FALSE) != kEqualFiles
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
i = do_source((char_u *)VIMRC_FILE, TRUE, DOSO_VIMRC);
|
|
||||||
|
|
||||||
if (i == FAIL) {
|
|
||||||
#if defined(UNIX)
|
#if defined(UNIX)
|
||||||
/* if ".exrc" is not owned by user set 'secure' mode */
|
// if ".exrc" is not owned by user set 'secure' mode
|
||||||
if (!file_owned(EXRC_FILE))
|
if (!file_owned(EXRC_FILE)) {
|
||||||
secure = p_secure;
|
secure = p_secure;
|
||||||
else
|
} else {
|
||||||
secure = 0;
|
secure = 0;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if ( path_full_compare((char_u *)USR_EXRC_FILE,
|
(void)do_source((char_u *)EXRC_FILE, false, DOSO_NONE);
|
||||||
(char_u *)EXRC_FILE, FALSE) != kEqualFiles
|
|
||||||
#ifdef USR_EXRC_FILE2
|
|
||||||
&& path_full_compare((char_u *)USR_EXRC_FILE2,
|
|
||||||
(char_u *)EXRC_FILE, FALSE) != kEqualFiles
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
(void)do_source((char_u *)EXRC_FILE, FALSE, DOSO_NONE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (secure == 2)
|
if (secure == 2) {
|
||||||
need_wait_return = TRUE;
|
need_wait_return = true;
|
||||||
|
}
|
||||||
secure = 0;
|
secure = 0;
|
||||||
}
|
}
|
||||||
did_source_startup_scripts = true;
|
did_source_startup_scripts = true;
|
||||||
@@ -2042,7 +2041,7 @@ static void usage(void)
|
|||||||
mch_msg(_(" -r, -L List swap files and exit\n"));
|
mch_msg(_(" -r, -L List swap files and exit\n"));
|
||||||
mch_msg(_(" -r <file> Recover crashed session\n"));
|
mch_msg(_(" -r <file> Recover crashed session\n"));
|
||||||
mch_msg(_(" -u <nvimrc> Use <nvimrc> instead of the default\n"));
|
mch_msg(_(" -u <nvimrc> Use <nvimrc> instead of the default\n"));
|
||||||
mch_msg(_(" -i <shada> Use <shada> instead of the default " SHADA_FILE "\n")); // NOLINT(whitespace/line_length)
|
mch_msg(_(" -i <shada> Use <shada> instead of the default\n"));
|
||||||
mch_msg(_(" --noplugin Don't load plugin scripts\n"));
|
mch_msg(_(" --noplugin Don't load plugin scripts\n"));
|
||||||
mch_msg(_(" -o[N] Open N windows (default: one for each file)\n"));
|
mch_msg(_(" -o[N] Open N windows (default: one for each file)\n"));
|
||||||
mch_msg(_(" -O[N] Like -o but split vertically\n"));
|
mch_msg(_(" -O[N] Like -o but split vertically\n"));
|
||||||
|
@@ -406,10 +406,12 @@ void ml_setname(buf_T *buf)
|
|||||||
* Try all directories in the 'directory' option.
|
* Try all directories in the 'directory' option.
|
||||||
*/
|
*/
|
||||||
dirp = p_dir;
|
dirp = p_dir;
|
||||||
|
bool found_existing_dir = false;
|
||||||
for (;; ) {
|
for (;; ) {
|
||||||
if (*dirp == NUL) /* tried all directories, fail */
|
if (*dirp == NUL) /* tried all directories, fail */
|
||||||
break;
|
break;
|
||||||
fname = findswapname(buf, &dirp, mfp->mf_fname);
|
fname = (char_u *)findswapname(buf, (char **)&dirp, (char *)mfp->mf_fname,
|
||||||
|
&found_existing_dir);
|
||||||
/* alloc's fname */
|
/* alloc's fname */
|
||||||
if (dirp == NULL) /* out of memory */
|
if (dirp == NULL) /* out of memory */
|
||||||
break;
|
break;
|
||||||
@@ -504,13 +506,15 @@ void ml_open_file(buf_T *buf)
|
|||||||
* Try all directories in 'directory' option.
|
* Try all directories in 'directory' option.
|
||||||
*/
|
*/
|
||||||
dirp = p_dir;
|
dirp = p_dir;
|
||||||
|
bool found_existing_dir = false;
|
||||||
for (;; ) {
|
for (;; ) {
|
||||||
if (*dirp == NUL)
|
if (*dirp == NUL)
|
||||||
break;
|
break;
|
||||||
/* There is a small chance that between choosing the swap file name
|
// There is a small chance that between choosing the swap file name
|
||||||
* and creating it, another Vim creates the file. In that case the
|
// and creating it, another Vim creates the file. In that case the
|
||||||
* creation will fail and we will use another directory. */
|
// creation will fail and we will use another directory.
|
||||||
fname = findswapname(buf, &dirp, NULL); /* allocates fname */
|
fname = (char_u *)findswapname(buf, (char **)&dirp, NULL,
|
||||||
|
&found_existing_dir);
|
||||||
if (dirp == NULL)
|
if (dirp == NULL)
|
||||||
break; /* out of memory */
|
break; /* out of memory */
|
||||||
if (fname == NULL)
|
if (fname == NULL)
|
||||||
@@ -3222,45 +3226,56 @@ static int do_swapexists(buf_T *buf, char_u *fname)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// Find out what name to use for the swap file for buffer 'buf'.
|
||||||
* Find out what name to use for the swap file for buffer 'buf'.
|
///
|
||||||
*
|
/// Several names are tried to find one that does not exist. Last directory in
|
||||||
* Several names are tried to find one that does not exist
|
/// option is automatically created.
|
||||||
* Returns the name in allocated memory or NULL.
|
///
|
||||||
* When out of memory "dirp" is set to NULL.
|
/// @note If BASENAMELEN is not correct, you will get error messages for
|
||||||
*
|
/// not being able to open the swap or undo file.
|
||||||
* Note: If BASENAMELEN is not correct, you will get error messages for
|
/// @note May trigger SwapExists autocmd, pointers may change!
|
||||||
* not being able to open the swap or undo file
|
///
|
||||||
* Note: May trigger SwapExists autocmd, pointers may change!
|
/// @param[in] buf Buffer for which swap file names needs to be found.
|
||||||
*/
|
/// @param[in,out] dirp Pointer to a list of directories. When out of memory,
|
||||||
static char_u *
|
/// is set to NULL. Is advanced to the next directory in
|
||||||
findswapname (
|
/// the list otherwise.
|
||||||
buf_T *buf,
|
/// @param[in] old_fname Allowed existing swap file name. Except for this
|
||||||
char_u **dirp, /* pointer to list of directories */
|
/// case, name of the non-existing file is used.
|
||||||
char_u *old_fname /* don't give warning for this file name */
|
/// @param[in,out] found_existing_dir If points to true, then new directory
|
||||||
)
|
/// for swap file is not created. At first
|
||||||
|
/// findswapname() call this argument must
|
||||||
|
/// point to false. This parameter may only
|
||||||
|
/// be set to true by this function, it is
|
||||||
|
/// never set to false.
|
||||||
|
///
|
||||||
|
/// @return [allocated] Name of the swap file.
|
||||||
|
static char *findswapname(buf_T *buf, char **dirp, char *old_fname,
|
||||||
|
bool *found_existing_dir)
|
||||||
|
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ARG(1, 2, 4)
|
||||||
{
|
{
|
||||||
char_u *fname;
|
char *fname;
|
||||||
int n;
|
size_t n;
|
||||||
char_u *dir_name;
|
char *dir_name;
|
||||||
char_u *buf_fname = buf->b_fname;
|
char *buf_fname = (char *) buf->b_fname;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Isolate a directory name from *dirp and put it in dir_name.
|
* Isolate a directory name from *dirp and put it in dir_name.
|
||||||
* First allocate some memory to put the directory name in.
|
* First allocate some memory to put the directory name in.
|
||||||
*/
|
*/
|
||||||
dir_name = xmalloc(STRLEN(*dirp) + 1);
|
const size_t dir_len = strlen(*dirp);
|
||||||
(void)copy_option_part(dirp, dir_name, 31000, ",");
|
dir_name = xmalloc(dir_len + 1);
|
||||||
|
(void)copy_option_part((char_u **) dirp, (char_u *) dir_name, dir_len, ",");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* we try different names until we find one that does not exist yet
|
* we try different names until we find one that does not exist yet
|
||||||
*/
|
*/
|
||||||
fname = makeswapname(buf_fname, buf->b_ffname, buf, dir_name);
|
fname = (char *)makeswapname((char_u *)buf_fname, buf->b_ffname, buf,
|
||||||
|
(char_u *)dir_name);
|
||||||
|
|
||||||
for (;; ) {
|
for (;; ) {
|
||||||
if (fname == NULL) /* must be out of memory */
|
if (fname == NULL) /* must be out of memory */
|
||||||
break;
|
break;
|
||||||
if ((n = (int)STRLEN(fname)) == 0) { /* safety check */
|
if ((n = strlen(fname)) == 0) { /* safety check */
|
||||||
xfree(fname);
|
xfree(fname);
|
||||||
fname = NULL;
|
fname = NULL;
|
||||||
break;
|
break;
|
||||||
@@ -3269,7 +3284,7 @@ findswapname (
|
|||||||
// Extra security check: When a swap file is a symbolic link, this
|
// Extra security check: When a swap file is a symbolic link, this
|
||||||
// is most likely a symlink attack.
|
// is most likely a symlink attack.
|
||||||
FileInfo file_info;
|
FileInfo file_info;
|
||||||
bool file_or_link_found = os_fileinfo_link((char *)fname, &file_info);
|
bool file_or_link_found = os_fileinfo_link(fname, &file_info);
|
||||||
if (!file_or_link_found) {
|
if (!file_or_link_found) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -3300,7 +3315,7 @@ findswapname (
|
|||||||
* Try to read block 0 from the swap file to get the original
|
* Try to read block 0 from the swap file to get the original
|
||||||
* file name (and inode number).
|
* file name (and inode number).
|
||||||
*/
|
*/
|
||||||
fd = os_open((char *)fname, O_RDONLY, 0);
|
fd = os_open(fname, O_RDONLY, 0);
|
||||||
if (fd >= 0) {
|
if (fd >= 0) {
|
||||||
if (read_eintr(fd, &b0, sizeof(b0)) == sizeof(b0)) {
|
if (read_eintr(fd, &b0, sizeof(b0)) == sizeof(b0)) {
|
||||||
/*
|
/*
|
||||||
@@ -3311,7 +3326,7 @@ findswapname (
|
|||||||
if (b0.b0_flags & B0_SAME_DIR) {
|
if (b0.b0_flags & B0_SAME_DIR) {
|
||||||
if (fnamecmp(path_tail(buf->b_ffname),
|
if (fnamecmp(path_tail(buf->b_ffname),
|
||||||
path_tail(b0.b0_fname)) != 0
|
path_tail(b0.b0_fname)) != 0
|
||||||
|| !same_directory(fname, buf->b_ffname)) {
|
|| !same_directory((char_u *) fname, buf->b_ffname)) {
|
||||||
/* Symlinks may point to the same file even
|
/* Symlinks may point to the same file even
|
||||||
* when the name differs, need to check the
|
* when the name differs, need to check the
|
||||||
* inode too. */
|
* inode too. */
|
||||||
@@ -3351,12 +3366,12 @@ findswapname (
|
|||||||
* user anyway.
|
* user anyway.
|
||||||
*/
|
*/
|
||||||
if (swap_exists_action != SEA_NONE
|
if (swap_exists_action != SEA_NONE
|
||||||
&& has_autocmd(EVENT_SWAPEXISTS, buf_fname, buf))
|
&& has_autocmd(EVENT_SWAPEXISTS, (char_u *) buf_fname, buf))
|
||||||
choice = do_swapexists(buf, fname);
|
choice = do_swapexists(buf, (char_u *) fname);
|
||||||
|
|
||||||
if (choice == 0) {
|
if (choice == 0) {
|
||||||
/* Show info about the existing swap file. */
|
/* Show info about the existing swap file. */
|
||||||
attention_message(buf, fname);
|
attention_message(buf, (char_u *) fname);
|
||||||
|
|
||||||
/* We don't want a 'q' typed at the more-prompt
|
/* We don't want a 'q' typed at the more-prompt
|
||||||
* interrupt loading a file. */
|
* interrupt loading a file. */
|
||||||
@@ -3364,20 +3379,21 @@ findswapname (
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (swap_exists_action != SEA_NONE && choice == 0) {
|
if (swap_exists_action != SEA_NONE && choice == 0) {
|
||||||
char_u *name;
|
char *name;
|
||||||
|
|
||||||
name = xmalloc(STRLEN(fname)
|
const size_t fname_len = strlen(fname);
|
||||||
+ STRLEN(_("Swap file \""))
|
name = xmalloc(fname_len
|
||||||
+ STRLEN(_("\" already exists!")) + 5);
|
+ strlen(_("Swap file \""))
|
||||||
|
+ strlen(_("\" already exists!")) + 5);
|
||||||
STRCPY(name, _("Swap file \""));
|
STRCPY(name, _("Swap file \""));
|
||||||
home_replace(NULL, fname, name + STRLEN(name),
|
home_replace(NULL, (char_u *) fname, (char_u *)&name[strlen(name)],
|
||||||
1000, TRUE);
|
fname_len, true);
|
||||||
STRCAT(name, _("\" already exists!"));
|
STRCAT(name, _("\" already exists!"));
|
||||||
choice = do_dialog(VIM_WARNING,
|
choice = do_dialog(VIM_WARNING,
|
||||||
(char_u *)_("VIM - ATTENTION"),
|
(char_u *)_("VIM - ATTENTION"),
|
||||||
name == NULL
|
(char_u *)(name == NULL
|
||||||
? (char_u *)_("Swap file already exists!")
|
? _("Swap file already exists!")
|
||||||
: name,
|
: name),
|
||||||
# if defined(UNIX)
|
# if defined(UNIX)
|
||||||
process_still_running
|
process_still_running
|
||||||
? (char_u *)_(
|
? (char_u *)_(
|
||||||
@@ -3409,7 +3425,7 @@ findswapname (
|
|||||||
swap_exists_action = SEA_RECOVER;
|
swap_exists_action = SEA_RECOVER;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
os_remove((char *)fname);
|
os_remove(fname);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
swap_exists_action = SEA_QUIT;
|
swap_exists_action = SEA_QUIT;
|
||||||
@@ -3421,7 +3437,7 @@ findswapname (
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* If the file was deleted this fname can be used. */
|
/* If the file was deleted this fname can be used. */
|
||||||
if (!os_file_exists(fname))
|
if (!os_file_exists((char_u *) fname))
|
||||||
break;
|
break;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
@@ -3454,6 +3470,19 @@ findswapname (
|
|||||||
--fname[n - 1]; /* ".swo", ".swn", etc. */
|
--fname[n - 1]; /* ".swo", ".swn", etc. */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (os_isdir((char_u *) dir_name)) {
|
||||||
|
*found_existing_dir = true;
|
||||||
|
} else if (!*found_existing_dir && **dirp == NUL) {
|
||||||
|
int ret;
|
||||||
|
char *failed_dir;
|
||||||
|
if ((ret = os_mkdir_recurse(dir_name, 0755, &failed_dir)) != 0) {
|
||||||
|
EMSG3(_("E303: Unable to create directory \"%s\" for swap file, "
|
||||||
|
"recovery impossible: %s"),
|
||||||
|
failed_dir, os_strerror(ret));
|
||||||
|
xfree(failed_dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
xfree(dir_name);
|
xfree(dir_name);
|
||||||
return fname;
|
return fname;
|
||||||
}
|
}
|
||||||
|
@@ -301,6 +301,243 @@ static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview",
|
|||||||
# include "option.c.generated.h"
|
# include "option.c.generated.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/// Append string with escaped commas
|
||||||
|
static char *strcpy_comma_escaped(char *dest, const char *src, const size_t len)
|
||||||
|
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
|
||||||
|
{
|
||||||
|
size_t shift = 0;
|
||||||
|
for (size_t i = 0; i < len; i++) {
|
||||||
|
if (src[i] == ',') {
|
||||||
|
dest[i + shift++] = '\\';
|
||||||
|
}
|
||||||
|
dest[i + shift] = src[i];
|
||||||
|
}
|
||||||
|
return &dest[len + shift];
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Compute length of a colon-separated value, doubled and with some suffixes
|
||||||
|
///
|
||||||
|
/// @param[in] val Colon-separated array value.
|
||||||
|
/// @param[in] common_suf_len Length of the common suffix which is appended to
|
||||||
|
/// each item in the array, twice.
|
||||||
|
/// @param[in] single_suf_len Length of the suffix which is appended to each
|
||||||
|
/// item in the array once.
|
||||||
|
///
|
||||||
|
/// @return Length of the comma-separated string array that contains each item
|
||||||
|
/// in the original array twice with suffixes with given length
|
||||||
|
/// (common_suf is present after each new item, single_suf is present
|
||||||
|
/// after half of the new items) and with commas after each item, commas
|
||||||
|
/// inside the values are escaped.
|
||||||
|
static inline size_t compute_double_colon_len(const char *const val,
|
||||||
|
const size_t common_suf_len,
|
||||||
|
const size_t single_suf_len)
|
||||||
|
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_PURE
|
||||||
|
{
|
||||||
|
if (val == NULL && *val) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
size_t ret = 0;
|
||||||
|
const void *iter = NULL;
|
||||||
|
do {
|
||||||
|
size_t dir_len;
|
||||||
|
const char *dir;
|
||||||
|
iter = vim_colon_env_iter(val, iter, &dir, &dir_len);
|
||||||
|
if (dir != NULL && dir_len > 0) {
|
||||||
|
ret += ((dir_len + memcnt(dir, ',', dir_len) + common_suf_len
|
||||||
|
+ !after_pathsep(dir, dir + dir_len)) * 2
|
||||||
|
+ single_suf_len);
|
||||||
|
}
|
||||||
|
} while (iter != NULL);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define NVIM_SIZE (sizeof("nvim") - 1)
|
||||||
|
|
||||||
|
/// Add directories to a comma-separated array from a colon-separated one
|
||||||
|
///
|
||||||
|
/// Commas are escaped in process. To each item PATHSEP "nvim" is appended in
|
||||||
|
/// addition to suf1 and suf2.
|
||||||
|
///
|
||||||
|
/// @param[in,out] dest Destination comma-separated array.
|
||||||
|
/// @param[in] val Source colon-separated array.
|
||||||
|
/// @param[in] suf1 If not NULL, suffix appended to destination. Prior to it
|
||||||
|
/// directory separator is appended. Suffix must not contain
|
||||||
|
/// commas.
|
||||||
|
/// @param[in] len1 Length of the suf1.
|
||||||
|
/// @param[in] suf2 If not NULL, another suffix appended to destination. Again
|
||||||
|
/// with directory separator behind. Suffix must not contain
|
||||||
|
/// commas.
|
||||||
|
/// @param[in] len2 Length of the suf2.
|
||||||
|
/// @param[in] forward If true, iterate over val in forward direction.
|
||||||
|
/// Otherwise in reverse.
|
||||||
|
///
|
||||||
|
/// @return (dest + appended_characters_length)
|
||||||
|
static inline char *add_colon_dirs(char *dest, const char *const val,
|
||||||
|
const char *const suf1, const size_t len1,
|
||||||
|
const char *const suf2, const size_t len2,
|
||||||
|
const bool forward)
|
||||||
|
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_ARG(1)
|
||||||
|
{
|
||||||
|
if (val == NULL && *val) {
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
const void *iter = NULL;
|
||||||
|
do {
|
||||||
|
size_t dir_len;
|
||||||
|
const char *dir;
|
||||||
|
iter = (forward ? vim_colon_env_iter : vim_colon_env_iter_rev)(
|
||||||
|
val, iter, &dir, &dir_len);
|
||||||
|
if (dir != NULL && dir_len > 0) {
|
||||||
|
dest = strcpy_comma_escaped(dest, dir, dir_len);
|
||||||
|
if (!after_pathsep(dest - 1, dest)) {
|
||||||
|
*dest++ = PATHSEP;
|
||||||
|
}
|
||||||
|
memmove(dest, "nvim", NVIM_SIZE);
|
||||||
|
dest += NVIM_SIZE;
|
||||||
|
if (suf1 != NULL) {
|
||||||
|
*dest++ = PATHSEP;
|
||||||
|
memmove(dest, suf1, len1);
|
||||||
|
dest += len1;
|
||||||
|
if (suf2 != NULL) {
|
||||||
|
*dest++ = PATHSEP;
|
||||||
|
memmove(dest, suf2, len2);
|
||||||
|
dest += len2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*dest++ = ',';
|
||||||
|
}
|
||||||
|
} while (iter != NULL);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Add directory to a comma-separated list of directories
|
||||||
|
///
|
||||||
|
/// In the added directory comma is escaped.
|
||||||
|
///
|
||||||
|
/// @param[in,out] dest Destination comma-separated array.
|
||||||
|
/// @param[in] dir Directory to append.
|
||||||
|
/// @param[in] append_nvim If true, append "nvim" as the very first suffix.
|
||||||
|
/// @param[in] suf1 If not NULL, suffix appended to destination. Prior to it
|
||||||
|
/// directory separator is appended. Suffix must not contain
|
||||||
|
/// commas.
|
||||||
|
/// @param[in] len1 Length of the suf1.
|
||||||
|
/// @param[in] suf2 If not NULL, another suffix appended to destination. Again
|
||||||
|
/// with directory separator behind. Suffix must not contain
|
||||||
|
/// commas.
|
||||||
|
/// @param[in] len2 Length of the suf2.
|
||||||
|
/// @param[in] forward If true, iterate over val in forward direction.
|
||||||
|
/// Otherwise in reverse.
|
||||||
|
///
|
||||||
|
/// @return (dest + appended_characters_length)
|
||||||
|
static inline char *add_dir(char *dest, const char *const dir,
|
||||||
|
const size_t dir_len, const bool append_nvim,
|
||||||
|
const char *const suf1, const size_t len1,
|
||||||
|
const char *const suf2, const size_t len2)
|
||||||
|
FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_ARG(1) FUNC_ATTR_WARN_UNUSED_RESULT
|
||||||
|
{
|
||||||
|
if (dir == NULL && dir_len != 0) {
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
dest = strcpy_comma_escaped(dest, dir, dir_len);
|
||||||
|
if (append_nvim) {
|
||||||
|
if (!after_pathsep(dest - 1, dest)) {
|
||||||
|
*dest++ = PATHSEP;
|
||||||
|
}
|
||||||
|
memmove(dest, "nvim", NVIM_SIZE);
|
||||||
|
dest += NVIM_SIZE;
|
||||||
|
if (suf1 != NULL) {
|
||||||
|
*dest++ = PATHSEP;
|
||||||
|
memmove(dest, suf1, len1);
|
||||||
|
dest += len1;
|
||||||
|
if (suf2 != NULL) {
|
||||||
|
*dest++ = PATHSEP;
|
||||||
|
memmove(dest, suf2, len2);
|
||||||
|
dest += len2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*dest++ = ',';
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Set &runtimepath to default value
|
||||||
|
static void set_runtimepath_default(void)
|
||||||
|
{
|
||||||
|
size_t rtp_size = 0;
|
||||||
|
char *const data_home = stdpaths_get_xdg_var(kXDGDataHome);
|
||||||
|
char *const config_home = stdpaths_get_xdg_var(kXDGConfigHome);
|
||||||
|
char *const vimruntime = vim_getenv("VIMRUNTIME");
|
||||||
|
char *const data_dirs = stdpaths_get_xdg_var(kXDGDataDirs);
|
||||||
|
char *const config_dirs = stdpaths_get_xdg_var(kXDGConfigDirs);
|
||||||
|
#define SITE_SIZE (sizeof("site") - 1)
|
||||||
|
#define AFTER_SIZE (sizeof("after") - 1)
|
||||||
|
size_t data_len = 0;
|
||||||
|
size_t config_len = 0;
|
||||||
|
size_t vimruntime_len = 0;
|
||||||
|
if (data_home != NULL) {
|
||||||
|
data_len = strlen(data_home);
|
||||||
|
if (data_len != 0) {
|
||||||
|
rtp_size += ((data_len + memcnt(data_home, ',', data_len)
|
||||||
|
+ NVIM_SIZE + 1 + SITE_SIZE + 1
|
||||||
|
+ !after_pathsep(data_home, data_home + data_len)) * 2
|
||||||
|
+ AFTER_SIZE + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (config_home != NULL) {
|
||||||
|
config_len = strlen(config_home);
|
||||||
|
if (config_len != 0) {
|
||||||
|
rtp_size += ((config_len + memcnt(config_home, ',', config_len)
|
||||||
|
+ NVIM_SIZE + 1
|
||||||
|
+ !after_pathsep(config_home, config_home + config_len)) * 2
|
||||||
|
+ AFTER_SIZE + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (vimruntime != NULL) {
|
||||||
|
vimruntime_len = strlen(vimruntime);
|
||||||
|
if (vimruntime_len != 0) {
|
||||||
|
rtp_size += vimruntime_len + memcnt(vimruntime, ',', vimruntime_len) + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rtp_size += compute_double_colon_len(data_dirs, NVIM_SIZE + 1 + SITE_SIZE + 1,
|
||||||
|
AFTER_SIZE + 1);
|
||||||
|
rtp_size += compute_double_colon_len(config_dirs, NVIM_SIZE + 1,
|
||||||
|
AFTER_SIZE + 1);
|
||||||
|
if (rtp_size == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
char *const rtp = xmalloc(rtp_size);
|
||||||
|
char *rtp_cur = rtp;
|
||||||
|
rtp_cur = add_dir(rtp_cur, config_home, config_len, true, NULL, 0, NULL, 0);
|
||||||
|
rtp_cur = add_colon_dirs(rtp_cur, config_dirs, NULL, 0, NULL, 0, true);
|
||||||
|
rtp_cur = add_dir(rtp_cur, data_home, data_len, true, "site", SITE_SIZE,
|
||||||
|
NULL, 0);
|
||||||
|
rtp_cur = add_colon_dirs(rtp_cur, data_dirs, "site", SITE_SIZE, NULL, 0,
|
||||||
|
true);
|
||||||
|
rtp_cur = add_dir(rtp_cur, vimruntime, vimruntime_len, false, NULL, 0,
|
||||||
|
NULL, 0);
|
||||||
|
rtp_cur = add_colon_dirs(rtp_cur, data_dirs, "site", SITE_SIZE,
|
||||||
|
"after", AFTER_SIZE, false);
|
||||||
|
rtp_cur = add_dir(rtp_cur, data_home, data_len, true, "site", SITE_SIZE,
|
||||||
|
"after", AFTER_SIZE);
|
||||||
|
rtp_cur = add_colon_dirs(rtp_cur, config_dirs, "after", AFTER_SIZE, NULL, 0,
|
||||||
|
false);
|
||||||
|
rtp_cur = add_dir(rtp_cur, config_home, config_len, true,
|
||||||
|
"after", AFTER_SIZE, NULL, 0);
|
||||||
|
// Strip trailing comma.
|
||||||
|
rtp_cur[-1] = NUL;
|
||||||
|
assert((size_t) (rtp_cur - rtp) == rtp_size);
|
||||||
|
#undef SITE_SIZE
|
||||||
|
#undef AFTER_SIZE
|
||||||
|
set_string_default("runtimepath", rtp, true);
|
||||||
|
xfree(data_dirs);
|
||||||
|
xfree(config_dirs);
|
||||||
|
xfree(data_home);
|
||||||
|
xfree(config_home);
|
||||||
|
xfree(vimruntime);
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef NVIM_SIZE
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize the options, first part.
|
* Initialize the options, first part.
|
||||||
*
|
*
|
||||||
@@ -308,7 +545,6 @@ static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview",
|
|||||||
*/
|
*/
|
||||||
void set_init_1(void)
|
void set_init_1(void)
|
||||||
{
|
{
|
||||||
char_u *p;
|
|
||||||
int opt_idx;
|
int opt_idx;
|
||||||
|
|
||||||
langmap_init();
|
langmap_init();
|
||||||
@@ -320,8 +556,12 @@ void set_init_1(void)
|
|||||||
* Find default value for 'shell' option.
|
* Find default value for 'shell' option.
|
||||||
* Don't use it if it is empty.
|
* Don't use it if it is empty.
|
||||||
*/
|
*/
|
||||||
if ((p = (char_u *)os_getenv("SHELL")) != NULL)
|
{
|
||||||
set_string_default("sh", p);
|
const char *shell = os_getenv("SHELL");
|
||||||
|
if (shell != NULL) {
|
||||||
|
set_string_default("sh", (char *) shell, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set the default for 'backupskip' to include environment variables for
|
* Set the default for 'backupskip' to include environment variables for
|
||||||
@@ -339,17 +579,18 @@ void set_init_1(void)
|
|||||||
ga_init(&ga, 1, 100);
|
ga_init(&ga, 1, 100);
|
||||||
for (size_t n = 0; n < ARRAY_SIZE(names); ++n) {
|
for (size_t n = 0; n < ARRAY_SIZE(names); ++n) {
|
||||||
bool mustfree = true;
|
bool mustfree = true;
|
||||||
|
char *p;
|
||||||
# ifdef UNIX
|
# ifdef UNIX
|
||||||
if (*names[n] == NUL) {
|
if (*names[n] == NUL) {
|
||||||
p = (char_u *)"/tmp";
|
p = "/tmp";
|
||||||
mustfree = false;
|
mustfree = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
# endif
|
# endif
|
||||||
p = (char_u *)vim_getenv(names[n]);
|
p = vim_getenv(names[n]);
|
||||||
if (p != NULL && *p != NUL) {
|
if (p != NULL && *p != NUL) {
|
||||||
// First time count the NUL, otherwise count the ','.
|
// First time count the NUL, otherwise count the ','.
|
||||||
len = (int)STRLEN(p) + 3;
|
len = (int)strlen(p) + 3;
|
||||||
ga_grow(&ga, len);
|
ga_grow(&ga, len);
|
||||||
if (!GA_EMPTY(&ga))
|
if (!GA_EMPTY(&ga))
|
||||||
STRCAT(ga.ga_data, ",");
|
STRCAT(ga.ga_data, ",");
|
||||||
@@ -363,8 +604,7 @@ void set_init_1(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ga.ga_data != NULL) {
|
if (ga.ga_data != NULL) {
|
||||||
set_string_default("bsk", ga.ga_data);
|
set_string_default("bsk", ga.ga_data, true);
|
||||||
xfree(ga.ga_data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -425,17 +665,34 @@ void set_init_1(void)
|
|||||||
|
|
||||||
#if defined(MSWIN) || defined(MAC)
|
#if defined(MSWIN) || defined(MAC)
|
||||||
/* Set print encoding on platforms that don't default to latin1 */
|
/* Set print encoding on platforms that don't default to latin1 */
|
||||||
set_string_default("penc",
|
set_string_default("printencoding", "hp-roman8", false);
|
||||||
(char_u *)"hp-roman8"
|
|
||||||
);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* 'printexpr' must be allocated to be able to evaluate it. */
|
// 'printexpr' must be allocated to be able to evaluate it.
|
||||||
set_string_default(
|
set_string_default("printexpr",
|
||||||
"pexpr",
|
#ifdef UNIX
|
||||||
(char_u *)
|
"system(['lpr'] "
|
||||||
"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error"
|
"+ (empty(&printdevice)?[]:['-P', &printdevice]) "
|
||||||
);
|
"+ [v:fname_in])"
|
||||||
|
". delete(v:fname_in)"
|
||||||
|
"+ v:shell_error",
|
||||||
|
#elif defined(MSWIN)
|
||||||
|
"system(['copy', v:fname_in, "
|
||||||
|
"empty(&printdevice)?'LPT1':&printdevice])"
|
||||||
|
". delete(v:fname_in)",
|
||||||
|
#else
|
||||||
|
"",
|
||||||
|
#endif
|
||||||
|
false);
|
||||||
|
|
||||||
|
set_string_default("viewdir", stdpaths_user_data_subpath("view", 0), true);
|
||||||
|
set_string_default("backupdir", stdpaths_user_data_subpath("backup", 0),
|
||||||
|
true);
|
||||||
|
set_string_default("directory", stdpaths_user_data_subpath("swap", 2), true);
|
||||||
|
set_string_default("undodir", stdpaths_user_data_subpath("undo", 0), true);
|
||||||
|
// Set default for &runtimepath. All necessary expansions are performed in
|
||||||
|
// this function.
|
||||||
|
set_runtimepath_default();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set all the options (except the terminal options) to their default
|
* Set all the options (except the terminal options) to their default
|
||||||
@@ -478,14 +735,16 @@ void set_init_1(void)
|
|||||||
* default.
|
* default.
|
||||||
*/
|
*/
|
||||||
for (opt_idx = 0; options[opt_idx].fullname; opt_idx++) {
|
for (opt_idx = 0; options[opt_idx].fullname; opt_idx++) {
|
||||||
|
char *p;
|
||||||
if ((options[opt_idx].flags & P_GETTEXT)
|
if ((options[opt_idx].flags & P_GETTEXT)
|
||||||
&& options[opt_idx].var != NULL)
|
&& options[opt_idx].var != NULL) {
|
||||||
p = (char_u *)_(*(char **)options[opt_idx].var);
|
p = _(*(char **)options[opt_idx].var);
|
||||||
else
|
} else {
|
||||||
p = option_expand(opt_idx, NULL);
|
p = (char *) option_expand(opt_idx, NULL);
|
||||||
|
}
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
p = vim_strsave(p);
|
p = xstrdup(p);
|
||||||
*(char_u **)options[opt_idx].var = p;
|
*(char **)options[opt_idx].var = p;
|
||||||
/* VIMEXP
|
/* VIMEXP
|
||||||
* Defaults for all expanded options are currently the same for Vi
|
* Defaults for all expanded options are currently the same for Vi
|
||||||
* and Vim. When this changes, add some code here! Also need to
|
* and Vim. When this changes, add some code here! Also need to
|
||||||
@@ -493,7 +752,7 @@ void set_init_1(void)
|
|||||||
*/
|
*/
|
||||||
if (options[opt_idx].flags & P_DEF_ALLOCED)
|
if (options[opt_idx].flags & P_DEF_ALLOCED)
|
||||||
xfree(options[opt_idx].def_val[VI_DEFAULT]);
|
xfree(options[opt_idx].def_val[VI_DEFAULT]);
|
||||||
options[opt_idx].def_val[VI_DEFAULT] = p;
|
options[opt_idx].def_val[VI_DEFAULT] = (char_u *) p;
|
||||||
options[opt_idx].flags |= P_DEF_ALLOCED;
|
options[opt_idx].flags |= P_DEF_ALLOCED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -522,14 +781,14 @@ void set_init_1(void)
|
|||||||
(void)set_chars_option(&p_lcs);
|
(void)set_chars_option(&p_lcs);
|
||||||
|
|
||||||
/* enc_locale() will try to find the encoding of the current locale. */
|
/* enc_locale() will try to find the encoding of the current locale. */
|
||||||
p = enc_locale();
|
char_u *p = enc_locale();
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
char_u *save_enc;
|
char_u *save_enc;
|
||||||
|
|
||||||
/* Try setting 'encoding' and check if the value is valid.
|
/* Try setting 'encoding' and check if the value is valid.
|
||||||
* If not, go back to the default "utf-8". */
|
* If not, go back to the default "utf-8". */
|
||||||
save_enc = p_enc;
|
save_enc = p_enc;
|
||||||
p_enc = p;
|
p_enc = (char_u *) p;
|
||||||
if (STRCMP(p_enc, "gb18030") == 0) {
|
if (STRCMP(p_enc, "gb18030") == 0) {
|
||||||
/* We don't support "gb18030", but "cp936" is a good substitute
|
/* We don't support "gb18030", but "cp936" is a good substitute
|
||||||
* for practical purposes, thus use that. It's not an alias to
|
* for practical purposes, thus use that. It's not an alias to
|
||||||
@@ -674,7 +933,9 @@ set_options_default (
|
|||||||
///
|
///
|
||||||
/// @param name The name of the option
|
/// @param name The name of the option
|
||||||
/// @param val The value of the option
|
/// @param val The value of the option
|
||||||
void set_string_default(const char *name, const char_u *val)
|
/// @param allocated If true, do not copy default as it was already allocated.
|
||||||
|
static void set_string_default(const char *name, char *val, bool allocated)
|
||||||
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
int opt_idx = findoption((char_u *)name);
|
int opt_idx = findoption((char_u *)name);
|
||||||
if (opt_idx >= 0) {
|
if (opt_idx >= 0) {
|
||||||
@@ -682,7 +943,10 @@ void set_string_default(const char *name, const char_u *val)
|
|||||||
xfree(options[opt_idx].def_val[VI_DEFAULT]);
|
xfree(options[opt_idx].def_val[VI_DEFAULT]);
|
||||||
}
|
}
|
||||||
|
|
||||||
options[opt_idx].def_val[VI_DEFAULT] = (char_u *) xstrdup((char *) val);
|
options[opt_idx].def_val[VI_DEFAULT] = (char_u *) (
|
||||||
|
allocated
|
||||||
|
? (char_u *) val
|
||||||
|
: (char_u *) xstrdup(val));
|
||||||
options[opt_idx].flags |= P_DEF_ALLOCED;
|
options[opt_idx].flags |= P_DEF_ALLOCED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5948,7 +6212,7 @@ static void paste_option_changed(void)
|
|||||||
old_p_paste = p_paste;
|
old_p_paste = p_paste;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found.
|
/// vimrc_found() - Called when a vimrc or "VIMINIT" has been found.
|
||||||
///
|
///
|
||||||
/// Set the values for options that didn't get set yet to the Vim defaults.
|
/// Set the values for options that didn't get set yet to the Vim defaults.
|
||||||
/// When "fname" is not NULL, use it to set $"envname" when it wasn't set yet.
|
/// When "fname" is not NULL, use it to set $"envname" when it wasn't set yet.
|
||||||
|
@@ -176,7 +176,7 @@ return {
|
|||||||
vi_def=true,
|
vi_def=true,
|
||||||
expand=true,
|
expand=true,
|
||||||
varname='p_bdir',
|
varname='p_bdir',
|
||||||
defaults={if_true={vi=macros('DFLT_BDIR')}}
|
defaults={if_true={vi=''}}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
full_name='backupext', abbreviation='bex',
|
full_name='backupext', abbreviation='bex',
|
||||||
@@ -627,7 +627,7 @@ return {
|
|||||||
vi_def=true,
|
vi_def=true,
|
||||||
expand=true,
|
expand=true,
|
||||||
varname='p_dir',
|
varname='p_dir',
|
||||||
defaults={if_true={vi=macros('DFLT_DIR')}}
|
defaults={if_true={vi=''}}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
full_name='display', abbreviation='dy',
|
full_name='display', abbreviation='dy',
|
||||||
@@ -1916,7 +1916,7 @@ return {
|
|||||||
vi_def=true,
|
vi_def=true,
|
||||||
expand=true,
|
expand=true,
|
||||||
varname='p_rtp',
|
varname='p_rtp',
|
||||||
defaults={if_true={vi=macros('DFLT_RUNTIMEPATH')}}
|
defaults={if_true={vi=''}}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
full_name='scroll', abbreviation='scr',
|
full_name='scroll', abbreviation='scr',
|
||||||
@@ -2524,7 +2524,7 @@ return {
|
|||||||
vi_def=true,
|
vi_def=true,
|
||||||
expand=true,
|
expand=true,
|
||||||
varname='p_udir',
|
varname='p_udir',
|
||||||
defaults={if_true={vi="."}}
|
defaults={if_true={vi=''}}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
full_name='undofile', abbreviation='udf',
|
full_name='undofile', abbreviation='udf',
|
||||||
@@ -2585,7 +2585,7 @@ return {
|
|||||||
vi_def=true,
|
vi_def=true,
|
||||||
expand=true,
|
expand=true,
|
||||||
varname='p_vdir',
|
varname='p_vdir',
|
||||||
defaults={if_true={vi=macros('DFLT_VDIR')}}
|
defaults={if_true={vi=''}}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
full_name='viewoptions', abbreviation='vop',
|
full_name='viewoptions', abbreviation='vop',
|
||||||
|
@@ -415,6 +415,74 @@ static char *remove_tail(char *p, char *pend, char *name)
|
|||||||
return pend;
|
return pend;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Iterate over colon-separated list
|
||||||
|
///
|
||||||
|
/// @note Environment variables must not be modified during iteration.
|
||||||
|
///
|
||||||
|
/// @param[in] val Value of the environment variable to iterate over.
|
||||||
|
/// @param[in] iter Pointer used for iteration. Must be NULL on first
|
||||||
|
/// iteration.
|
||||||
|
/// @param[out] dir Location where pointer to the start of the current
|
||||||
|
/// directory name should be saved. May be set to NULL.
|
||||||
|
/// @param[out] len Location where current directory length should be saved.
|
||||||
|
///
|
||||||
|
/// @return Next iter argument value or NULL when iteration should stop.
|
||||||
|
const void *vim_colon_env_iter(const char *const val,
|
||||||
|
const void *const iter,
|
||||||
|
const char **const dir,
|
||||||
|
size_t *const len)
|
||||||
|
FUNC_ATTR_NONNULL_ARG(1, 3, 4) FUNC_ATTR_WARN_UNUSED_RESULT
|
||||||
|
{
|
||||||
|
const char *varval = (const char *) iter;
|
||||||
|
if (varval == NULL) {
|
||||||
|
varval = val;
|
||||||
|
}
|
||||||
|
*dir = varval;
|
||||||
|
const char *const dirend = strchr(varval, ':');
|
||||||
|
if (dirend == NULL) {
|
||||||
|
*len = strlen(varval);
|
||||||
|
return NULL;
|
||||||
|
} else {
|
||||||
|
*len = (size_t) (dirend - varval);
|
||||||
|
return dirend + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Iterate over colon-separated list in reverse order
|
||||||
|
///
|
||||||
|
/// @note Environment variables must not be modified during iteration.
|
||||||
|
///
|
||||||
|
/// @param[in] val Value of the environment variable to iterate over.
|
||||||
|
/// @param[in] iter Pointer used for iteration. Must be NULL on first
|
||||||
|
/// iteration.
|
||||||
|
/// @param[out] dir Location where pointer to the start of the current
|
||||||
|
/// directory name should be saved. May be set to NULL.
|
||||||
|
/// @param[out] len Location where current directory length should be saved.
|
||||||
|
///
|
||||||
|
/// @return Next iter argument value or NULL when iteration should stop.
|
||||||
|
const void *vim_colon_env_iter_rev(const char *const val,
|
||||||
|
const void *const iter,
|
||||||
|
const char **const dir,
|
||||||
|
size_t *const len)
|
||||||
|
FUNC_ATTR_NONNULL_ARG(1, 3, 4) FUNC_ATTR_WARN_UNUSED_RESULT
|
||||||
|
{
|
||||||
|
const char *varend = (const char *) iter;
|
||||||
|
if (varend == NULL) {
|
||||||
|
varend = val + strlen(val) - 1;
|
||||||
|
}
|
||||||
|
const size_t varlen = (size_t) (varend - val) + 1;
|
||||||
|
const char *const colon = xmemrchr(val, ':', varlen);
|
||||||
|
if (colon == NULL) {
|
||||||
|
*len = varlen;
|
||||||
|
*dir = val;
|
||||||
|
return NULL;
|
||||||
|
} else {
|
||||||
|
*dir = colon + 1;
|
||||||
|
*len = (size_t) (varend - colon);
|
||||||
|
return colon - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Vim's version of getenv().
|
/// Vim's version of getenv().
|
||||||
/// Special handling of $HOME, $VIM and $VIMRUNTIME, allowing the user to
|
/// Special handling of $HOME, $VIM and $VIMRUNTIME, allowing the user to
|
||||||
/// override the vim runtime directory at runtime. Also does ACP to 'enc'
|
/// override the vim runtime directory at runtime. Also does ACP to 'enc'
|
||||||
|
@@ -366,11 +366,17 @@ int os_mkdir_recurse(const char *const dir, int32_t mode,
|
|||||||
}
|
}
|
||||||
while (e != real_end) {
|
while (e != real_end) {
|
||||||
if (e > past_head) {
|
if (e > past_head) {
|
||||||
*e = '/';
|
*e = PATHSEP;
|
||||||
} else {
|
} else {
|
||||||
*past_head = past_head_save;
|
*past_head = past_head_save;
|
||||||
}
|
}
|
||||||
e += strlen(e);
|
const size_t component_len = strlen(e);
|
||||||
|
e += component_len;
|
||||||
|
if (e == real_end
|
||||||
|
&& memcnt(e - component_len, PATHSEP, component_len) == component_len) {
|
||||||
|
// Path ends with something like "////". Ignore this.
|
||||||
|
break;
|
||||||
|
}
|
||||||
int ret;
|
int ret;
|
||||||
if ((ret = os_mkdir(curdir, mode)) != 0) {
|
if ((ret = os_mkdir(curdir, mode)) != 0) {
|
||||||
*failed_dir = curdir;
|
*failed_dir = curdir;
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
#include <uv.h>
|
#include <uv.h>
|
||||||
|
|
||||||
#include "nvim/os/fs_defs.h"
|
#include "nvim/os/fs_defs.h"
|
||||||
|
#include "nvim/os/stdpaths_defs.h"
|
||||||
#include "nvim/vim.h"
|
#include "nvim/vim.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||||
@@ -12,6 +13,7 @@
|
|||||||
# include "os/mem.h.generated.h"
|
# include "os/mem.h.generated.h"
|
||||||
# include "os/env.h.generated.h"
|
# include "os/env.h.generated.h"
|
||||||
# include "os/users.h.generated.h"
|
# include "os/users.h.generated.h"
|
||||||
|
# include "os/stdpaths.h.generated.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // NVIM_OS_OS_H
|
#endif // NVIM_OS_OS_H
|
||||||
|
108
src/nvim/os/stdpaths.c
Normal file
108
src/nvim/os/stdpaths.c
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include "nvim/os/stdpaths_defs.h"
|
||||||
|
#include "nvim/os/os.h"
|
||||||
|
#include "nvim/path.h"
|
||||||
|
#include "nvim/memory.h"
|
||||||
|
#include "nvim/ascii.h"
|
||||||
|
|
||||||
|
/// Names of the environment variables, mapped to XDGVarType values
|
||||||
|
static const char *xdg_env_vars[] = {
|
||||||
|
[kXDGConfigHome] = "XDG_CONFIG_HOME",
|
||||||
|
[kXDGDataHome] = "XDG_DATA_HOME",
|
||||||
|
[kXDGCacheHome] = "XDG_CACHE_HOME",
|
||||||
|
[kXDGRuntimeDir] = "XDG_RUNTIME_DIR",
|
||||||
|
[kXDGConfigDirs] = "XDG_CONFIG_DIRS",
|
||||||
|
[kXDGDataDirs] = "XDG_DATA_DIRS",
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Defaults for XDGVarType values
|
||||||
|
///
|
||||||
|
/// Used in case environment variables contain nothing. Need to be expanded.
|
||||||
|
static const char *const xdg_defaults[] = {
|
||||||
|
#ifdef WIN32
|
||||||
|
// Windows
|
||||||
|
[kXDGConfigHome] = "$LOCALAPPDATA\\nvim\\config",
|
||||||
|
[kXDGDataHome] = "$LOCALAPPDATA\\nvim\\data",
|
||||||
|
[kXDGCacheHome] = "$LOCALAPPDATA\\nvim\\cache",
|
||||||
|
[kXDGRuntimeDir] = "",
|
||||||
|
[kXDGConfigDirs] = NULL,
|
||||||
|
[kXDGDataDirs] = NULL,
|
||||||
|
#else
|
||||||
|
// Linux, BSD, CYGWIN, Apple
|
||||||
|
[kXDGConfigHome] = "~/.config",
|
||||||
|
[kXDGDataHome] = "~/.local/share",
|
||||||
|
[kXDGCacheHome] = "~/.cache",
|
||||||
|
[kXDGRuntimeDir] = "",
|
||||||
|
[kXDGConfigDirs] = "/etc/xdg/",
|
||||||
|
[kXDGDataDirs] = "/usr/local/share/:/usr/share/",
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Return XDG variable value
|
||||||
|
///
|
||||||
|
/// @param[in] idx XDG variable to use.
|
||||||
|
///
|
||||||
|
/// @return [allocated] variable value.
|
||||||
|
char *stdpaths_get_xdg_var(const XDGVarType idx)
|
||||||
|
FUNC_ATTR_WARN_UNUSED_RESULT
|
||||||
|
{
|
||||||
|
const char *const env = xdg_env_vars[idx];
|
||||||
|
const char *const fallback = xdg_defaults[idx];
|
||||||
|
|
||||||
|
const char *const env_val = os_getenv(env);
|
||||||
|
char *ret = NULL;
|
||||||
|
if (env_val != NULL) {
|
||||||
|
ret = xstrdup(env_val);
|
||||||
|
} else if (fallback) {
|
||||||
|
ret = (char *) expand_env_save((char_u *)fallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Return nvim-specific XDG directory subpath
|
||||||
|
///
|
||||||
|
/// @param[in] idx XDG directory to use.
|
||||||
|
///
|
||||||
|
/// @return [allocated] `{xdg_directory}/nvim`
|
||||||
|
static char *get_xdg_home(const XDGVarType idx)
|
||||||
|
FUNC_ATTR_WARN_UNUSED_RESULT
|
||||||
|
{
|
||||||
|
char *dir = stdpaths_get_xdg_var(idx);
|
||||||
|
if (dir) {
|
||||||
|
dir = concat_fnames_realloc(dir, "nvim", true);
|
||||||
|
}
|
||||||
|
return dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Return subpath of $XDG_CONFIG_HOME
|
||||||
|
///
|
||||||
|
/// @param[in] fname New component of the path.
|
||||||
|
///
|
||||||
|
/// @return [allocated] `$XDG_CONFIG_HOME/nvim/{fname}`
|
||||||
|
char *stdpaths_user_conf_subpath(const char *fname)
|
||||||
|
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
|
||||||
|
{
|
||||||
|
return concat_fnames_realloc(get_xdg_home(kXDGConfigHome), fname, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Return subpath of $XDG_DATA_HOME
|
||||||
|
///
|
||||||
|
/// @param[in] fname New component of the path.
|
||||||
|
/// @param[in] trailing_pathseps Amount of trailing path separators to add.
|
||||||
|
///
|
||||||
|
/// @return [allocated] `$XDG_DATA_HOME/nvim/{fname}`
|
||||||
|
char *stdpaths_user_data_subpath(const char *fname,
|
||||||
|
const size_t trailing_pathseps)
|
||||||
|
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
|
||||||
|
{
|
||||||
|
char *ret = concat_fnames_realloc(get_xdg_home(kXDGDataHome), fname, true);
|
||||||
|
if (trailing_pathseps) {
|
||||||
|
const size_t len = strlen(ret);
|
||||||
|
ret = xrealloc(ret, len + trailing_pathseps + 1);
|
||||||
|
memset(ret + len, PATHSEP, trailing_pathseps);
|
||||||
|
ret[len + trailing_pathseps] = NUL;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
14
src/nvim/os/stdpaths_defs.h
Normal file
14
src/nvim/os/stdpaths_defs.h
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#ifndef NVIM_OS_STDPATHS_DEFS_H
|
||||||
|
#define NVIM_OS_STDPATHS_DEFS_H
|
||||||
|
|
||||||
|
/// List of possible XDG variables
|
||||||
|
typedef enum {
|
||||||
|
kXDGConfigHome, ///< XDG_CONFIG_HOME
|
||||||
|
kXDGDataHome, ///< XDG_DATA_HOME
|
||||||
|
kXDGCacheHome, ///< XDG_CACHE_HOME
|
||||||
|
kXDGRuntimeDir, ///< XDG_RUNTIME_DIR
|
||||||
|
kXDGConfigDirs, ///< XDG_CONFIG_DIRS
|
||||||
|
kXDGDataDirs, ///< XDG_DATA_DIRS
|
||||||
|
} XDGVarType;
|
||||||
|
|
||||||
|
#endif // NVIM_OS_STDPATHS_DEFS_H
|
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
// Unix system-dependent file names
|
// Unix system-dependent file names
|
||||||
#ifndef SYS_VIMRC_FILE
|
#ifndef SYS_VIMRC_FILE
|
||||||
# define SYS_VIMRC_FILE "$VIM/nvimrc"
|
# define SYS_VIMRC_FILE "$VIM/sysinit.vim"
|
||||||
#endif
|
#endif
|
||||||
#ifndef DFLT_HELPFILE
|
#ifndef DFLT_HELPFILE
|
||||||
# define DFLT_HELPFILE "$VIMRUNTIME/doc/help.txt"
|
# define DFLT_HELPFILE "$VIMRUNTIME/doc/help.txt"
|
||||||
@@ -28,46 +28,11 @@
|
|||||||
#ifndef SYNTAX_FNAME
|
#ifndef SYNTAX_FNAME
|
||||||
# define SYNTAX_FNAME "$VIMRUNTIME/syntax/%s.vim"
|
# define SYNTAX_FNAME "$VIMRUNTIME/syntax/%s.vim"
|
||||||
#endif
|
#endif
|
||||||
#ifndef USR_EXRC_FILE
|
|
||||||
# define USR_EXRC_FILE "~/.exrc"
|
|
||||||
#endif
|
|
||||||
#ifndef USR_VIMRC_FILE
|
|
||||||
# define USR_VIMRC_FILE "~/.nvimrc"
|
|
||||||
#endif
|
|
||||||
#ifndef USR_VIMRC_FILE2
|
|
||||||
# define USR_VIMRC_FILE2 "~/.nvim/nvimrc"
|
|
||||||
#endif
|
|
||||||
#ifndef EXRC_FILE
|
#ifndef EXRC_FILE
|
||||||
# define EXRC_FILE ".exrc"
|
# define EXRC_FILE ".exrc"
|
||||||
#endif
|
#endif
|
||||||
#ifndef VIMRC_FILE
|
#ifndef VIMRC_FILE
|
||||||
# define VIMRC_FILE ".nvimrc"
|
# define VIMRC_FILE ".nvimrc"
|
||||||
#endif
|
#endif
|
||||||
#ifndef SHADA_FILE
|
|
||||||
# define SHADA_FILE "~/.nvim/shada/main.shada"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Default for 'backupdir'.
|
|
||||||
#ifndef DFLT_BDIR
|
|
||||||
# define DFLT_BDIR ".,~/tmp,~/"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Default for 'directory'.
|
|
||||||
#ifndef DFLT_DIR
|
|
||||||
# define DFLT_DIR ".,~/tmp,/var/tmp,/tmp"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Default for 'viewdir'.
|
|
||||||
#ifndef DFLT_VDIR
|
|
||||||
# define DFLT_VDIR "~/.nvim/view"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef RUNTIME_GLOBAL
|
|
||||||
# define DFLT_RUNTIMEPATH "~/.nvim," RUNTIME_GLOBAL ",$VIMRUNTIME," \
|
|
||||||
RUNTIME_GLOBAL "/after,~/.nvim/after"
|
|
||||||
#else
|
|
||||||
# define DFLT_RUNTIMEPATH \
|
|
||||||
"~/.nvim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,~/.nvim/after"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // NVIM_OS_UNIX_DEFS_H
|
#endif // NVIM_OS_UNIX_DEFS_H
|
||||||
|
@@ -7,13 +7,9 @@
|
|||||||
#define TEMP_FILE_PATH_MAXLEN _MAX_PATH
|
#define TEMP_FILE_PATH_MAXLEN _MAX_PATH
|
||||||
|
|
||||||
// Defines needed to fix the build on Windows:
|
// Defines needed to fix the build on Windows:
|
||||||
// - USR_EXRC_FILE
|
|
||||||
// - USR_VIMRC_FILE
|
|
||||||
// - SHADA_FILE
|
|
||||||
// - DFLT_DIR
|
// - DFLT_DIR
|
||||||
// - DFLT_BDIR
|
// - DFLT_BDIR
|
||||||
// - DFLT_VDIR
|
// - DFLT_VDIR
|
||||||
// - DFLT_RUNTIMEPATH
|
|
||||||
// - EXRC_FILE
|
// - EXRC_FILE
|
||||||
// - VIMRC_FILE
|
// - VIMRC_FILE
|
||||||
// - SYNTAX_FNAME
|
// - SYNTAX_FNAME
|
||||||
|
@@ -329,6 +329,31 @@ int vim_fnamencmp(char_u *x, char_u *y, size_t len)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Append fname2 to fname1
|
||||||
|
///
|
||||||
|
/// @param[in] fname1 First fname to append to.
|
||||||
|
/// @param[in] len1 Length of fname1.
|
||||||
|
/// @param[in] fname2 Secord part of the file name.
|
||||||
|
/// @param[in] len2 Length of fname2.
|
||||||
|
/// @param[in] sep If true and fname1 does not end with a path separator,
|
||||||
|
/// add a path separator before fname2.
|
||||||
|
///
|
||||||
|
/// @return fname1
|
||||||
|
static inline char *do_concat_fnames(char *fname1, const size_t len1,
|
||||||
|
const char *fname2, const size_t len2,
|
||||||
|
const bool sep)
|
||||||
|
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET
|
||||||
|
{
|
||||||
|
if (sep && *fname1 && !after_pathsep(fname1, fname1 + len1)) {
|
||||||
|
fname1[len1] = PATHSEP;
|
||||||
|
memmove(fname1 + len1 + 1, fname2, len2 + 1);
|
||||||
|
} else {
|
||||||
|
memmove(fname1 + len1, fname2, len2 + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return fname1;
|
||||||
|
}
|
||||||
|
|
||||||
/// Concatenate file names fname1 and fname2 into allocated memory.
|
/// Concatenate file names fname1 and fname2 into allocated memory.
|
||||||
///
|
///
|
||||||
/// Only add a '/' or '\\' when 'sep' is true and it is necessary.
|
/// Only add a '/' or '\\' when 'sep' is true and it is necessary.
|
||||||
@@ -339,17 +364,33 @@ int vim_fnamencmp(char_u *x, char_u *y, size_t len)
|
|||||||
/// if necessary
|
/// if necessary
|
||||||
/// @return [allocated] Concatenation of fname1 and fname2.
|
/// @return [allocated] Concatenation of fname1 and fname2.
|
||||||
char *concat_fnames(const char *fname1, const char *fname2, bool sep)
|
char *concat_fnames(const char *fname1, const char *fname2, bool sep)
|
||||||
FUNC_ATTR_NONNULL_ARG(1, 2) FUNC_ATTR_NONNULL_RET
|
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET
|
||||||
{
|
{
|
||||||
char *dest = xmalloc(strlen(fname1) + strlen(fname2) + 3);
|
const size_t len1 = strlen(fname1);
|
||||||
|
const size_t len2 = strlen(fname2);
|
||||||
|
char *dest = xmalloc(len1 + len2 + 3);
|
||||||
|
memmove(dest, fname1, len1 + 1);
|
||||||
|
return do_concat_fnames(dest, len1, fname2, len2, sep);
|
||||||
|
}
|
||||||
|
|
||||||
strcpy(dest, fname1);
|
/// Concatenate file names fname1 and fname2
|
||||||
if (sep) {
|
///
|
||||||
add_pathsep(dest);
|
/// Like concat_fnames(), but in place of allocating new memory it reallocates
|
||||||
}
|
/// fname1. For this reason fname1 must be allocated with xmalloc, and can no
|
||||||
strcat(dest, fname2);
|
/// longer be used after running concat_fnames_realloc.
|
||||||
|
///
|
||||||
return dest;
|
/// @param fname1 is the first part of the path or filename
|
||||||
|
/// @param fname2 is the second half of the path or filename
|
||||||
|
/// @param sep is a flag to indicate a path separator should be added
|
||||||
|
/// if necessary
|
||||||
|
/// @return [allocated] Concatenation of fname1 and fname2.
|
||||||
|
char *concat_fnames_realloc(char *fname1, const char *fname2, bool sep)
|
||||||
|
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET
|
||||||
|
{
|
||||||
|
const size_t len1 = strlen(fname1);
|
||||||
|
const size_t len2 = strlen(fname2);
|
||||||
|
return do_concat_fnames(xrealloc(fname1, len1 + len2 + 3), len1,
|
||||||
|
fname2, len2, sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -1583,6 +1583,20 @@ shada_read_main_cycle_end:
|
|||||||
kh_dealloc(strset, &oldfiles_set);
|
kh_dealloc(strset, &oldfiles_set);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Default shada file location: cached path
|
||||||
|
static char *default_shada_file = NULL;
|
||||||
|
|
||||||
|
/// Get the default ShaDa file
|
||||||
|
static const char *shada_get_default_file(void)
|
||||||
|
FUNC_ATTR_WARN_UNUSED_RESULT
|
||||||
|
{
|
||||||
|
if (default_shada_file == NULL) {
|
||||||
|
char *shada_dir = stdpaths_user_data_subpath("shada", 0);
|
||||||
|
default_shada_file = concat_fnames_realloc(shada_dir, "main.shada", true);
|
||||||
|
}
|
||||||
|
return default_shada_file;
|
||||||
|
}
|
||||||
|
|
||||||
/// Get the ShaDa file name to use
|
/// Get the ShaDa file name to use
|
||||||
///
|
///
|
||||||
/// If "file" is given and not empty, use it (has already been expanded by
|
/// If "file" is given and not empty, use it (has already been expanded by
|
||||||
@@ -1600,22 +1614,7 @@ static char *shada_filename(const char *file)
|
|||||||
file = used_shada_file;
|
file = used_shada_file;
|
||||||
} else {
|
} else {
|
||||||
if ((file = find_shada_parameter('n')) == NULL || *file == NUL) {
|
if ((file = find_shada_parameter('n')) == NULL || *file == NUL) {
|
||||||
#ifdef SHADA_FILE2
|
file = shada_get_default_file();
|
||||||
// don't use $HOME when not defined (turned into "c:/"!).
|
|
||||||
if (os_getenv((char_u *)"HOME") == NULL) {
|
|
||||||
// don't use $VIM when not available.
|
|
||||||
expand_env((char_u *)"$VIM", NameBuff, MAXPATHL);
|
|
||||||
if (STRCMP("$VIM", NameBuff) != 0) { // $VIM was expanded
|
|
||||||
file = SHADA_FILE2;
|
|
||||||
} else {
|
|
||||||
file = SHADA_FILE;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
#endif
|
|
||||||
file = SHADA_FILE;
|
|
||||||
#ifdef SHADA_FILE2
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
// XXX It used to be one level lower, so that whatever is in
|
// XXX It used to be one level lower, so that whatever is in
|
||||||
// `used_shada_file` was expanded. I intentionally moved it here
|
// `used_shada_file` was expanded. I intentionally moved it here
|
||||||
|
@@ -4,3 +4,6 @@ set shell=sh
|
|||||||
|
|
||||||
" Don't depend on system locale, always use utf-8
|
" Don't depend on system locale, always use utf-8
|
||||||
set encoding=utf-8
|
set encoding=utf-8
|
||||||
|
|
||||||
|
" Use safer defaults for various directories
|
||||||
|
set backupdir=. directory=. undodir=. viewdir=.
|
||||||
|
@@ -1067,31 +1067,6 @@ void list_version(void)
|
|||||||
version_msg(SYS_VIMRC_FILE);
|
version_msg(SYS_VIMRC_FILE);
|
||||||
version_msg("\"\n");
|
version_msg("\"\n");
|
||||||
#endif // ifdef SYS_VIMRC_FILE
|
#endif // ifdef SYS_VIMRC_FILE
|
||||||
#ifdef USR_VIMRC_FILE
|
|
||||||
version_msg(_(" user vimrc file: \""));
|
|
||||||
version_msg(USR_VIMRC_FILE);
|
|
||||||
version_msg("\"\n");
|
|
||||||
#endif // ifdef USR_VIMRC_FILE
|
|
||||||
#ifdef USR_VIMRC_FILE2
|
|
||||||
version_msg(_(" 2nd user vimrc file: \""));
|
|
||||||
version_msg(USR_VIMRC_FILE2);
|
|
||||||
version_msg("\"\n");
|
|
||||||
#endif // ifdef USR_VIMRC_FILE2
|
|
||||||
#ifdef USR_VIMRC_FILE3
|
|
||||||
version_msg(_(" 3rd user vimrc file: \""));
|
|
||||||
version_msg(USR_VIMRC_FILE3);
|
|
||||||
version_msg("\"\n");
|
|
||||||
#endif // ifdef USR_VIMRC_FILE3
|
|
||||||
#ifdef USR_EXRC_FILE
|
|
||||||
version_msg(_(" user exrc file: \""));
|
|
||||||
version_msg(USR_EXRC_FILE);
|
|
||||||
version_msg("\"\n");
|
|
||||||
#endif // ifdef USR_EXRC_FILE
|
|
||||||
#ifdef USR_EXRC_FILE2
|
|
||||||
version_msg(_(" 2nd user exrc file: \""));
|
|
||||||
version_msg(USR_EXRC_FILE2);
|
|
||||||
version_msg("\"\n");
|
|
||||||
#endif // ifdef USR_EXRC_FILE2
|
|
||||||
#ifdef HAVE_PATHDEF
|
#ifdef HAVE_PATHDEF
|
||||||
|
|
||||||
if (*default_vim_dir != NUL) {
|
if (*default_vim_dir != NUL) {
|
||||||
|
@@ -118,7 +118,7 @@ describe('server -> client', function()
|
|||||||
|
|
||||||
describe('when the client is a recursive vim instance', function()
|
describe('when the client is a recursive vim instance', function()
|
||||||
before_each(function()
|
before_each(function()
|
||||||
nvim('command', "let vim = rpcstart('"..nvim_prog.."', ['-u', 'NONE', '--embed'])")
|
nvim('command', "let vim = rpcstart('"..nvim_prog.."', ['-u', 'NONE', '-i', 'NONE', '--cmd', 'set noswapfile', '--embed'])")
|
||||||
neq(0, eval('vim'))
|
neq(0, eval('vim'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@@ -29,9 +29,11 @@ describe(':preserve', function()
|
|||||||
|
|
||||||
it("saves to custom 'directory' and (R)ecovers (issue #1836)", function()
|
it("saves to custom 'directory' and (R)ecovers (issue #1836)", function()
|
||||||
local testfile = 'testfile_recover_spec'
|
local testfile = 'testfile_recover_spec'
|
||||||
|
-- Note: `set swapfile` *must* go after `set directory`: otherwise it may
|
||||||
|
-- attempt to create a swapfile in different directory.
|
||||||
local init = [[
|
local init = [[
|
||||||
set swapfile fileformat=unix undolevels=-1
|
|
||||||
set directory^=]]..swapdir..[[//
|
set directory^=]]..swapdir..[[//
|
||||||
|
set swapfile fileformat=unix undolevels=-1
|
||||||
]]
|
]]
|
||||||
|
|
||||||
source(init)
|
source(init)
|
||||||
@@ -47,7 +49,7 @@ describe(':preserve', function()
|
|||||||
|
|
||||||
--TODO(justinmk): this is an ugly hack to force `helpers` to support
|
--TODO(justinmk): this is an ugly hack to force `helpers` to support
|
||||||
--multiple sessions.
|
--multiple sessions.
|
||||||
local nvim2 = helpers.spawn({helpers.nvim_prog, '-u', 'NONE', '--embed'},
|
local nvim2 = helpers.spawn({helpers.nvim_prog, '-u', 'NONE', '-i', 'NONE', '--embed'},
|
||||||
true)
|
true)
|
||||||
helpers.set_session(nvim2)
|
helpers.set_session(nvim2)
|
||||||
|
|
||||||
|
@@ -13,7 +13,7 @@ describe(':wshada', function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Override the default session because we need 'swapfile' for these tests.
|
-- Override the default session because we need 'swapfile' for these tests.
|
||||||
local session = spawn({nvim_prog, '-u', 'NONE', '--embed',
|
local session = spawn({nvim_prog, '-u', 'NONE', '-i', '/dev/null', '--embed',
|
||||||
'--cmd', 'set swapfile'})
|
'--cmd', 'set swapfile'})
|
||||||
set_session(session)
|
set_session(session)
|
||||||
|
|
||||||
|
@@ -7,7 +7,7 @@ local Session = require('nvim.session')
|
|||||||
|
|
||||||
local nvim_prog = os.getenv('NVIM_PROG') or 'build/bin/nvim'
|
local nvim_prog = os.getenv('NVIM_PROG') or 'build/bin/nvim'
|
||||||
local nvim_argv = {nvim_prog, '-u', 'NONE', '-i', 'NONE', '-N',
|
local nvim_argv = {nvim_prog, '-u', 'NONE', '-i', 'NONE', '-N',
|
||||||
'--cmd', 'set shortmess+=I background=light noswapfile noautoindent laststatus=1 encoding=utf-8',
|
'--cmd', 'set shortmess+=I background=light noswapfile noautoindent laststatus=1 encoding=utf-8 undodir=. directory=. viewdir=. backupdir=.',
|
||||||
'--embed'}
|
'--embed'}
|
||||||
|
|
||||||
-- Formulate a path to the directory containing nvim. We use this to
|
-- Formulate a path to the directory containing nvim. We use this to
|
||||||
|
@@ -18,7 +18,7 @@ describe('72', function()
|
|||||||
|
|
||||||
-- Test 'undofile': first a simple one-line change.
|
-- Test 'undofile': first a simple one-line change.
|
||||||
execute('set visualbell')
|
execute('set visualbell')
|
||||||
execute('set ul=100 undofile nomore')
|
execute('set ul=100 undofile undodir=. nomore')
|
||||||
execute('e! Xtestfile')
|
execute('e! Xtestfile')
|
||||||
feed('ggdGithis is one line<esc>:set ul=100<cr>')
|
feed('ggdGithis is one line<esc>:set ul=100<cr>')
|
||||||
execute('s/one/ONE/')
|
execute('s/one/ONE/')
|
||||||
|
@@ -17,7 +17,7 @@ describe('78', function()
|
|||||||
|
|
||||||
it('is working', function()
|
it('is working', function()
|
||||||
source([=[
|
source([=[
|
||||||
set swapfile fileformat=unix undolevels=-1
|
set directory=. swapfile fileformat=unix undolevels=-1
|
||||||
e! Xtest
|
e! Xtest
|
||||||
let text = "\tabcdefghijklmnoparstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnoparstuvwxyz0123456789"
|
let text = "\tabcdefghijklmnoparstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnoparstuvwxyz0123456789"
|
||||||
let i = 1
|
let i = 1
|
||||||
|
@@ -11,7 +11,7 @@ describe('tui', function()
|
|||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
helpers.clear()
|
helpers.clear()
|
||||||
screen = thelpers.screen_setup(0, '["'..helpers.nvim_prog..'", "-u", "NONE", "--cmd", "set noswapfile"]')
|
screen = thelpers.screen_setup(0, '["'..helpers.nvim_prog..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile"]')
|
||||||
screen.timeout = 30000 -- pasting can be really slow in the TUI
|
screen.timeout = 30000 -- pasting can be really slow in the TUI
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{1: } |
|
{1: } |
|
||||||
|
@@ -125,7 +125,7 @@ end
|
|||||||
|
|
||||||
do
|
do
|
||||||
local spawn, nvim_prog = helpers.spawn, helpers.nvim_prog
|
local spawn, nvim_prog = helpers.spawn, helpers.nvim_prog
|
||||||
local session = spawn({nvim_prog, '-u', 'NONE', '-N', '--embed'})
|
local session = spawn({nvim_prog, '-u', 'NONE', '-i', 'NONE', '-N', '--embed'})
|
||||||
local status, rv = session:request('vim_get_color_map')
|
local status, rv = session:request('vim_get_color_map')
|
||||||
if not status then
|
if not status then
|
||||||
print('failed to get color map')
|
print('failed to get color map')
|
||||||
|
@@ -564,6 +564,28 @@ describe('fs function', function()
|
|||||||
eq(false, os_isdir('unit-test-directory/new-dir-recurse'))
|
eq(false, os_isdir('unit-test-directory/new-dir-recurse'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('succeeds to create a directory ending with ///', function()
|
||||||
|
local mode = ffi.C.kS_IRUSR + ffi.C.kS_IWUSR + ffi.C.kS_IXUSR
|
||||||
|
local ret, failed_str = os_mkdir_recurse(
|
||||||
|
'unit-test-directory/new-dir-recurse///', mode)
|
||||||
|
eq(0, ret)
|
||||||
|
eq(nil, failed_str)
|
||||||
|
eq(true, os_isdir('unit-test-directory/new-dir-recurse'))
|
||||||
|
lfs.rmdir('unit-test-directory/new-dir-recurse')
|
||||||
|
eq(false, os_isdir('unit-test-directory/new-dir-recurse'))
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('succeeds to create a directory ending with /', function()
|
||||||
|
local mode = ffi.C.kS_IRUSR + ffi.C.kS_IWUSR + ffi.C.kS_IXUSR
|
||||||
|
local ret, failed_str = os_mkdir_recurse(
|
||||||
|
'unit-test-directory/new-dir-recurse/', mode)
|
||||||
|
eq(0, ret)
|
||||||
|
eq(nil, failed_str)
|
||||||
|
eq(true, os_isdir('unit-test-directory/new-dir-recurse'))
|
||||||
|
lfs.rmdir('unit-test-directory/new-dir-recurse')
|
||||||
|
eq(false, os_isdir('unit-test-directory/new-dir-recurse'))
|
||||||
|
end)
|
||||||
|
|
||||||
it('succeeds to create a directory tree', function()
|
it('succeeds to create a directory tree', function()
|
||||||
local mode = ffi.C.kS_IRUSR + ffi.C.kS_IWUSR + ffi.C.kS_IXUSR
|
local mode = ffi.C.kS_IRUSR + ffi.C.kS_IWUSR + ffi.C.kS_IXUSR
|
||||||
local ret, failed_str = os_mkdir_recurse(
|
local ret, failed_str = os_mkdir_recurse(
|
||||||
|
Reference in New Issue
Block a user