Movatterモバイル変換


[0]ホーム

URL:


Quick links:help overview ·quick reference ·user manual toc ·reference manual toc·faq
Go to keyword (shortcut:k)
Site search (shortcut:s)
intro.txt     ForVim version 9.1.  Last change: 2024 Oct 05VIM REFERENCE MANUAL    by Bram MoolenaarIntroduction to Vimrefreference1. Introductionintro2. Vim on theinternetinternet3. Creditscredits4. Notationnotation5. Modes, introductionvim-modes-intro6. Switching from mode to modemode-switching7. Thewindow contentswindow-contents8. Definitionsdefinitions==============================================================================1. IntroductionintroVim stands forVi IMproved.  It used to beVi IMitation, but there are so manyimprovements thata name change was appropriate.  Vimisa text editor whichincludes almost all the commands from theUnix program "Vi" anda lot of newones.  Itis very useful for editing programs and other plain text.   All commands are given with the keyboard.  This has the advantage that youcan keep your fingers on the keyboard and your eyes on the screen.  For thosewho want it, thereis mouse support andaGUI version with scrollbars andmenus (seegui.txt).An overview of this manual can be found in the file "help.txt",help.txt.It can be accessed from within Vim with the<Help> or<F1> key and with the:help command (just type ":help", without thebars or quotes).   The'helpfile' option can be set to the name of thehelp file, incaseitis not located in the default place.  You can jump to subjects like with tags:UseCTRL-] to jump toa subject under the cursor, useCTRL-T to jump back.The differences betweenVi and Vim are mentioned invi_diff.txt.This manual refers to Vim onvarious machines.  There may be small differencesbetween different computers and terminals.  Besides the remarks given in thisdocument, thereisa separate document for each supported system, seesys-file-list.pronounceVimis pronouncedas one word, like Jim, not vi-ai-em.  It's written withacapital, since it'sa name, again like Jim.  TheGUI version of Vimis written"gVim" (or "GVim" whenat the beginning ofa sentence).This manualisareference for all the Vim commands and options.  Thisis notan introduction to the use ofVi or Vim,it getsa bit complicated here andthere.  For beginners, thereisa hands-ontutor.  To learn using Vim, readthe user manualusr_toc.txt.bookbooksMostbooks onVi and Vim containasection for beginners.  Others are spendingmore words on specific functionality.  You can find an overview of Vimbookshere:http://iccf-holland.org/vim_books.html==============================================================================2. Vim on theinternetinternetwwwWWWfaqFAQdistributiondownloadThe Vim pages contain the most recent information about Vim.  They alsocontain links to the most recent version of Vim.  TheFAQisalist ofFrequently Asked Questions.  Read this if you have problems.Vimhome page:https://www.vim.org/Vim FAQ:https://vimhelp.org/vim_faq.txt.htmlDownloading:https://www.vim.org/download.phpAsking questions, finding answers:https://vi.stackexchange.com/"Vi and Vim Stack Exchangeisa question and answer site for people using thevi and Vim families of text editors"Usenet News group where Vimis discussed:newsusenetcomp.editorsThis groupis also for other editors.  If you write about Vim, don't forget tomention that.You can accessit here:https://groups.google.com/forum/#!topic/comp.editorsmail-listmaillistThere are several mailing lists for Vim:<vim@vim.org>vim-usevim_useFor discussions about using existing versions of Vim: Useful mappings,questions, answers, where to geta specific version, etc.  There arequitea few people watching thislist and answering questions, alsofor beginners.  Don't hesitate to ask your question here.<vim-dev@vim.org>vim-devvim_devvimdevFor discussions aboutchanging Vim: New features, porting, patches,beta-test versions, etc.<vim-announce@vim.org>vim-announcevim_announceAnnouncements about new versions of Vim; also for beta-test versionsand ports to different systems.  Thisisa read-only list.<vim-mac@vim.org>vim-macvim_macFor discussions about using and improving theMacintosh version ofVim.<vim-security@googlegroups.com>vim-securityThislistis for (privately) discussing security relevant issues of Vim.Seehttp://www.vim.org/maillist.php for the latest information.NOTE:- Anyone can see the archive, e.g. on Google groups.  Search this if you have  questions, except for thevim-security list.- You can only sendmessages to these lists if you have subscribed!- The first messageis moderated, thusit may takea few hours to show up.- You need to send themessages from the same locationas where you subscribed  from (to avoid spam mail).subscribe-maillistIf you want to join, senda message to<vim-subscribe@vim.org>Make sure that your "From:" addressis correct.  Then thelist server willgive youhelp on how to subscribe.maillist-archiveFor more information and archives look on the Vimmaillist page:http://www.vim.org/maillist.phpBug reports:bugsbug-reportsbugreport.vimThere are three ways to report bugs:1. For issues with runtime files, look in the header for an email address or   any other way to reportit to the maintainer.2. Open an issue on GitHub:https://github.com/vim/vim/issues   The text will be forwarded to thevim-dev maillist.3. Send bug reports to: Vim Developers <vim-dev@vim.org>   Thisisa maillist, you need to becomea member first and many people will   see the message.  If you don't want that, e.g. becauseitisa security   issue, please contact the current Vim maintainersat the e-mail address   <vim-security@googlegroups.com> or createa security advisoryat Github:https://github.com/vim/vim/security/advisoriesPlease be brief; all the time thatis spent on answering mailis subtractedfrom the time thatis spent on improving Vim!  Always givea reproducibleexample and try to find out which settings or other things trigger the bug.Preferably start Vim with:vim --clean -u reproduce.vimWhere reproduce.vimisascript that reproduces the problem.  Try differentmachines, if relevant (is this anMS-Windows specific bug perhaps?).Send patches if you can!  If you createa pull request onhttps://github.com/vim/vim then the automated checks will run and report anyobvious problems.  But you can also send the patch by email (use an attachmentto avoid whitespace changes).It willhelp to include information about the version of Vim you are using andyour setup.  You can get the information with this command:   :so $VIMRUNTIME/bugreport.vimThis will createa file "bugreport.txt" in the current directory, witha lotof information of your environment.  Before sending this out, check ifitdoesn't contain any confidential information!If Vim crashes, please try to find out where.  You can findhelp on this here:debug.txt.Incase of doubt or when you wonder if the problem has already been fixed butyou can't finda fix for it, becomea member of thevim-devmaillist and askyour question there.maillistyear-2000Y2KSince Vim internally doesn't use dates for editing, thereis no year 2000problem to worry about.  Vim does use the time in the form of seconds sinceJanuary 1st 1970.  Itis used fora time-stamp check of the edited file andthe swap file, whichis not critical and should only cause warning messages.There might bea year 2038 problem, when the seconds don't fit ina 32 bit intanymore.  This depends on the compiler, libraries and operating system.Specifically, time_t and the ctime() function are used.  And the time_tisstored in four bytes in the swap file.  But that's only used forprintingafile date/time for recovery,it will never affect normal editing.The Vimstrftime() function directly uses thestrftime() system function.localtime() uses the time() system function.getftime() uses the timereturned by the stat() system function.  If your system libraries are year2000 compliant, Vimis too.The user may create scripts for Vim that use external commands.  These mightintroduceY2K problems, but those are not really part of Vim itself.==============================================================================3. CreditscreditsauthorMost of Vim was created byBramMoolenaar <Bram@vim.org>Bram-Moolenaar.Parts of the documentation come from severalVi manuals, written by:W.N. JoyAlan P.W. HewettMark HortonThe Vim editoris based on Stevie and includes (ideas from) other software,worked on by the people mentioned here.  Other people helped by sending mepatches, suggestions and giving feedback about whatis good and bad in Vim.Vim would never have become whatitis now, without thehelp of these people!Ron AaronWin32GUI changesMohsin AhmedencryptionZoltan Arpadffywork onVMS portTony AndrewsStevieGert van Antwerpenchanges for DJGPP onMS-DOSBerkeley DB(3)ideas for swap file implementationKeith BosticNviWalter BriscoeMakefile updates,various patchesRalf BrownSPAWNO library forMS-DOSRobert Colonmany useful remarksMarcin DaleckiGTK+GUI port, toolbar icons,gettext()Kayhan Demirelsent menews inUgandaChris& John Downeyxvi (ideas for multi-windows version)Henk ElbersfirstVMS portDaniel ElstnerGTK+ 2 portEric FischerMac port,'cindent', and other improvementsBenji FisherAnswering lots of user questionsBill FosterAthenaGUI port (later removed)GoogleLetBram work on Vim one daya weekLoic Greniexvim (ideas for multiwindows version)Sven GuckesVim promoter and previousWWW page maintainerSven-GuckesDarren HiebertExuberantctagsJason HildebrandGTK+ 2 portBruce Hunsakerimprovements forVMS portAndy KahnCscope support,GTK+GUI portOezguer KesimMaintainer of Vim MailingListsAxel Kielhornwork on theMacintosh portSteve KirkendallElvisRoger Knobbeoriginal port to Windows NTSergey LaskavyVim'shelp from MoscowFelix von LeitnerPrevious maintainer of Vim MailingListsDavid LeonardPort ofPython extensions toUnixAvner LottemEdit in right-to-leftwindowsFlemming MadsenX11 client-server,various features and patchesTony Mechelynckanswers many user questionsPaul MoorePython interface extensions, many patchesKatsuhito NaganoWork onmultibyte versionsSung-Hyun NamWork onmultibyte versionsVince NegriWin32GUI and generic console enhancementsSteve OuallineAuthor of the first VimbookfrombookDominique PelleValgrind reports and many fixesA.PolitzMany bug reports and some fixesGeorge V. ReillyWin32 port,Win32GUI start-offStephen Riehmbug collectorStefan Roemervarious patches andhelp to usersRalf SchandlIBM OS/390 portOlaf SeibertDICE andBeBox version,regexp improvementsMortaza ShiranFarsi patchesPeter da SilvatermlibPaul SlootmanOS/2 portHenry Spencerregular expressionsDany St-AmantMacintosh portTim ThompsonStevieG. R. (Fred) WalterStevieSven VerdoolaegePerl interfaceRobert WebbCommand-line completion,GUI versions, andlots of patchesIngo WilkenTcl interfaceMike WilliamsPostScriptprintingJuergen WeigertLattice version, AUX improvements, UNIX andMS-DOS ports, autoconfStefan 'Sec' ZehlMaintainer of vim.orgYasuhiro MatsumotomanyMS-Windows improvementsKen Takatafixes and featuresKazunobu KuriyamaGTK 3Christian Brabandtmany fixes, features, user support, etc.Yegappan Lakshmananmanyquickfix featuresI wish to thank all the people that sent me bug reports and suggestions.  Thelistis too long to mention them all here.  Vim would not be the same withoutthe ideas from all these people: They keep Vim alive!lovepeacefriendshipgross-national-happinessIn this documentation there are several references to other versions of Vi:ViviVi"the original".  Without further remarks thisis the versionofVi that appeared in Sun OS 4.x.  ":version" returns"Version 3.7, 6/7/85".  Sometimes other versions are referredto.  Only runs under Unix.  Source codeis now available underaBSD-style license.  More information onVi can be found through:http://ex-vi.sourceforge.net/PosixPosixFrom the IEEE standard 1003.2, Part 2: Shell and utilities.Generally knownas "Posix".  Thisisa textual description ofhowViis supposed to work.Seeposix-compliance.NviNviThe "New" Vi.  The version ofVi that comes with BSD 4.4 and FreeBSD.Very good compatibility with the original Vi, witha few extensions.The version usedis 1.79.  ":version" returns "Version 1.79(10/23/96)".  There has been no release the last few years, althoughthereisadevelopment version 1.81.Source codeis freely available.ElvisElvisAnotherVi clone, made by Steve Kirkendall.  Very compact but isn'tas flexibleas Vim.  Development has stalled,Elvis has left thebuilding!  Source codeis freely available.NeovimNeovimA Vim clone.  Forked the Vim source in 2014 and wenta different way.Very much bound to github and has many more dependencies, makingdevelopment more complex and limiting portability.  Code has beenrefactored, resulting in patches not being exchangeable with Vim.Supportsa remoteGUI and integration with scripting languages.==============================================================================4. NotationnotationWhensyntax highlightingis used to read this, text thatis not typedliterallyis often highlighted with theSpecial group.  These are items in [],{} and <>, andCTRL-X.Note that Vim uses all possible characters in commands.  Sometimes the [],{}and<> are part of what you type, the context should make this clear.[]Characters in square brackets are optional.count[count][count]An optional number that may precede the command to multiplyor iterate the command.  If no numberis given,acount of oneis used, unless otherwise noted.Note that in this manual the[count]is not mentioned in the description of the command,but only in the explanation.  This was done to make thecommands easier to look up.  If the'showcmd' optionis on,the (partially) enteredcountis shownat the bottom of thewindow.  You can use<Del> to erase the last digit(N<Del>).[quotex]["x]An optionalregister designation where text can be stored.Seeregisters.  Thexisa single character between 'a' and'z' or 'A' and 'Z' or'"', and in some cases (with theputcommand) between '0' and '9', '%', '#', or others.  Theuppercase andlowercaseletter designate the same register,but thelowercaseletteris used to overwrite the previousregister contents, while theuppercaseletteris used toappend to the previousregister contents.  Without the ""x" orwith """" the stored textisput into the unnamed register.{}{}Curly braces denote parts of the command whichmust appear,but which can takea number of different values.  Thedifferences between Vim andVi are also given in curly braces(this will be clear from the context).{char1-char2}{char1-char2}A single character from the range char1 to char2.  Forexample:{a-z}isalowercase letter.  Multiple ranges may beconcatenated.  For example,{a-zA-Z0-9}is any alphanumericcharacter.{motion}movement{motion}A command that moves the cursor.  These are explained inmotion.txt.  Examples:wto start of nextwordbto begin of currentword4jfour lines down/The<CR>to next occurrence of "The"Thisis used after anoperator command to move over the textthatis to be operated upon.- If the motion includesacount and theoperator also hasa  count, the two counts are multiplied.  For example: "2d3w"  deletes six words.- The motion can be backwards, e.g. "db" to delete to the  start of the word.- The motion can also bea mouse click.  The mouseis not  supported in everyterminal though.- The ":omap" command can be used to map characters while anoperatoris pending.-Ex commands can be used to move the cursor.  This can be  used to calla function that does some complicated motion.  The motionis alwayscharacterwise exclusive, no matter  what ":" commandis used.  This means it's impossible to  include the last character ofa line without the line break  (unless'virtualedit'is set).  If theEx command changes the text before where theoperator  starts or jumps to another buffer the resultis  unpredictable.  Itis possible to change the text further  down.  Jumping to another bufferis possible if the current  bufferis not unloaded.{Visual}{Visual}A selected text area.  Itis started with the "v", "V", orCTRL-V command, then any cursormovement command can be usedto change theend of the selected text.Thisis used before anoperator command to highlight thetext thatis to be operated upon.SeeVisual-mode.<character><character>A special character from the table below, optionally withmodifiers, ora single ASCII character with modifiers.'character''c'A single ASCII character.CTRL-{char}CTRL-{char}{char} typedasacontrol character; that is, typing{char}while holding the CTRL key down.  Thecase of{char} does notmatter; thusCTRL-A andCTRL-a are equivalent.  But on someterminals, using the SHIFT key will produce another code,don't useit then.'option''option'An option, or parameter, that can be set toa value,isenclosed in single quotes.  Seeoptions.quotecommandquote"command"Areference toa command that you can typeis enclosed indouble quotes.command  New style command, this distinguishesit from other quotedtext and strings.key-notationkey-codeskeycodesThese names for keys are used in the documentation.  They can also be usedwith the ":map" command (insert the key name by pressingCTRL-K and then thekey you want the name for).notationmeaning    equivalentdecimal value(s)-----------------------------------------------------------------------<Nul>zeroCTRL-@0 (storedas 10)<Nul><BS>backspaceCTRL-H  8backspace<Tab>tabCTRL-I  9tabTablinefeed<NL>linefeedCTRL-J 10 (used for<Nul>)<CR>carriage returnCTRL-M 13carriage-return<Return>sameas<CR><Return><Enter>sameas<CR><Enter><Esc>escapeCTRL-[ 27escape<Esc><Space>space 32space<lt>less-than< 60<lt><Bslash>backslash\ 92backslash<Bslash><Bar>verticalbar|124<Bar><Del>delete127<CSI>command sequenceintroALT-Esc 155<CSI><xCSI>CSI when typed in theGUI<xCSI><EOL>end-of-line (can be<CR>,<NL> or<CR><NL>,depends on system and'fileformat')<EOL><Up>cursor-upcursor-upcursor_up<Down>cursor-downcursor-downcursor_down<Left>cursor-leftcursor-leftcursor_left<Right>cursor-rightcursor-rightcursor_right<S-Up>shift-cursor-up<S-Down>shift-cursor-down<S-Left>shift-cursor-left<S-Right>shift-cursor-right<C-Left>control-cursor-left<C-Right>control-cursor-right<F1>-<F12>function keys 1 to 12function_keyfunction-key<S-F1>-<S-F12> shift-function keys 1 to 12<S-F1><Help>help key<Undo>undo key<Insert>insert key<Home>homehome<End>endend<PageUp>page-uppage_uppage-up<PageDown>page-downpage_downpage-down<kHome>keypadhome (upper left)keypad-home<kEnd>keypadend (lower left)keypad-end<kPageUp>keypadpage-up (upper right)keypad-page-up<kPageDown>keypadpage-down (lower right)keypad-page-down<kPlus>keypad+keypad-plus<kMinus>keypad-keypad-minus<kMultiply>keypad *keypad-multiply<kDivide>keypad/keypad-divide<kEnter>keypad Enterkeypad-enter<kPoint>keypad Decimal pointkeypad-point<k0>-<k9>keypad0 to 9keypad-0keypad-9<S-...>shift-keyshift<S-<C-...>control-keycontrolctrl<C-<M-...>alt-key or meta-keymetaalt<M-<A-...>sameas <M-...><A-<D-...>command-key (Mac)/ super (GTK)<D-<t_xx>key with "xx" entry intermcap-----------------------------------------------------------------------Note: The shifted cursor keys, thehelp key, and theundo key are onlyavailable ona few terminals.  On the Amiga, shifted function key 10 producesa code (CSI) thatis also used by key sequences.  It will be recognized onlyafter typing another key.Note: There are two codes for the delete key.  127is the decimal ASCII valuefor the delete key, whichis always recognized.  Some delete keys send anothervalue, in whichcase this valueis obtained from thetermcap entry "kD".  Bothvalues have the same effect.  Also see:fixdel.Note: The keypad keys are used in the same wayas the corresponding "normal"keys.  For example,<kHome> has the same effectas<Home>.  Ifa keypad keysends the same raw key codeas its non-keypad equivalent,it will berecognizedas the non-keypad code.  For example, when<kHome> sends the samecodeas<Home>, when pressing<kHome> Vim will think<Home> was pressed.Mapping<kHome> will not work then.<>Examples are often given in the<> notation.  Sometimes thisis just to makeclear what you need to type, but oftenit can be typed literally, e.g., withthe ":map" command.  The rules are: 1.  Any printable characters are typed directly, exceptbackslash and '<' 2.Abackslashis represented with "\\", double backslash, or "<Bslash>". 3.A real '<'is represented with "\<" or "<lt>".  When thereis no     confusion possible,a '<' can be used directly. 4.  "<key>" means the special key typed.  Thisis thenotation explained in     the table above.A few examples:<Esc>Escape key<C-G>CTRL-G<Up>cursor up key<C-LeftMouse>Control- left mouse click<S-F11>Shifted function key 11<M-a>Meta-a  ('a' with bit 8 set)<M-A>Meta-A  ('A' with bit 8 set)<t_kd>"kd"termcap entry (cursor down key)    Although you can specify <M-{char}> with{char} beingamultibyte    character, Vim may not be able to know what byte sequence thatis and thenit won't work.If you want to use the full<>notation in Vim, you have to make sure the '<'flagis excluded from'cpoptions' (when'compatible'is not set,it alreadyisby default).:set cpo-=<The<>notation uses<lt> toescape the special meaning of key names.  Usingabackslash also works, but only when'cpoptions' does not include the 'B' flag.Examples formappingCTRL-H to the six characters "<Home>"::imap <C-H> \<Home>:imap <C-H> <lt>Home>The first one only works when the 'B' flagis not in'cpoptions'.  The secondone always works.To geta literal "<lt>" ina mapping::map <C-L> <lt>lt>For mapping, abbreviation and menu commands you can then copy-paste theexamples and use them directly.  Or type them literally, including the '<' and'>' characters.  This does NOT work for other commands, like ":set" and":autocmd"!Thenotation can be used ina double quoted strings, using "\<"at the start,e.g. "\<C-Space>".  This results ina special key code.  To convert this backto readable text usekeytrans().==============================================================================5. Modes, introductionvim-modes-introvim-modesVim has seven BASIC modes:NormalNormal-modecommand-modeNormal modeInNormal mode you can enter all the normal editorcommands.  If you start the editor you are in thismode (unless you have set the'insertmode' option,see below).  Thisis also knownas command mode.Visual modeThisis likeNormal mode, but themovement commandsextenda highlighted area.  Whena non-movementcommandis used,itis executed for the highlightedarea.  SeeVisual-mode.If the'showmode' optionis on "-- VISUAL--"is shownat the bottom of the window.Select modeThis looks most like theMS-Windows selection mode.Typinga printable character deletes the selectionand startsInsert mode.  SeeSelect-mode.If the'showmode' optionis on "-- SELECT--"is shownat the bottom of the window.Insert modeInInsert mode the text you typeis inserted into thebuffer.  SeeInsert-mode.If the'showmode' optionis on "-- INSERT--"is shownat the bottom of the window.Command-line modeInCommand-line mode (also calledCmdline mode) youCmdline modecan enter one line of textat the bottom of thewindow.  Thisis for theEx commands, ":", thepatternsearch commands, "?" and "/", and thefilter command,"!".Cmdline-modeEx modeLikeCommand-line mode, but after enteringa commandyou remain inEx mode.  Very limited editing of thecommand line.Ex-modeTerminal-Job modeInteracting withajob inaterminal window.  Typedkeysgo to thejob and thejob outputis displayed intheterminal window.  Seeterminal about how toswitch to other modes.There are seven ADDITIONAL modes.  These are variants of the BASIC modes:Operator-pendingOperator-pending-modeOperator-pending modeThisis likeNormal mode, but after anoperatorcommand has started, and Vimis waiting fora{motion}to specify the text that theoperator will work on.Replace modeReplace modeisa specialcase ofInsert mode.  Youcando the same thingsas inInsert mode, but foreach character you enter, one character of the existingtextis deleted.  SeeReplace-mode.If the'showmode' optionis on "-- REPLACE--"isshownat the bottom of the window.VirtualReplace modeVirtualReplace modeis similar toReplace mode, butinstead of file characters you arereplacing screenreal estate.  SeeVirtual-Replace-mode.If the'showmode' optionis on "-- VREPLACE--"isshownat the bottom of the window.InsertNormal modeEntered whenCTRL-Ois typed inInsert mode (seei_CTRL-O).  Thisis likeNormal mode, but afterexecuting one command Vim returns toInsert mode.If the'showmode' optionis on "-- (insert)--"isshownat the bottom of the window.Terminal-Normal modeUsingNormal mode inaterminal window.  Makingchangesis impossible.  Use aninsert command, suchas"a" or "i", to return toTerminal-Job mode.InsertVisual modeEntered whenstartingaVisual selection fromInsertmode, e.g., by usingCTRL-O and then "v", "V" orCTRL-V.  When theVisual selection ends, Vim returnstoInsert mode.If the'showmode' optionis on "-- (insert) VISUAL--"is shownat the bottom of the window.InsertSelect modeEntered whenstartingSelect mode fromInsert mode.E.g., by dragging the mouse or<S-Right>.When theSelect mode ends, Vim returns toInsert mode.If the'showmode' optionis on "-- (insert) SELECT--"is shownat the bottom of the window.==============================================================================6. Switching from mode to modemode-switchingIf for any reason youdo not know which mode you are in, you can always getback toNormal mode by typing<Esc> twice.  This doesn't work forEx modethough, use ":visual".You will know you are back inNormal mode when you see the screen flash orhear the bell after you type<Esc>.  However, when pressing<Esc> after usingCTRL-O inInsert mode you getabeep but you are still inInsert mode, type<Esc> again.i_escTO modeNormalVisualSelectInsert  Replace   Cmd-line  ExFROM modeNormalvV ^V  *4 *1RgR:/?!QVisual *2  ^GcC--:--Select *5^O ^G *6------Insert<Esc>----<Insert>----Replace<Esc>----<Insert>----Command-line *3----:start----Ex:vi------------ not possible*1 Go fromNormal mode toInsert mode by giving the command "i", "I", "a",   "A", "o", "O", "c", "C", "s" orS".*2 Go fromVisual mode toNormal mode by givinga non-movement command, which   causes the command to be executed, or by hitting<Esc> "v", "V" or "CTRL-V"   (seev_v), which just stopsVisual mode without side effects.*3 Go fromCommand-line mode toNormal mode by:- Hitting<CR> or<NL>, which causes the entered command to be executed.- Deleting the complete line (e.g., withCTRL-U) and givinga final<BS>.- HittingCTRL-C or<Esc>, which quits the command-line without executing     the command.   In the lastcase<Esc> may be the character defined with the'wildchar'   option, in whichcaseit will start command-line completion.  You can   ignore that and type<Esc> again.*4 Go fromNormal toSelect mode by:- use the mouse to select text while'selectmode' contains "mouse"- usea non-printable command to move the cursor while keeping the Shift     key pressed, and the'selectmode' option contains "key"- use "v", "V" or "CTRL-V" while'selectmode' contains "cmd"- use "gh", "gH" or "gCTRL-H"g_CTRL-H*5 Go fromSelect mode toNormal mode by usinga non-printable command to move   the cursor, without keeping the Shift key pressed.*6 Go fromSelect mode toInsert mode by typinga printable character.  The   selectionis deleted and the characteris inserted.If the'insertmode' optionis on, editinga file will start inInsert mode.CTRL-\_CTRL-Ni_CTRL-\_CTRL-Nc_CTRL-\_CTRL-Nv_CTRL-\_CTRL-NAdditionally the commandCTRL-\CTRL-N or<C-\><C-N> can be used togo toNormal mode from any other mode.  This can be used to make sure Vimis inNormal mode, without causingabeep like<Esc> would.  However, this does notwork inEx mode.  When used aftera command that takes an argument, suchasf orm, the timeout set with'ttimeoutlen' applies.When focusis inaterminal window,CTRL-\CTRL-N goes toNormal mode until anedit commandis entered, seet_CTRL-\_CTRL-N.CTRL-\_CTRL-Gi_CTRL-\_CTRL-Gc_CTRL-\_CTRL-Gv_CTRL-\_CTRL-GThe commandCTRL-\CTRL-G or<C-\><C-G> can be used togo toInsert mode when'insertmode'is set.  Otherwiseit goes toNormal mode.  This can be used tomake sure Vimis in the mode indicated by'insertmode', without knowing inwhat mode Vim currently is.Qmode-ExEx-modeExEXE501QSwitch to "Ex" mode.  Thisisa bit like typing ":"commands one after another, except:- You don't have to keep pressing ":".- The screen doesn't get updated after each command.- Thereis no normal command-line editing.- Mappings andabbreviations are not used.In fact, you are editing the lines with the "standard"line-input editing commands (<Del> or<BS> to erase,CTRL-U to kill the whole line).Vim will enter this mode by default if it's invokedas"ex" on the command-line or the-e command lineargument was used.Use the ":vi" command:visual to exit "Ex" mode.Note: In older versions of Vim "Q" formatted text,thatis now done withgq.  But if you use thevimrc_example.vimscript ordefaults.vim, "Q"works like "gq".  Except forSelect mode.gQgQSwitch to "Ex" mode like with "Q", but really behavelike typing ":" commands after another.  All commandline editing, completion etc.is available.Use the:vi command (`:visual`) to exit "Ex" mode.==============================================================================7. Thewindow contentswindow-contentsInNormal mode and Insert/Replace mode the screenwindow will show the currentcontents of the buffer: What You See Is What You Get.  There are twoexceptions:- When the'cpoptions' option contains '$', and the changeis within one line,  the textis not directly deleted, buta '$'isputat the last deleted  character.- Wheninserting text in one window, otherwindows on the same text are not  updated until theinsertis finished.Lines longer than thewindow width will wrap, unless the'wrap' optionis off(see below).  The'linebreak' option can be set to wrapata blank character.If thewindow has room after the last line of the buffer, Vim will show '~' inthe first column of the last lines in the window, like this:+-----------------------+|some line||last line||~||~|+-----------------------+Thus the '~' lines indicate that theend of the buffer was reached.If the last line inawindow doesn't fit, Vim will indicate this witha '@' inthe first column of the last lines in the window, like this:+-----------------------+|first line||second line||@||@|+-----------------------+Thus the '@' lines indicate that thereisa line that doesn't fit in thewindow.When the "lastline" flagis present in the'display' option, you will not see'@' charactersat the left side of window.  If the last line doesn't fitcompletely, only the part that fitsis shown, and the last three characters ofthe last line are replaced with "@@@", like this:+-----------------------+|first line||second line||a very long line thatd||oesn't fit in the wi@@@|+-----------------------+If thereisa single line thatis too long to fit in the window, thisisaspecial situation.  Vim will show only part of the line, around where thecursor is.  There are no special characters shown, so that you can edit allparts of this line.The '@' occasion in the'highlight' option can be used to set specialhighlighting for the '@' and '~' characters.  This makesit possible todistinguish them from real characters in the buffer.The'showbreak' option contains thestring toput in front of wrapped lines.wrap-offIf the'wrap' optionis off, long lines will not wrap.  Only the part thatfits on the screenis shown.  If the cursoris moved toa part of the linethatis not shown, the screenis scrolled horizontally.  The advantage ofthismethodis that columns are shownas they are and lines that cannot fiton the screen can be edited.  The disadvantageis that you cannot see all thecharacters ofa lineat once.  The'sidescroll' option can be set to theminimal number of columns to scroll.All normal ASCII characters are displayed directly on the screen.  The<Tab>is replaced with the number of spaces thatit represents.  Other non-printingcharacters are replaced with "^{char}", where{char}is the non-printingcharacter with 64 added.  Thus character 7 (bell) will be shownas "^G".Characters between 127 and 160 are replaced with "~{char}", where{char}isthe character with 64 subtracted.  These characters occupy more than oneposition on the screen.  The cursor can only be positioned on the first one.If you set the'number' option, all lines will be preceded with theirnumber.  Tip: If you don't like wrapping lines to mix with the line numbers,set the'showbreak' option to eight spaces:":set showbreak=\ \ \ \ \ \ \ \ "If you set the'list' option,<Tab> characters will not be shownas severalspaces, butas "^I".A '$' will be placedat theend of the line, so you canfind trailing blanks.InCommand-line mode only the command-line itselfis shown correctly.  Thedisplay of the buffer contentsis updatedas soonas yougo back to Commandmode.The last line of thewindowis used for status and other messages.  Thestatusmessages will only be used if an optionis on:status messageoption     defaultUnix defaultcurrent mode'showmode'on    oncommand characters'showcmd'on    offcursor position'ruler'off    offThe current modeis "-- INSERT--" or "-- REPLACE--", see'showmode'.  Thecommand characters are those that you typed but were not used yet.If you havea slowterminal you can switch off the statusmessages to speedup editing::set nosc noru nosmIf thereis an error, an error message will be shown forat least one second(in reverse video).Some commands show how many lines were affected.  Above which threshold thishappens can be controlled with the'report' option (default 2).On theAmiga Vim will run ina CLI window.  The name Vim and the full name ofthe current file name will be shown in the title bar.  When thewindowisresized, Vim will automatically redraw the window.  You may make thewindowassmallas you like, but ifit gets too small nota single line will fit in it.Makeitat least 40 characters wide to be able to read mostmessages on thelast line.On mostUnix systems, resizing thewindowis recognized and handled correctlyby Vim.==============================================================================8. Definitionsdefinitions  bufferContains lines of text, usually read froma file.  screenThe whole area that Vim uses to work in.  This can beaterminal emulator window.  Also called "the Vimwindow".windowAview ona buffer.  There can be multiplewindows forone buffer.A screen contains one or more windows, separated by status lines and with thecommand lineat the bottom.+-------------------------------+screen|window 1|window 2||||||||= status line=|= status line=||window 3||||||==== status line ==============||command line|+-------------------------------+The command lineis also used for messages.  It scrolls up the screen whenthereis not enough room in the command line.A differenceis made between four types of lines:  buffer linesThe lines in the buffer.  Thisis the sameas thelinesas they are read from/written toa file.  Theycan be thousands of characters long.  logical linesThe buffer lines withfolding applied.  Buffer linesina closed fold are changed toa single logical line:"+-- 99 lines folded".  They can be thousands ofcharacters long.window linesThe lines displayed ina window:A range of logicallines with wrapping, line breaks, etc.  applied.  Theycan only beas longas the width of thewindow allows,longer lines are wrapped or truncated.  screen linesThe lines of the screen that Vim uses.  Consists ofthewindow lines of all windows, with status linesand the command line added.  They can only beas longas the width of the screen allows.  When the commandline gets longerit wraps and lines are scrolled tomake room.buffer lineslogical lineswindow linesscreen lines1. one1. one1. +-- folded   1.  +-- folded2. two2. +-- folded2. five2.  five3. three3. five3. six3.  six4. four4. six4. seven4.  seven5. five5. seven5.  === status line ===6. six6.  aaa7. seven7.  bbb8.  ccc cccc1. aaa1. aaa1. aaa9.cc2. bbb2. bbb2. bbb10. ddd3. ccc ccc ccc3. ccc ccc ccc3. ccc cccc11.~ 4. ddd4. ddd4.cc12. === status line ===5. ddd13. (command line)6.~============================================================================== vim:tw=78:ts=8:noet:ft=help:norl:

Quick links:help overview ·quick reference ·user manual toc ·reference manual toc·faq


[8]ページ先頭

©2009-2025 Movatter.jp