This is a meta-post. It is filled with vim commands to help you use the editor while playing with the code in the other posts and in the life.
- Saving in files:
– :w – Saves the current file.
– :w! – Overwrites the current file.
– :w or :w! <file_Path> – Saves/Overwrites to/the <file_path>.
– :wq – A classic – save and exit.
– :h writing – Many other options for these commands, like :wa (write to all buffers) for example.
- Executing shell commands:
– :!<command> – Executes the shell <command> (for example :!ruby %, which executes ruby on the current buffer).
–:!! – Repeats the last executed command.
– :sh – Starts the shell, you can type commands, compile files, etc, after typing exit you will return to Vim.
– :h shell – Detailed help the above commands.
- Enter in the Insert Mode (for typing text).
– :i – Enter Insert Mode, insert before the cursor.
– :I – Enter Insert Mode, insert in the beginning of the current line.
– :gi – Enter Insert Mode, from the position the last Insert Mode was exited.
– :o/:O – Insert new line bellow/above the line of the cursor and enter Insert Mode in the beginning of it.
– :a – Enter Insert Mode, insert after the cursor.
– :A – Enter Insert Mode, insert at the end of the current line.
– :h insert – Help for the above commands.
– :i comes from insert, :a comes from append.
- Saving files:
– ZZ – Save the current file and exit.
- Basic navigation
– h == left
– l == right
– j == down
– k == up
– G == End of the buffer/file
– gg == Beginning of the buffer/file
– 0 == The beginning of the current line.
– $ == The end of the current line