📄 starting.txt
字号:
Also consider using autocommands; see |autocommand|. When {vimrc} is equal to "NONE" (all uppercase), all initializations from files and environment variables are skipped, including reading the .gvimrc file when the GUI starts. Using the "-u" argument also means that the 'compatible' option will be on by default. This can have unexpected side effects. See |'compatible'|. {not in Vi} *-U*-U {gvimrc} The file "gvimrc" is read for initializations when the GUI starts. Other GUI initializations are skipped. When {gvimrc} is equal to "NONE", no file is read for initializations at all. Exception: Reading the system-wide menu file is always done. *-i*-i {viminfo} The file "viminfo" is used instead of the default viminfo file. If the name "NONE" is used (all uppercase), no viminfo file is read or written, even if 'viminfo' is set or when ":rv" or ":wv" are used. See also |viminfo-file|. {not in Vi} *-x*-x Use encryption to read/write files. Will prompt for a key, which is then stored in the 'key' option. All writes will then use this key to encrypt the text. The '-x' argument is not needed when reading a file, because there is a check if the file that is being read has been encrypted, and Vim asks for a key automatically. |encryption| *-s*-s {scriptin} The script file "scriptin" is read. The characters in the file are interpreted as if you had typed them. The same can be done with the command ":source! {scriptin}". If the end of the file is reached before the editor exits, further characters are read from the keyboard. Only works when not started in Ex mode, see |-s-ex|. See also |complex-repeat|. {not in Vi} *-w*-w {scriptout} All the characters that you type are recorded in the file "scriptout", until you exit Vim. This is useful if you want to create a script file to be used with "vim -s" or ":source!". When the "scriptout" file already exists, new characters are appended. See also |complex-repeat|. {not in Vi} *-W*-W {scriptout} Like -w, but do not append, overwrite an existing file. {not in Vi} *-w_nr*-w{number} Does nothing. This was included for Vi-compatibility. In Vi it sets the 'window' option, which is not implemented in Vim.Example for using a script file to change a name in several files: Create a file "subs.vi" containing substitute commands and a :wq command:> :%s/Jones/Smith/g> :%s/Allen/Peter/g> :wq Execute Vim on all files you want to change:> foreach i ( *.let ) vim -s subs.vi $iIf the executable is called "view", Vim will start in Readonly mode. This isuseful if you can make a hard or symbolic link from "view" to "vim".Starting in Readonly mode can also be done with "vim -R".If the executable is called "ex", Vim will start in "Ex" mode. This means itwill accept only ":" commands. But when the "-v" argument is given, Vim willstart in in Normal mode anyway.==============================================================================2. Vim on the Amiga *starting-amiga*Starting Vim from the Workbench *workbench*-------------------------------Vim can be started from the Workbench by clicking on its icon twice. It willthen start with an empty buffer.Vim can be started to edit one or more files by using a "Project" icon. The"Default Tool" of the icon must be the full pathname of the Vim executable.The name of the ".info" file must be the same as the name of the text file.By clicking on this icon twice, Vim will be started with the file name ascurrent file name, which will be read into the buffer (if it exists). You canedit multiple files by pressing the shift key while clicking on icons, andclicking twice on the last one. The "Default Tool" for all these icons mustbe the same.It is not possible to give arguments to Vim, other than file names, from theworkbench.Vim window *amiga-window*----------Vim will run in the CLI window where it was started. If Vim was started withthe "run" or "runback" command, or if Vim was started from the workbench, itwill open a window of its own.Technical detail: To open the new window a little trick is used. As soon as Vim recognizes that it does not run in a normal CLI window, it will create a script file in "t:". This script file contains the same command as the one Vim was started with, and an "endcli" command. This script file is then executed with a "newcli" command (the "c:run" and "c:newcli" commands are required for this to work). The script file will hang around until reboot, or until you delete it. This method is required to get the ":sh" and ":!" commands to work correctly. But when Vim was started with the -f option (foreground mode), this method is not used. The reason for this is that when a program starts Vim with the -f option it will wait for Vim to exit. With the script trick, the calling program does not know when Vim exits. The -f option can be used when Vim is started by a mail program which also waits for the edit session to finish. As a consequence, the ":sh" and ":!" commands are not available when the -f option is used.Vim will automatically recognize the window size and react to windowresizing. Under Amiga DOS 1.3, it is advised to use the fastfonts program,"FF", to speed up display redrawing.==============================================================================3. Running Vim from xargs *xargs*The xargs program can be used to start a program with arguments that come fromstdin. A typical example:> find . -name "*.c" -print | xargs vimA problem is that stdin for the program run by xargs is not setup properly,which causes problems for Vim. That is because Vim expects commands to comefrom stdin. The symptoms are that typed characters are echoed and don't takeeffect until <Return> is hit.This is really a problem in xargs. To work around it, you can use this smallprogram:> #include <unistd.h>> #include <stdio.h>>> main(argc, argv)> int argc;> char **argv;> {> close(0); /* close stdin */> dup(2); /* duplicate stdin from stderr */> execvp(argv[1], argv + 1);> perror("could not execute program");> }Store this in "start.c", compile it to "start" and put it somewhere in yoursearch path. You might have to make a few adjustments for your system. Anexample of using this:> find . -name "*.c" -print | xargs start vim==============================================================================4. Initialization *initialization* *startup*This section is about the non-GUI version of Vim. See |gui-fork| foradditional initialization when starting the GUI.At startup, Vim checks environment variables and files and sets valuesaccordingly. Vim proceeds in this order:1. Set the 'shell' option *SHELL* *COMSPEC* The environment variable SHELL, if it exists, is used to set the 'shell' option. On MS-DOS and Win32, the COMPSPEC variable is used if SHELL is not set.2. Set the 'term' option *TERM* The environment variable TERM, if it exists, is used to set the 'term' option.3. Execute Ex commands, from environment variables and/or files An environment variable is read as one Ex command line, where multiple commands must be separated with '|' or "<NL>". *vimrc* *exrc* 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 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 name. Also see |vimrc-intro|. Recommended place for your personal initializations: Unix $HOME/.vimrc OS/2 $HOME/.vimrc or $VIM/.vimrc (or _vimrc) MS-DOS and Win32 $HOME/_vimrc or $VIM/_vimrc Amiga s:.vimrc or $VIM/.vimrc If Vim was started with "-u filename", the file "filename" is used. All following initializations until 5. are skipped. "vim -u NONE" can be used to skip these initializations. |-u| If Vim was started in Ex mode with the "-s" argument, all following initializations until 4. are skipped. Only the "-u" option is interpreted. *system-vimrc* a. For Unix, OS/2, VMS, Macintosh, RISC-OS and Amiga the system vimrc file is read for initializations. The path of this file is shown with the ":version" command. Note that this file is ALWAYS read in 'compatible' mode, since the automatic resetting of 'compatible' is only done later. Add a ":set nocp" command if you like. *VIMINIT* *.vimrc* *_vimrc* *EXINIT* *.exrc* *_exrc* b. Four places are searched for initializations. The first that exists is used, the others are ignored. - The environment variable VIMINIT (see also |compatible-default|) (*) - The user vimrc file(s): "$HOME/.vimrc" (for Unix and OS/2) (*) "s:.vimrc" (for Amiga) (*) "home:.vimrc" (for Amiga) (*) "$VIM/.vimrc" (for OS/2 and Amiga) (*) "$HOME/_vimrc" (for MS-DOS and Win32) (*) "$VIM\_vimrc" (for MS-DOS and Win32) (*) Note: For Unix, OS/2 and Amiga, 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 user exrc file(s). Same as for the user vimrc file, but with "vimrc" replaced by "exrc". But without the (*)! c. If the 'exrc' option is on (which is not the default), the current directory is searched for four files. The first that exists is used, the others are ignored. - The file ".vimrc" (for Unix, Amiga and OS/2) (*) "_vimrc" (for MS-DOS and Win32) (*) - The file "_vimrc" (for Unix, Amiga and OS/2) (*) ".vimrc" (for MS-DOS and Win32) (*) - The file ".exrc" (for Unix, Amiga and OS/2) "_exrc" (for MS-DOS and Win32) - The file "_exrc" (for Unix, Amiga and OS/2) ".exrc" (for MS-DOS and Win32) (*) Using this file or environment variable will cause 'compatible' to be off by default. See |compatible-default|.4. Load the default file type detection script. This script is used to set autocommands for the FileType event. See |FileType| and |'filetype'|. This is only done if Vim was compiled with the |+autocmd| feature. If Vim was started with "-u filename", this is skipped. |-u| The name of this file depends on the system: Amiga $VIMRUNTIME/filetype.vim Mac $VIMRUNTIME:filetype.vim MS-DOS $VIMRUNTIME\filetype.vim RiscOS Vim:Filetype Unix $VIMRUNTIME/filetype.vim VMS $VIMRUNTIME/filetype.vim5. Set 'shellpipe' and 'shellredir' The 'shellpipe' and 'shellredir' options are set according to the value of the 'shell' option, unless they have been set before. This means that Vim will figure out the values of 'shellpipe' and 'shellredir' for you, unless you have set them yourself.6. Set 'updatecount' to zero, if "-n" command argument used7. Set binary options If the "-b" flag was given to Vim, the options for binary editing will be set now. See |-b|.8. Perform GUI initializations Only when starting "gvim", the GUI initializations will be done. See |gui-init|.9. Read the viminfo file If the 'viminfo' option is not empty, the viminfo file is read. The default is empty, so 'viminfo' must have been set by one of the previous initializations. See |viminfo-file|.10. Read the quickfix file If the "-q" flag was given to Vim, the quickfix file is read. If this fails, Vim exits.11. Open all windows When the |-o| flag was given, windows will be opened (but not displayed yet). When switching screens, it happens now. Redrawing starts. If the "-q" flag was given to Vim, the first error is jumped to. Buffers for all windows will be loaded.12. Execute startup commands If a "-t" flag was given to Vim, the tag is jumped to. The commands given with the |-c| and |+cmd| arguments are executed. If the 'insertmode' option is set, Insert mode is entered. The |VimEnter| autocommands are executed.Some hints on using initializations:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -