Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to save a file in vim editor without quit

Tags:

vim

I know the basic command ESC + SHIFT ZZ and another ESC + :wq ENTER but i don't want to quit vim editor.I want to save the file and the file should remain open in vim.

Any help will be appreciated.

like image 609
darshan Avatar asked May 18 '16 15:05

darshan


People also ask

How do I save in Vim without quitting?

The command to save a file in Vim is :w . To save the file without exiting the editor, switch back to normal mode by pressing Esc , type :w and hit Enter . There is also an update command :up , which writes the buffer to the file only if there are unsaved changes.

How do I save a file in Vim after editing?

To save a file in Vim / vi, press Esc key, type :w and hit Enter key. One can save a file and quit vim / Vi by pressing Esc key, type :x and hit Enter key.

How do you save in Vim?

Press Esc key and type :w to save a file in vim. One can press Esc and type :wq to save changes to a file and exit from vim.


2 Answers

ESC, :, w, Enter

The w is "write", the q is "quit"; use only "write".

like image 110
max66 Avatar answered Oct 13 '22 22:10

max66


Here's another shorcut that works, if you're interested in saving a keystroke or two. Run the below commands (as long as your Vim(rc) config file matches the below target destination):

`$ echo "noremap ww :w<CR>" >> ~/.vimrc` `$ source ~/.vimrc`    . 

This should add a line to your Vim config file, noremap ww :w<CR>, which: (1.) Declares it's going to create a new Normal-Mode "Remap" (noremap); (2.) Designates what we can consider a new operator, or operating keystroke, ww, for the...; (3.) ...for the operand command, :w<CR>, which stands for "[Enter the] command mode, with ':', then key stroke 'w', following with a Carrige Return ()", and is the how the operator will behave when called. In case you're not familiar with Vim's Normal mode shortcuts: For example, using my example, you'd literally just type the letters 'ww', and read the bottom for confirmation that lines were written. (There are no "CTRL-... or CMD- or Shift-"-like combinations necessary.)

like image 45
Levi Maes Avatar answered Oct 13 '22 21:10

Levi Maes