{"id":1394,"date":"2017-06-11T19:38:47","date_gmt":"2017-06-11T19:38:47","guid":{"rendered":"https:\/\/scunster.co.uk\/?p=1394"},"modified":"2017-06-11T21:10:16","modified_gmt":"2017-06-11T21:10:16","slug":"vi-vim-editor-how-to-edit-cut-copy-and-paste","status":"publish","type":"post","link":"https:\/\/scunster.co.uk\/?p=1394","title":{"rendered":"vi \/ vim editor &#8211; how to edit, cut, copy and paste!"},"content":{"rendered":"<p>When working with the shell in linux you&#8217;ll often have to edit or change a text file \/ config file or two.<\/p>\n<p>The easiest way to do this is to use vi or vim straight from the shell. Simply type vi followed by the name of the file that you wish to open and edit or create. You must provide the full path for the file you want to open or create.<\/p>\n<p>If you type vi and then a filename that doesn&#8217;t already exist, vi will create that file for you.<\/p>\n<pre>vi name_of_file.txt<\/pre>\n<p>Once opened you won&#8217;t be able to edit or change the file without using these keys<\/p>\n<p>Press i to insert, this allows you to start editing \/ deleting existing text, press ESC once finished.<\/p>\n<p>Press v to start to highlight text or multiple rows of text, use the arrow keys to make your selection.<\/p>\n<p>once highlighted with v you can:<br \/>\nPress delete to delete!<br \/>\nPress y to copy the selection.<br \/>\nPress d to cut the selection.<\/p>\n<p>Press p to paste<\/p>\n<p>How to save and quit<br \/>\nPress Escape to cancel any key mode you might be in such as highlight, insert etc<\/p>\n<p>Type w: and press return to write the changes ie. save the file<br \/>\nType q: to quit the editor and return to shell<\/p>\n<p>When working remotely using pussy for example, you can interact with vi by copying the contents of your clipboard to vi by using the right mouse button<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When working with the shell in linux you&#8217;ll often have to edit or change a text file \/ config file or two. The easiest way to do this is to use vi or vim straight from the shell. Simply type vi followed by the name of the file that you wish to open and edit [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[363,96,198,361,362],"class_list":["post-1394","post","type-post","status-publish","format-standard","hentry","category-linux","tag-editor","tag-shell","tag-text","tag-vi","tag-vim"],"_links":{"self":[{"href":"https:\/\/scunster.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1394","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/scunster.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/scunster.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/scunster.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/scunster.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1394"}],"version-history":[{"count":5,"href":"https:\/\/scunster.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1394\/revisions"}],"predecessor-version":[{"id":1404,"href":"https:\/\/scunster.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1394\/revisions\/1404"}],"wp:attachment":[{"href":"https:\/\/scunster.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1394"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/scunster.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1394"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/scunster.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1394"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}