I know the basic command ESC + SHIFT ZZ and another, ESC + :wq ENTER, but I don't want to quit Vim.
I want to save the file and the file should remain open in Vim.
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.)
w to navigate. w is supposed to jump to the beginning of a word, but that seems to be getting ignored with the ww remap. W to jump forward a word still works.How about the :update / :up command? It's similar to the :write / :w command, but it doesn't actually write out the file if there were no changes made that need to be written out.
(Kind of like the difference between :x and :wq ; if there are no changes to save, :x just quits without writing out the file, whereas :wq writes out the file regardless of whether there are any changes.)
:wbut I'm pretty sure that's a duplicate.:w, it is:h, do:h wqyou can see many possibilities to save/quit/discard....vimtutorfirst. just type the command in your terminal.