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.
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.
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.
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.
ESC, :, w, Enter
The w
is "write", the q
is "quit"; use only "write".
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.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With