I'm using spacemacs and while when I create a new buffer with a given name and try to save it into a real file I find that
:w won't work but
:sav will. What is the difference between those two commands ?
:sav are Evil ex-commands, provided by Evil. The "bindings" of ex-commands are stored in the variable
evil-ex-commands, which is an alist. To examine the variable, run the command
C-h v evil-ex-commands (in Spacemacs you can use
SPC h d v evil-ex-commands instead). The output would be something like this:
evil-ex-commands is a variable defined in ‘evil-vars.el’. Its value is shown below. This variable may be risky if used as a file-local variable. Documentation: Association list of command bindings and functions. Value: (("edit" . evil-edit) ("e" . "edit") ("write" . evil-write) ("w" . "write") ("wall" . evil-write-all) ("wa" . "wall") ("saveas" . evil-save) ("sav" . "saveas") ("read" . evil-read) ("r" . "read") --- I trimmed the rest (the list continues) ---
:<key>, Evil looks for
evil-ex-commands and invokes the corresponding command. As you can see, ":w" is a shortcut for ":write", and ":write" invokes the function
evil-write. Similarly, ":sav" is a shortcut for ":saveas", which invokes
To find the differences between
evil-save, you can read their documentation by calling
C-h f or
SPC h d f (as db48x wrote). It seems that ":w" saves to current file, while ":sav" lets you save to a new file.
I don't use spacemacs, but emacs in general is self-documenting; you can always query the help system for information about keybindings, functions, variables, etc. The normal emacs keyboard shortcut for getting help with a key binding is
C-h k. From a quick glance at the spacemacs manual (http://spacemacs.org/doc/DOCUMENTATION.html#orgheadline91), it looks like you should use
SPC h d k, or possibly
SPC h d f (I'm not sure if the ex-commands like :w are classified as keyboard shortcuts or functions; probably the former but it might be the latter.)
You should be able to figure out the differnce by comparing the documentation for the two.