{"id":164,"date":"2008-12-05T10:47:12","date_gmt":"2008-12-05T14:47:12","guid":{"rendered":"http:\/\/jianmingli.com\/wp\/?p=164"},"modified":"2013-03-01T09:31:28","modified_gmt":"2013-03-01T14:31:28","slug":"vi-commands","status":"publish","type":"post","link":"https:\/\/jianmingli.com\/wp\/?p=164","title":{"rendered":"vi Commands"},"content":{"rendered":"<table width=\"855\" border=\"0\">\n<tr>\n<td scope=\"col\">\n<div align=\"left\"><strong>Editing<\/strong><\/div>\n<\/td>\n<th scope=\"col\">&nbsp;<\/th>\n<th scope=\"col\">&nbsp;<\/th>\n<\/tr>\n<tr>\n<td width=\"201\" scope=\"col\">\n<div align=\"right\">Undo last edit: <\/div>\n<\/td>\n<th width=\"33\" scope=\"col\">&nbsp;<\/th>\n<td width=\"599\" scope=\"col\">\n<div align=\"left\">u <\/div>\n<\/td>\n<\/tr>\n<tr>\n<td scope=\"col\">\n<div align=\"left\"><strong>Editing between files <\/strong><\/div>\n<\/td>\n<th scope=\"col\">&nbsp;<\/th>\n<th scope=\"col\">&nbsp;<\/th>\n<\/tr>\n<tr>\n<td width=\"201\" scope=\"col\">\n<div align=\"right\">open another file: <\/div>\n<\/td>\n<th width=\"33\" scope=\"col\">&nbsp;<\/th>\n<td width=\"599\" scope=\"col\">\n<div align=\"left\">:e <\/div>\n<\/td>\n<\/tr>\n<tr>\n<td scope=\"row\">\n<div align=\"right\">switch to another file:<\/div>\n<\/td>\n<td>&nbsp;<\/td>\n<td>\n<div align=\"left\">:e #<\/div>\n<\/td>\n<\/tr>\n<tr>\n<td scope=\"row\">\n<div align=\"right\">copy 4 lines into f buffer: <\/div>\n<\/td>\n<td>&nbsp;<\/td>\n<td>\n<div align=\"left\">&#8220;f4yy <\/div>\n<\/td>\n<\/tr>\n<tr>\n<td scope=\"row\">\n<div align=\"right\">paste from f buffer:<\/div>\n<\/td>\n<td>&nbsp;<\/td>\n<td>\n<div align=\"left\">&#8220;fp <\/div>\n<\/td>\n<\/tr>\n<tr>\n<td scope=\"row\">\n<div align=\"left\"><strong>Open\/Save File: <\/strong><\/div>\n<\/td>\n<td>&nbsp;<\/td>\n<td>&nbsp;<\/td>\n<\/tr>\n<tr>\n<td scope=\"row\">\n<div align=\"right\">Open file and go to pattern: <\/div>\n<\/td>\n<td>&nbsp;<\/td>\n<td>vi +\/pattern <\/td>\n<\/tr>\n<tr>\n<td scope=\"row\">\n<div align=\"right\">redraw screen:<\/div>\n<\/td>\n<td>&nbsp;<\/td>\n<td>\n<div align=\"left\">ctrl L<\/div>\n<\/td>\n<\/tr>\n<tr>\n<td scope=\"row\">\n<div align=\"right\">revert to last save: <\/div>\n<\/td>\n<td>&nbsp;<\/td>\n<td>\n<div align=\"left\">:e! <\/div>\n<\/td>\n<\/tr>\n<tr>\n<td scope=\"row\">\n<div align=\"right\">Exit without save: <\/div>\n<\/td>\n<td>&nbsp;<\/td>\n<td>\n<div align=\"left\">:q! <\/div>\n<\/td>\n<\/tr>\n<tr>\n<td scope=\"row\">\n<div align=\"left\"><strong>Search string:<\/strong><\/div>\n<\/td>\n<td>&nbsp;<\/td>\n<td>&nbsp;<\/td>\n<\/tr>\n<tr>\n<td scope=\"row\">\n<div align=\"right\">search forward: <\/div>\n<\/td>\n<td>&nbsp;<\/td>\n<td>\/string <\/td>\n<\/tr>\n<tr>\n<td scope=\"row\">\n<div align=\"right\">search backward: <\/div>\n<\/td>\n<td>&nbsp;<\/td>\n<td>?string <\/td>\n<\/tr>\n<tr>\n<td scope=\"row\">\n<div align=\"right\">go to beginning of doc: <\/div>\n<\/td>\n<td>&nbsp;<\/td>\n<td>1 Shft G <\/td>\n<\/tr>\n<tr>\n<td scope=\"row\">\n<div align=\"left\"><strong>String Replacement:<\/strong><\/div>\n<\/td>\n<td>&nbsp;<\/td>\n<td>&nbsp;<\/td>\n<\/tr>\n<tr>\n<td scope=\"row\">\n<div align=\"right\">replace 1st occurance: <\/div>\n<\/td>\n<td>&nbsp;<\/td>\n<td>\n<div align=\"left\">:s\/old\/new <\/div>\n<\/td>\n<\/tr>\n<tr>\n<td scope=\"row\">\n<div align=\"right\">replace all in current line:<\/div>\n<\/td>\n<td>&nbsp;<\/td>\n<td>\n<div align=\"left\">:s\/old\/new\/g <\/div>\n<\/td>\n<\/tr>\n<tr>\n<td scope=\"row\">\n<div align=\"right\">global replacement: <\/div>\n<\/td>\n<td>&nbsp;<\/td>\n<td>\n<div align=\"left\">:%s\/editer\/editor\/g <\/div>\n<\/td>\n<\/tr>\n<tr>\n<td scope=\"row\">\n<div align=\"right\">Remove all ^M: <\/div>\n<\/td>\n<td>&nbsp;<\/td>\n<td>\n<div align=\"left\">:%s\/Ctrl V Ctrl M\/\/g <\/div>\n<\/td>\n<\/tr>\n<tr>\n<td scope=\"row\">\n<div align=\"right\">repeat last substitution: <\/div>\n<\/td>\n<td>&nbsp;<\/td>\n<td>:s <\/td>\n<\/tr>\n<tr>\n<td scope=\"row\">\n<div align=\"left\"><strong>Change Cases: <\/strong><\/div>\n<\/td>\n<td>&nbsp;<\/td>\n<td>&nbsp;<\/td>\n<\/tr>\n<tr>\n<td scope=\"row\">\n<div align=\"right\">Ignore case: <\/div>\n<\/td>\n<td>&nbsp;<\/td>\n<td>:set ic <\/td>\n<\/tr>\n<tr>\n<td scope=\"row\">\n<div align=\"right\">Do not ignore case: <\/div>\n<\/td>\n<td>&nbsp;<\/td>\n<td>:set noic<\/td>\n<\/tr>\n<tr>\n<td scope=\"row\">\n<div align=\"right\">change case: <\/div>\n<\/td>\n<td>&nbsp;<\/td>\n<td>~ <\/td>\n<\/tr>\n<tr>\n<td scope=\"row\">\n<div align=\"left\"><strong>Others:<\/strong><\/div>\n<\/td>\n<td>&nbsp;<\/td>\n<td>&nbsp;<\/td>\n<\/tr>\n<tr>\n<td scope=\"row\">\n<div align=\"right\">Turn vim color off<\/div>\n<\/td>\n<td>&nbsp;<\/td>\n<td>:syn off <\/td>\n<\/tr>\n<tr>\n<td scope=\"row\">\n<div align=\"right\">Delete to the end of file<\/div>\n<\/td>\n<td>&nbsp;<\/td>\n<td>dG<\/td>\n<\/tr>\n<\/table>\n<span id=\"References\"><h3>References<\/h3><\/span>\n<p>* A good <a href=\"http:\/\/www.ss64.com\/bashsyntax\/vi.html\">vi commands <\/a> page<br \/>\n* <a href=\"http:\/\/www.eng.hawaii.edu\/Tutor\/vi.html\">Mastering the VI editor<\/a><br \/>\n* <a href=\"http:\/\/www.lagmonster.org\/docs\/vi.html\">vi cheat sheet<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Editing &nbsp; &nbsp; Undo last edit: &nbsp; u Editing between files &nbsp; &nbsp; open another file: &nbsp; :e switch to another file: &nbsp; :e # copy 4 lines into f buffer: &nbsp; &#8220;f4yy paste from f buffer: &nbsp; &#8220;fp Open\/Save &hellip; <a href=\"https:\/\/jianmingli.com\/wp\/?p=164\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[85],"tags":[358,231,586],"class_list":["post-164","post","type-post","status-publish","format-standard","hentry","category-vi","tag-cheartsheet","tag-commands","tag-vi"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8cRUO-2E","_links":{"self":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/164","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=164"}],"version-history":[{"count":16,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/164\/revisions"}],"predecessor-version":[{"id":468,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/164\/revisions\/468"}],"wp:attachment":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=164"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=164"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=164"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}