{"id":2956,"date":"2022-01-24T05:36:52","date_gmt":"2022-01-24T13:36:52","guid":{"rendered":"https:\/\/192.168.1.30\/wordpress\/?p=2956"},"modified":"2022-01-24T06:04:08","modified_gmt":"2022-01-24T14:04:08","slug":"vim-vi-filename-default-ssh-editor","status":"publish","type":"post","link":"https:\/\/spiffynasty.com\/blahblahblah\/vim-vi-filename-default-ssh-editor\/","title":{"rendered":"VIM \/ vi filename &#8211; default ssh editor"},"content":{"rendered":"<p>Vim is the default editor that comes installed on the Asustor NAS.<\/p>\n<p>EDIT using<\/p>\n<pre><code class=\"language-javascript\"> $ vi filename<\/code><\/pre>\n<p>https:\/\/www.openvim.com\/<br \/>\n<a href=\"https:\/\/192.168.1.30\/wordpress\/vim-vi-filename-default-ssh-editor\/learnvim\/\" rel=\"attachment wp-att-2967\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/192.168.1.30\/wordpress\/wp-content\/uploads\/2022\/01\/learnvim.gif\" alt=\"\" width=\"720\" height=\"589\" class=\"aligncenter size-full wp-image-2967\" \/><\/a><br \/>\n<!--\n<a href=\"https:\/\/192.168.1.30\/wordpress\/vim-vi-filename-default-ssh-editor\/learnvimstatic\/\" rel=\"attachment wp-att-2968\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/192.168.1.30\/wordpress\/wp-content\/uploads\/2022\/01\/learnvimstatic.png\" alt=\"\" width=\"800\" height=\"655\" class=\"aligncenter size-full wp-image-2968\" srcset=\"https:\/\/spiffynasty.com\/blahblahblah\/wp-content\/uploads\/2022\/01\/learnvimstatic.png 800w, https:\/\/spiffynasty.com\/blahblahblah\/wp-content\/uploads\/2022\/01\/learnvimstatic-300x246.png 300w, https:\/\/spiffynasty.com\/blahblahblah\/wp-content\/uploads\/2022\/01\/learnvimstatic-768x629.png 768w, https:\/\/spiffynasty.com\/blahblahblah\/wp-content\/uploads\/2022\/01\/learnvimstatic-500x409.png 500w, https:\/\/spiffynasty.com\/blahblahblah\/wp-content\/uploads\/2022\/01\/learnvimstatic-600x491.png 600w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/a>\n--><\/p>\n<h3>Save \/ Exit \/ Edit Vim<\/h3>\n<p>><\/p>\n<p>Vim is the text editor of choice for many users that spend a lot of time on the command line. Unlike other editors, Vim has several modes of operation, which can be a little intimidating for new users.<\/p>\n<p>Vim or its precursor Vi comes preinstalled on macOS and almost all Linux distributions. Knowing the basics of Vim will help you when you encounter a situation where your favorite editor is not available.<\/p>\n<p>This guide explains how to save a file in Vim \/ Vi and quit the editor.<\/p>\n<h5>Vim Modes<\/h5>\n<p>When you launch the Vim editor, you\u2019re in normal mode. In this mode, you can use vim commands and navigate through the file.<\/p>\n<p>To type a text, you need to enter the insert mode by pressing the <code>i<\/code> key. This mode allows you to insert and delete characters in the same way you do in a regular <a href='https:\/\/linuxize.com\/post\/how-to-use-nano-text-editor\/'>text editor<\/a> .<\/p>\n<p>To go back to the normal mode from any other mode, just press the <code>Esc<\/code> key.<\/p>\n<h5>Open a File in Vim \/ Vi<\/h5>\n<p>To open a file using Vim, launch your terminal and type <code>vim<\/code> followed by the name of the file you want to edit or create:<\/p>\n<pre><code class=\"language-javascript\">vim file.text\r\n<\/code><\/pre>\n<p>Another way to open a file is to start the editor and type <code>:e file_name<\/code>, where <code>file_name<\/code> is the name of the file you want to open.<\/p>\n<h5>Save a File in Vim \/ Vi<\/h5>\n<p>The command to save a file in Vim is <code>:w<\/code>.<\/p>\n<p>To save the file without exiting the editor, switch back to normal mode by pressing <code>Esc<\/code>, type <code>:w<\/code> and hit <code>Enter<\/code>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-120255\" src=\"https:\/\/clickety-clack.click\/img\/vim-save-file_hua6383ba1696fabd20c1736dee812806a_26835_480x0_resize_q75_lanczos-design-assets\/ago-no-category\/1.jpg\" width=\"480\" height=\"185\" alt=\"Vim Save File\" \/><\/p>\n<ol start=''>\n<li>Press <code>Esc<\/code><\/li>\n<li>Type <code>:w<\/code><\/li>\n<li>Press <code>Enter<\/code><\/li>\n<\/ol>\n<p>There is also an update command <code>:up<\/code>, which writes the buffer to the file only if there are unsaved changes.<\/p>\n<p>To save the file under a different name, type <code>:w new_filename<\/code> and hit <code>Enter<\/code>.<\/p>\n<h5>Save a File and Quit Vim \/ Vi<\/h5>\n<p>The command to save a file in Vim and quit the editor is <code>:wq<\/code>.<\/p>\n<p>To save the file and exit the editor simultaneously, press <code>Esc<\/code> to switch to normal mode, type <code>:wq<\/code> and hit <code>Enter<\/code>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2963\" src=\"https:\/\/192.168.1.30\/wordpress\/wp-content\/uploads\/2022\/01\/vim-save-quit_hua6383ba1696fabd20c1736dee812806a_27023_480x0_resize_q75_lanczos-1.jpg\" width=\"480\" height=\"185\" alt=\"Vim Save Quit\" srcset=\"https:\/\/spiffynasty.com\/blahblahblah\/wp-content\/uploads\/2022\/01\/vim-save-quit_hua6383ba1696fabd20c1736dee812806a_27023_480x0_resize_q75_lanczos-1.jpg 480w, https:\/\/spiffynasty.com\/blahblahblah\/wp-content\/uploads\/2022\/01\/vim-save-quit_hua6383ba1696fabd20c1736dee812806a_27023_480x0_resize_q75_lanczos-1-300x116.jpg 300w\" sizes=\"auto, (max-width: 480px) 100vw, 480px\" \/><\/p>\n<ol start=''>\n<li>Press <code>Esc<\/code><\/li>\n<li>Type <code>:wq<\/code><\/li>\n<li>Press <code>Enter<\/code><\/li>\n<\/ol>\n<p>Another command to save a file and quit Vim is <code>:x<\/code>.<\/p>\n<p>The difference between these two commands is that <code>:x<\/code> writes the buffer to the file only if there are unsaved changes, whereas <code>:wq<\/code> always writes the buffer to file and updates the file modification time.<\/p>\n<h5>Quit Vim \/ Vi without Saving the File<\/h5>\n<p>To exit the editor, without saving the changes, switch to normal mode by pressing <code>Esc<\/code>, type <code>:q!<\/code> and hit <code>Enter<\/code>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2964\" src=\"https:\/\/192.168.1.30\/wordpress\/wp-content\/uploads\/2022\/01\/vim-quit-no-save_hub649983214dcf36a96ee6bd6fe8f5af9_26921_480x0_resize_q75_lanczos-1.jpg\" width=\"480\" height=\"185\" alt=\"Vim Quit NoSave \" srcset=\"https:\/\/spiffynasty.com\/blahblahblah\/wp-content\/uploads\/2022\/01\/vim-quit-no-save_hub649983214dcf36a96ee6bd6fe8f5af9_26921_480x0_resize_q75_lanczos-1.jpg 480w, https:\/\/spiffynasty.com\/blahblahblah\/wp-content\/uploads\/2022\/01\/vim-quit-no-save_hub649983214dcf36a96ee6bd6fe8f5af9_26921_480x0_resize_q75_lanczos-1-300x116.jpg 300w\" sizes=\"auto, (max-width: 480px) 100vw, 480px\" \/><\/p>\n<ol start=''>\n<li>Press <code>Esc<\/code><\/li>\n<li>Type <code>:q!<\/code><\/li>\n<li>Press <code>Enter<\/code><\/li>\n<\/ol>\n<h5>Conclusion<\/h5>\n<p>In this guide, we have shown you how to save a file in Vim and exit the editor. If you are new to Vim, visit the <a href='https:\/\/www.openvim.com\/'>Open Vim<\/a> site where you can practice Vim with an interactive tutorial.<\/p>\n<p>Feel free to leave a comment if you have any questions.<\/p>\n<p>&nbsp;<\/p>\n<h3>VIM Editor Commands<\/h3>\n<p>Vim is an editor to create or edit a text file.<\/p>\n<p>There are two modes in vim. One is the command mode and another is the insert mode.<\/p>\n<p>In the command mode, user can move around the file, delete text, etc.<\/p>\n<p>In the insert mode, user can insert text.<\/p>\n<p>&nbsp;<\/p>\n<p>Changing mode from one to another<\/p>\n<p>&nbsp;<\/p>\n<p><b>From<\/b> command mode <b>to<\/b> insert mode type <b>a<\/b>\/<b>A<\/b>\/<b>i<\/b>\/<b>I<\/b>\/<b>o<\/b>\/<b>O<\/b> ( see details below)<\/p>\n<p>&nbsp;<\/p>\n<p><b>From<\/b> insert mode <b>to<\/b> command mode type <b>Esc<\/b> (escape key)<\/p>\n<p>Some useful commands for VIM<\/p>\n<p>&nbsp;<\/p>\n<p><b>Text Entry Commands<\/b> (Used to start text entry)<\/p>\n<p>&nbsp;<\/p>\n<p><b>a<\/b> Append text following current cursor position<\/p>\n<p>&nbsp;<\/p>\n<p><b>A<\/b> Append text to the end of current line<\/p>\n<p>&nbsp;<\/p>\n<p><b>i<\/b> Insert text before the current cursor position<\/p>\n<p>&nbsp;<\/p>\n<p><b>I<\/b> Insert text at the beginning of the cursor line<\/p>\n<p>&nbsp;<\/p>\n<p><b>o<\/b> Open up a new line following the current line and add text there<\/p>\n<p>&nbsp;<\/p>\n<p><b>O<\/b> Open up a new line in front of the current line and add text there<\/p>\n<p>&nbsp;<\/p>\n<p>The following commands are used only in the commands mode.<\/p>\n<p>&nbsp;<\/p>\n<p>Cursor Movement Commands<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: Courier New; font-size: small;\">h Moves the cursor one character to the left<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>l Moves the cursor one character to the right<\/p>\n<p>k Moves the cursor up one line<\/p>\n<p>j Moves the cursor down one line<\/p>\n<p>nG or :n Cursor goes to the specified (n) line<\/p>\n<p>&nbsp;<\/p>\n<p>(ex. 10G goes to line 10)<\/p>\n<p>&nbsp;<\/p>\n<p>^F (CTRl F) Forward screenful<\/p>\n<p>^B Backward screenful<\/p>\n<p>^f One page forward<\/p>\n<p>^b One page backward<\/p>\n<p>^U Up half screenful<\/p>\n<p>^D Down half screenful<\/p>\n<p>$ Move cursor to the end of current line<\/p>\n<p>0 (zero) Move cursor to the beginning of current line<br \/>\n<br \/>\nw Forward one word<\/p>\n<p>b Backward one word<\/p>\n<p>&nbsp;<\/p>\n<p>Exit Commands<\/p>\n<p>&nbsp;<\/p>\n<p>:wq Write file to disk and quit the editor<\/p>\n<p>:q! Quit (no warning)<\/p>\n<p>:q Quit (a warning is printed if a modified file has not been saved)<\/p>\n<p>ZZ Save workspace and quit the editor (same as :wq)<\/p>\n<p>: 10,25 w temp<\/p>\n<p>write lines 10 through 25 into file named temp. Of course, other line<\/p>\n<p>numbers can be used. (Use :f to find out the line numbers you want.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Text Deletion Commands<\/p>\n<p>x Delete character<\/p>\n<p>dw Delete word from cursor on<br \/>\n<br \/>\ndb Delete word backward<br \/>\n<br \/>\ndd Delete line<\/p>\n<p>d$ Delete to end of line<\/p>\n<p>d^ (d caret, not CTRL d) Delete to beginning of line<\/p>\n<p>&nbsp;<\/p>\n<p><b>Yank<\/b> (has most of the options of delete)&#8211; VI&#8217;s <b>copy<\/b> commmand<\/p>\n<p>yy yank current line<\/p>\n<p>y$ yank to end of current line from cursor<\/p>\n<p>yw yank from cursor to end of current word<\/p>\n<p>5yy yank, for example, 5 lines<\/p>\n<p>&nbsp;<\/p>\n<p><b>Paste<\/b> (used after delete or yank to recover lines.)<\/p>\n<p>p paste below cursor<\/p>\n<p>P paste above cursor<\/p>\n<p>&#8220;2p paste from buffer 2 (there are 9)<\/p>\n<p>u Undo last change<\/p>\n<p>U Restore line<\/p>\n<p>J Join next line down to the end of the current line<\/p>\n<p>&nbsp;<\/p>\n<p>File Manipulation Commands<\/p>\n<p>&nbsp;<\/p>\n<p>:w Write workspace to original file<\/p>\n<p>:w file Write workspace to named file<\/p>\n<p>:e file Start editing a new file<\/p>\n<p>:r file Read contents of a file to the workspace<\/p>\n<p>&nbsp;<\/p>\n<p><b>To create a page break,<\/b> while in the insert mode, press the CTRL key<\/p>\n<p>And l. ^L will appear in your text and will cause the printer to start<\/p>\n<p>A new page.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Other Useful Commands<\/p>\n<p>Most commands can be repeated n times by typing a number, n, before<\/p>\n<p>the command. For example 10dd means delete 10 lines.<\/p>\n<p>. Repeat last command<\/p>\n<p>cw Change current word to a new word<\/p>\n<p>r Replace one character at the cursor position<\/p>\n<p>R Begin overstrike or replace mode \ufffd use ESC key to exit<\/p>\n<p>:\/ pattern Search forward for the pattern<\/p>\n<p>\ud83d\ude15 pattern Search backward for the pattern<\/p>\n<p>n (used after either of the 2 search commands above to<\/p>\n<p>continue to find next occurrence of the pattern.<\/p>\n<p>:g\/pat1\/s\/\/pat2\/g replace every occurrence of pattern1 (pat1) with<\/p>\n<p>pat2<\/p>\n<p>&nbsp;<\/p>\n<p><b>Example :<\/b>g\/tIO\/s\/\/Ada.Text_IO\/g<\/p>\n<p>This will find and replace tIO by Ada.text_IO everywhere in the file.<\/p>\n<p>:g\/a\/s\/\/ \/g replace the letter a, by blank<\/p>\n<p>:g\/a\/s\/\/\/g replace a by nothing<\/p>\n<p>note: Even this command be undone by u<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Examples<\/p>\n<p>&nbsp;<\/p>\n<p>Opening a New File<\/p>\n<p>&nbsp;<\/p>\n<p>Step 1 type <b>vim <i>filename<\/i><\/b> (create a file named <i>filename<\/i>)<\/p>\n<p>Step 2 type <b>i<\/b> ( switch to insert mode)<\/p>\n<p>Step 3 enter text (enter your Ada program)<\/p>\n<p>Step 4 hit <b>Esc key<\/b> (switch back to command mode)<\/p>\n<p>Step 5 type <b>:wq<\/b> (write file and exit vim)<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Editing the Existing File<\/p>\n<p>Step 1 type <b>vim <i>filename<\/i><\/b> (edit the existing file named filename)<\/p>\n<p>Step 2 move around the file using <b>h<\/b>\/<b>j<\/b>\/<b>k<\/b>\/<b>l<\/b> key or any appropriate command<\/p>\n<p><b><span style=\"font-family: Courier New; font-size: small;\">h<\/span><\/b><span style=\"font-family: Courier New; font-size: small;\"> Moves the cursor one character to the left<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><dir><\/dir><dir><\/dir>&nbsp;<\/p>\n<p><b>l<\/b> Moves the cursor one character to the right<\/p>\n<p>&nbsp;<\/p>\n<p><b>k<\/b> Moves the cursor up one line<\/p>\n<p>&nbsp;<\/p>\n<p><b>j<\/b> Moves the cursor down one line<\/p>\n<p>&nbsp;<\/p>\n<p><b>nG<\/b> or :n Cursor goes to the specified (n) line<\/p>\n<p>&nbsp;<\/p>\n<p>(ex. 10G goes to line 10)<\/p>\n<p><i><br \/>\n<\/i><i><br \/>\n<\/i><i><br \/>\n<\/i><i><\/i><\/p>\n<p>&nbsp;<\/p>\n<p>Step 3 <b>edit<\/b> required text (replace or delete or insert)<\/p>\n<p>Step 4 hit <b>Esc<\/b> key (exit from insert mode if you insert or replace text)<\/p>\n<p>Step 5 type <b>:wq<\/b><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Vim is the default editor that comes installed on the Asustor NAS. EDIT using $ vi filename https:\/\/www.openvim.com\/ Save \/ Exit \/ Edit Vim > Vim is the text editor of choice for many users that spend a lot of time on the command line. Unlike other editors, Vim has several modes of operation, which can be a little intimidating for new users. Vim or its precursor Vi comes preinstalled on macOS and almost all Linux distributions. Knowing the basics of Vim will help you when you encounter a situation where your favorite editor is not available. This guide explains how to save a file in Vim \/ Vi and quit the editor. Vim Modes When you launch the Vim editor, you\u2019re in normal mode. In this mode, you can use vim commands and navigate through the file. To type a text, you need to enter the insert mode by pressing the i key. This [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2960,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[27],"tags":[],"class_list":["post-2956","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-nas"],"_links":{"self":[{"href":"https:\/\/spiffynasty.com\/blahblahblah\/wp-json\/wp\/v2\/posts\/2956","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/spiffynasty.com\/blahblahblah\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/spiffynasty.com\/blahblahblah\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/spiffynasty.com\/blahblahblah\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/spiffynasty.com\/blahblahblah\/wp-json\/wp\/v2\/comments?post=2956"}],"version-history":[{"count":6,"href":"https:\/\/spiffynasty.com\/blahblahblah\/wp-json\/wp\/v2\/posts\/2956\/revisions"}],"predecessor-version":[{"id":2972,"href":"https:\/\/spiffynasty.com\/blahblahblah\/wp-json\/wp\/v2\/posts\/2956\/revisions\/2972"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/spiffynasty.com\/blahblahblah\/wp-json\/wp\/v2\/media\/2960"}],"wp:attachment":[{"href":"https:\/\/spiffynasty.com\/blahblahblah\/wp-json\/wp\/v2\/media?parent=2956"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/spiffynasty.com\/blahblahblah\/wp-json\/wp\/v2\/categories?post=2956"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/spiffynasty.com\/blahblahblah\/wp-json\/wp\/v2\/tags?post=2956"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}