{"id":1595,"date":"2024-02-05T00:00:00","date_gmt":"2024-02-05T05:00:00","guid":{"rendered":"https:\/\/molecularsciences.org\/content\/?p=1595"},"modified":"2024-02-21T08:15:19","modified_gmt":"2024-02-21T13:15:19","slug":"vi-editor-cheatsheet","status":"publish","type":"post","link":"https:\/\/molecularsciences.org\/content\/vi-editor-cheatsheet\/","title":{"rendered":"VI Editor Cheatsheet"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Modes:<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Normal Mode (Esc):<\/strong> Used for navigation and commands.<\/li>\n\n\n\n<li><strong>Insert Mode (i):<\/strong> Used for inserting or editing text.<\/li>\n\n\n\n<li><strong>Visual Mode (v):<\/strong> Used for selecting text.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Navigation:<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>h, j, k, l:<\/strong> Move left, down, up, and right respectively.<\/li>\n\n\n\n<li><strong>0 (zero):<\/strong> Move to the beginning of the line.<\/li>\n\n\n\n<li><strong>^ (caret):<\/strong> Move to the first non-whitespace character of the line.<\/li>\n\n\n\n<li><strong>$:<\/strong> Move to the end of the line.<\/li>\n\n\n\n<li><strong>G:<\/strong> Move to the end of the file or to a specified line number (e.g., <code>:12<\/code>).<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Editing:<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>i:<\/strong> Enter Insert mode before the cursor.<\/li>\n\n\n\n<li><strong>I:<\/strong> Enter Insert mode at the beginning of the line.<\/li>\n\n\n\n<li><strong>a:<\/strong> Enter Insert mode after the cursor.<\/li>\n\n\n\n<li><strong>A:<\/strong> Enter Insert mode at the end of the line.<\/li>\n\n\n\n<li><strong>o:<\/strong> Open a new line below the current line.<\/li>\n\n\n\n<li><strong>O:<\/strong> Open a new line above the current line.<\/li>\n\n\n\n<li><strong>x:<\/strong> Delete the character under the cursor.<\/li>\n\n\n\n<li><strong>dd:<\/strong> Delete the current line.<\/li>\n\n\n\n<li><strong>yy:<\/strong> Copy (yank) the current line.<\/li>\n\n\n\n<li><strong>p:<\/strong> Paste the yanked or deleted text after the cursor.<\/li>\n\n\n\n<li><strong>u:<\/strong> Undo the last change.<\/li>\n\n\n\n<li><strong>Ctrl + r:<\/strong> Redo the last undone change.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Visual Mode:<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>v:<\/strong> Enter Visual mode to select characters.<\/li>\n\n\n\n<li><strong>V:<\/strong> Enter Visual mode to select whole lines.<\/li>\n\n\n\n<li><strong>Ctrl + v:<\/strong> Enter Visual block mode to select a block of text.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Search and Replace:<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\/pattern:<\/strong> Search forward for the specified pattern.<\/li>\n\n\n\n<li><strong>?pattern:<\/strong> Search backward for the specified pattern.<\/li>\n\n\n\n<li><strong>n:<\/strong> Move to the next occurrence of the search pattern.<\/li>\n\n\n\n<li><strong>N:<\/strong> Move to the previous occurrence of the search pattern.<\/li>\n\n\n\n<li><strong>:s\/old\/new:<\/strong> Replace the first occurrence of &#8216;old&#8217; with &#8216;new&#8217; in the current line.<\/li>\n\n\n\n<li><strong>:s\/old\/new\/g:<\/strong> Replace all occurrences of &#8216;old&#8217; with &#8216;new&#8217; in the current line.<\/li>\n\n\n\n<li><strong>:%s\/old\/new\/g:<\/strong> Replace all occurrences of &#8216;old&#8217; with &#8216;new&#8217; in the entire file.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Saving and Quitting:<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>:w:<\/strong> Save changes.<\/li>\n\n\n\n<li><strong>:q:<\/strong> Quit (close) the editor.<\/li>\n\n\n\n<li><strong>:wq or :x:<\/strong> Save changes and quit.<\/li>\n\n\n\n<li><strong>:q!:<\/strong> Quit without saving.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Miscellaneous:<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Ctrl + g:<\/strong> Show file information and cursor position.<\/li>\n\n\n\n<li><strong>:set number:<\/strong> Display line numbers.<\/li>\n\n\n\n<li><strong>:set nonumber:<\/strong> Hide line numbers.<\/li>\n\n\n\n<li><strong>:help command:<\/strong> Open help for a specific command.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Modes: Navigation: Editing: Visual Mode: Search and Replace: Saving and Quitting: Miscellaneous:<\/p>\n","protected":false},"author":1,"featured_media":1790,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[265],"tags":[],"class_list":["post-1595","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-reference"],"_links":{"self":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/1595","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/comments?post=1595"}],"version-history":[{"count":1,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/1595\/revisions"}],"predecessor-version":[{"id":1596,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/1595\/revisions\/1596"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/media\/1790"}],"wp:attachment":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/media?parent=1595"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/categories?post=1595"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/tags?post=1595"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}