[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-seo-571586-105":3,"detail-sidebar-cat-1-en-105":81,"doc-detail-571586-en":127},{"code":4,"msg":5,"data":6},0,"ok",{"site_id":7,"language":8,"slug":9,"title":10,"keywords":11,"description":12,"schema_data":13,"social_meta":74,"head_meta":76,"extra_data":78,"updated_unix":80},105,"en","vi-cheat-sheet-editing-modes-commands","vi Cheat Sheet - Editing Modes - Commands","","vi Cheat Sheet summarizes essential vi text editor operations for efficient editing in command and insert modes. It provides practical command syntax for starting and stopping vi, recovering lost sessions, and configuring initialization via .exrc and EXINIT. The sheet covers cursor movement by characters, lines, words, and scrolling controls, plus text insertion, replacement, margin wrapping, deletion, copy/paste, and searching with substitution including ranges and flags. It also lists miscellaneous workflows like shell commands, undo, repeats, file reading, line joining, line numbers, and screen refresh.",{"@graph":14,"@context":73},[15,34,56],{"@type":16,"itemListElement":17},"BreadcrumbList",[18,23,27,31],{"item":19,"name":20,"@type":21,"position":22},"https://docshare.wps.com","Home","ListItem",1,{"item":24,"name":25,"@type":21,"position":26},"https://docshare.wps.com/template/","Template",2,{"item":28,"name":29,"@type":21,"position":30},"https://docshare.wps.com/template/presentations/","Presentations",3,{"item":32,"name":10,"@type":21,"position":33},"https://docshare.wps.com/template/vi-cheat-sheet-editing-modes-commands/571586/",4,{"url":32,"name":10,"@type":35,"image":36,"author":41,"headline":10,"publisher":44,"fileFormat":47,"inLanguage":8,"description":12,"dateModified":48,"datePublished":49,"encodingFormat":47,"isAccessibleForFree":50,"interactionStatistic":51},"DigitalDocument",{"url":37,"@type":38,"width":39,"height":40},"https://docshare.wps.com/thumbnails/vi-cheat-sheet-editing-modes-commands/571586.png","ImageObject",442,249,{"name":42,"@type":43},"Nguyễn Văn Học","Person",{"url":19,"name":45,"@type":46},"DocShare","Organization","application/pdf","2026-10-21","2026-10-13",true,{"@type":52,"interactionType":53,"userInteractionCount":55},"InteractionCounter",{"@type":54},"ViewAction",7,{"@type":57,"mainEntity":58},"FAQPage",[59,65,69],{"name":60,"@type":61,"acceptedAnswer":62},"How do I start vi in read-only mode?","Question",{"text":63,"@type":64},"Use % vi -R filename. Make sure the terminal setup is correct (for example, % set term=vt100).","Answer",{"name":66,"@type":61,"acceptedAnswer":67},"How do I save and quit vi, or quit without saving?",{"text":68,"@type":64},":wq saves changes and exits vi, while :q! quits without saving changes.",{"name":70,"@type":61,"acceptedAnswer":71},"How can I search and repeat searches in vi?",{"text":72,"@type":64},"Use / string to search forward and ? string to search backward (the sheet shows / for forward and the described backward form). Press n to repeat in the same direction and N to repeat in the opposite direction.","https://schema.org",{"og:url":32,"og:type":75,"og:title":10,"og:site_name":45,"og:description":12},"article",{"robots":77,"canonical":32},"index,follow",{"doc_id":79,"site_id":7},571586,1792016902,{"code":4,"msg":82,"data":83},"success",[84,88,93,98,103,108,113,118,123],{"id":85,"doc_module":22,"doc_module_name":25,"category_name":29,"show_sort_weight":86,"slug":87},11,90,"presentations",{"id":89,"doc_module":22,"doc_module_name":25,"category_name":90,"show_sort_weight":91,"slug":92},12,"Resumes",80,"resumes",{"id":94,"doc_module":22,"doc_module_name":25,"category_name":95,"show_sort_weight":96,"slug":97},14,"Invoices",70,"invoices",{"id":99,"doc_module":22,"doc_module_name":25,"category_name":100,"show_sort_weight":101,"slug":102},15,"Posters",60,"posters",{"id":104,"doc_module":22,"doc_module_name":25,"category_name":105,"show_sort_weight":106,"slug":107},16,"Social Media",50,"social-media",{"id":109,"doc_module":22,"doc_module_name":25,"category_name":110,"show_sort_weight":111,"slug":112},17,"Forms",40,"forms",{"id":114,"doc_module":22,"doc_module_name":25,"category_name":115,"show_sort_weight":116,"slug":117},18,"Letters",30,"letters",{"id":119,"doc_module":22,"doc_module_name":25,"category_name":120,"show_sort_weight":121,"slug":122},21,"Paper Templates",5,"papers-templates",{"id":124,"doc_module":22,"doc_module_name":25,"category_name":125,"show_sort_weight":4,"slug":126},158,"General","general-158",{"code":4,"msg":82,"data":128},{"doc_id":79,"user_id":129,"nickname":42,"user_avatar":130,"doc_module":22,"category_id":85,"category_name":29,"doc_title":10,"doc_description":12,"doc_content":131,"file_id":132,"file_url":133,"file_type":134,"file_size":135,"view_count":55,"is_deleted":4,"is_public":22,"is_downloadable":22,"audit_status":22,"page_count":26,"language":136,"language_code":8,"site_id":7,"html_lang":8,"table_of_contents":137,"faqs":138,"seo_title":139,"seo_description":12,"update_tm":140,"read_time":22},1374402739827,"https://ap-avatar.wpscdn.com/avatar/14000c97e7351f1a627?x-image-process=image/resize,m_fixed,w_180,h_180&k=1787885694763230660","[https://t.me/learningnets](https://t.me/learningnets)  \nvi Cheat Sheet  \nEditing Modes  \nCommand mode Insert mode  \nKeystrokes used as commands Characters inserted into file  \n% vi filename  \ni, a—insert mode command  \ncommand mode insert mode  \n\u003CESC>—escape  \n:wq—exit (save changes)  :q!—quit (discard changes)  \n%  \nInvoking and Terminating  \n\n| Invoking | % vi filename\u003Cbr>Make sure terminal setup is correct (% set term=vt100)% vi -R filename\u003Cbr>invoke vi in read only mode |\n| --- | --- |\n| Terminating | :wq exit vi, saving changes\u003Cbr>:q! quit vi, without saving changes |\n| Recovering Lost Editing Sessions | % vi -r filename\u003Cbr>recover ﬁle after system crash\u003Cbr>% vi -r list all recoverable ﬁles |\n| Initialization | .exrc ﬁle containing ex commands to be\u003Cbr>executed upon startup\u003Cbr>EXINIT environment variable containing vi\u003Cbr>commands to be executed upon startup |\n\nCursor Movement  \n\n| Moving by characters | h (or backspace)\u003Cbr>move left one character\u003Cbr>j move down one line\u003Cbr>k move up one line\u003Cbr>l (or space) move right one character\u003Cbr>Arrow keys may also be used |\n| --- | --- |\n| Moving by lines | 1G go to ﬁrst line\u003Cbr>nG go to nth line\u003Cbr>G go to last line\u003Cbr>^ go to beginning of line\u003Cbr>$ go to end of line |\n| Moving bywords | w go forward one word\u003Cbr>b go backward one word |\n| Scrolling | Ctrl-f scroll forward one screen\u003Cbr>Ctrl-b scroll backward one screen\u003Cbr>Ctrl-d scroll down one half screen\u003Cbr>Ctrl-u scroll up one half screen |\n\nInserting Text  \n\n| Inserting Text | The following commands place you in insert mode:\u003Cbr>i insert text before cursor\u003Cbr>a append text after cursor\u003Cbr>I insert text at beginning of line\u003Cbr>A append text at end of line\u003Cbr>o start adding text in new line below present line\u003Cbr>O start adding text in new line above\u003Cbr>present line Use Escape to return to command mode |\n| --- | --- |\n| Replacing Text | r char substitute char for character under\u003Cbr>cursor\u003Cbr>R overwrite old text (end with Esc)\u003Cbr>w change current word to new word (end\u003Cbr>with Esc) |\n| Setting Margins | :set wrapmargin=x\u003Cbr>Sets right margin to x, automatic word wrap |\n\n[https://t.me/learningnets](https://t.me/learningnets)  \nDeleting, Copying, and Pasting Text  \n\n| Deleting Text | x delete character at cursor\u003Cbr>dd delete line\u003Cbr>ndd delete n lines\u003Cbr>ndw delete n words\u003Cbr>d$ delete to end of line\u003Cbr>d^ delete to beginning of line\u003Cbr>dG delete to end of ﬁle\u003Cbr>d1G delete to beginning of ﬁle |\n| --- | --- |\n| Copying Text | yy yank current line into buffer\u003Cbr>nyy yank n lines into buffer\u003Cbr>yw yank word\u003Cbr>nyw yank n words |\n| Pasting Text | p put most recently deleted or yanked\u003Cbr>characters or words after cursor; put lines\u003Cbr>below current line\u003Cbr>P put most recently deleted or yanked\u003Cbr>characters or words before cursor; put\u003Cbr>lines above current line |\n\nSearches and Substitution  \n\n| Simple Searches | / string search forward for string? string search backward for string\u003Cbr>n repeat search\u003Cbr>N repeat search in opposite direction |\n| --- | --- |\n| Global Search | :g/string/ command\u003Cbr>execute command on lines containing\u003Cbr>string\u003Cbr>:v/string/ command\u003Cbr>execute command on linesnot containing\u003Cbr>string |\n| Substitution | : x, ys/oldstring/newstring/flags\u003Cbr>Substitutes newstring for oldstring in line range x, y. flags (optional):\u003Cbr>c wait for conﬁrmation (y or n)\u003Cbr>g replace all occurrences within speciﬁed\u003Cbr>lines (default is to replace only ﬁrst occurrence)\u003Cbr>Range speciﬁers:\u003Cbr>. current line\u003Cbr>$ last line\u003Cbr>% entire ﬁle |\n\nSearches and Substitution (cont.)  \n\n| Special Characters | [ ccc] matches any speciﬁed character\u003Cbr>[^ ccc] matches any character except those\u003Cbr>speciﬁed\u003Cbr>[ c1-c2] matches any character in range\u003Cbr>^ matches beginning of line\u003Cbr>$ matches end of line\u003Cbr>. matches any one character\u003Cbr>* matches zero or more occurrences of previous character\u003Cbr>.* matches any number of characters |\n| --- | --- |\n| Case Sensitivity | :set ignorecase\u003Cbr>disable case sensitivity\u003Cbr>:set noic enable case sensitivity |","cbCaiiTl5Lhx4T64","https://ap.wps.com/l/cbCaiiTl5Lhx4T64","pdf",27074,"English","# Editing Modes\n## Invoking and Terminating\n## Recovering Lost Editing Sessions\n## Initialization\n# Cursor Movement\n## Moving by characters\n## Moving by lines\n## Moving by words\n## Scrolling\n# Inserting and Replacing Text\n## Inserting Text\n## Replacing Text\n## Setting Margins\n# Deleting, Copying, and Pasting Text\n## Deleting Text\n## Copying Text\n## Pasting Text\n# Searches and Substitution\n## Simple Searches\n## Global Search\n## Substitution\n## Special Characters\n## Case Sensitivity\n# Miscellaneous Commands\n## Shell Commands\n## Undoing Commands\n## Repeating Commands\n## Reading in Files\n## Joining Lines\n## Line Numbers\n## Screen Refresh","[{\"question\":\"How do I start vi in read-only mode?\",\"answer\":\"Use % vi -R filename. Make sure the terminal setup is correct (for example, % set term=vt100).\"},{\"question\":\"How do I save and quit vi, or quit without saving?\",\"answer\":\":wq saves changes and exits vi, while :q! quits without saving changes.\"},{\"question\":\"How can I search and repeat searches in vi?\",\"answer\":\"Use / string to search forward and ? string to search backward (the sheet shows / for forward and the described backward form). Press n to repeat in the same direction and N to repeat in the opposite direction.\"}]","vi Cheat Sheet - Editing Modes - Commands | PDF",1791922482]