Thursday, January 19, 2017

VIM - let's take a quick walk around...

VIM

The granddaddy of Unix text editors, vi, is infamous for its difficult, non-intuitive command structure. On the bright side, vi is powerful, lightweight, and fast. Learning vi is a Unix rite of passage, since it is universally available on Unix-like systems. On most Linux distributions, an enhanced version of the traditional vi editor called vim is used

Lets open our first file in VIM

in a Cygwin shell type

    vim myFirstVIM

This will open vim in edit mode, and it will start in "command" mode.  Click on the insert key.  This will put the VIM editor in insert mode.  If you click the insert  again, it will be put in replace mode... now click   again to go back to insert  mode.

You should be able to start typing...  Type

    echo "Hello World"

To be able to quit, you need to get VIM back into command mode... to do this click the ESC key

To write and quit  Type ZZ
To quit with our saving type :q

If the file has not been changed, the :q will quit... if the file has changed, when you use ;q  you will be warned and asked if you really want to quit with out saving...

To force a quit with out saving type :q!

Now you should be back to the Cygwin $ prompt.  If you type ls, you should see that the file has been written.  If you cat myFirstVIM, you should see what you typed.

To reopen the file, type vim myFirstVIM

This will again put you back to vim in command mode.  to get back to edit mode, click on the insert key.

Type some more.. then ESC and ZZ to exit

Now type vimtutor and spend about 20-30 min doing the tutorial

See https://www.linux.com/learn/vim-101-beginners-guide-vim for more quit start guide
here is another https://scotch.io/tutorials/getting-started-with-vim-an-interactive-guide
and https://www.youtube.com/watch?v=rfl9KQb_HVk 
and this good link https://www.youtube.com/watch?v=TwJbr2KIR0E



No comments:

Post a Comment