Many articles in this knowledge base advise editing configuration files. We usually recommend using your preferred text editor. At Liquid Web, we prefer vim. Vim, or its older sibling vi, are installed by default on nearly every server that we come across. If you do not yet have a preferred text editor, read on to see if vim might work for you.
Normal Mode
The biggest concept that beginning vim users need to know is the concept of modes. Different editor functions, such as moving the cursor around and inserting text, are accomplished in different modes. Open up a file in vim:vim example.conf
You are immediately put into normal mode. Normal modes does not seem normal at first. If you press “j” in normal mode, the letter “j” does not appear. Instead, the letter “j” moves the cursor down one line. Positioning the cursor in this mode is completely done with letter keys. The most basic are:
- j – one line down
- k – one line up
- h – one character left
- l – one character right
Insert Mode
To leave normal mode and start typing text, press “i” to enter insert mode. Insert mode behaves much more like the default mode in other text editors. There should not be any surprises.When you are done with insert mode, hit the ESC key to get back to normal mode.
Command-line Mode
Command-line mode is used to perform a wide range of commands. To enter vim’s command line, hit “:” (the colon) in normal mode. This will drop the cursor to the bottom of the terminal. Here you can do things like:- Save your changes (write):
:w
- Quit out of vim:
:q
- Quit without saving changes:
:q!
:wq
After you have run a command, vim will place you back in normal mode.
0 comments:
Post a Comment
Note: only a member of this blog may post a comment.