Interesting fact. I've been using Linux and Unix professionally since 1999 and personally a bit longer than that. I've always used Vim. I've edited thousands of configurations, written hundreds of Python scripts and even written full blown daemons in Python using Vim. In all that experiencing using Vim and that huge amount of commands and features it offers. I still know only a few of Vim's commands. Mostly just enough to get what I need done.
Proceed all commands below with hitting the ESC key.
- i ~ Insert
- x ~ Delete charcter
- dd ~ Delete line
- #yy -> p ~ Copy and paste # number of lines
- :/<search term> ~ Search
- :s/<find pattern>/<replace pattern>/[mode] ~ Find and replace (using sed command structure)
- :# ~ Goto line number specified by #
- shift+g (or just 'G') ~ Move to the end of the file
- "gg' ~ Move to the beginning of the file
- :w ~ Save
- Shift+zz (or 'ZZ') ~ Save and quit (also :wq, but I mainly use shift+zz)
Given how many commands and things you can do in Vim. It's amazing that I pretty much have only used these commands for the most part. There are times when I had to search down a command for a specific use, but for the most part. This is it.
Oh I also use this command, but it's specific to starting vim:
vim <filename> +# ~ Opens the file and goes to the specified line number.
This command is great when writing Python and you get a stack trace with a line number and you want to jump directly to it.
One last thing I will say is, while there are many different command line editors out there. If you want to become a Linux / Unix admin. Learning the basics of Vi is very important. There are many Linux and Unit systems out there. They can have very basic installs with no extra software. The one editor they always have is Vi. (sometimes not even Vim, just Vi) For that reason alone. Learning Vi is VERY important. Otherwise, you may be unable to edit something on a system you must work on!
Viva la Vi!