Saturday, July 23, 2016

Vim editor (Linux) tips and tricks!

Vim editor (Linux) tips and tricks!

As you know, some beginner users have many questions about Vim editor. Most popular is "How to close vim editor in linux without saving". So, this document can be like Bible for beginner users

Answer for main question is:

"To quit the vi editor without saving any changes you've made: If you are currently in insert or append mode, press Esc. Press : (colon). The cursor should reappear at the lower left corner of the screen beside a colon prompt. Enter the following: q!" (c) Google

Best solution for Vim editor is - do not use Vim editor!

But sometime you can find Vim as a default editor for something, for example (this is my experience) when you type:

$ sudo crontab -e

you can become a beginner user for Vim editor. In this case use instructions which above. Just press Esc, and then type ":q!" (without quotes).

After this you can setup other default editor (Oh-yea!), just type:

$ sudo select-editor

Then you will see something like this:

Select an editor.  To change later, run 'select-editor'.
  1. /bin/nano        <---- easiest
  2. /usr/bin/vim.basic
  3. /usr/bin/vim.tiny

Choose 1-3 [1]:

Then read instructions and chose best. My choice is 1 - "/bin/nano". If you don't have nano, you can install it with this command:

$ sudo apt-get install nano

I think that best editors is nano or pico. Nano is much easier to use then Vim.


No comments:

Post a Comment