LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to use Vim? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-use-vim-4175499977/)

AlexBB 03-30-2014 04:40 PM

How to use Vim?
 
Hi there. My environment is Ubuntu as a VM under VirtualBox. I just installed vim (text editor for programmers) and decided to write a simple fortran program. Well, the editor does not allow me to enter any text. When I type even a single character, a dull sound sounds and a red color message appears at the bottom of the editor:

Quote:

E353: Nothing in register "
What does it all mean?

Thanks, - Alex

Emerson 03-30-2014 05:09 PM

Did you put vi in insert mode by hitting "i"?

Myk267 03-30-2014 05:24 PM

Vim is quite a sharp tool, and as such, it's going to take real work to get to using it well if it's your first time. I happen to like this intro Learn Vim Progressively, but there are other Vim resources as well.

If you don't end up wanting to learn how to drive Vim, gedit for the GUI environment and/or nano for the command line. Both of those trade off ultimate text editing power for ease of use.

John VV 03-30-2014 05:26 PM

i would print out a VI "cheat sheet" and tape it next to the monitor
something like
http://linuxtutorial.todolistme.net/cheatsheetvi.php
or this graphical one
http://www.viemu.com/a_vi_vim_graphi..._tutorial.html
or this pdf
http://www.cse.scu.edu/~yfang/coen11/vi-CheatSheet.pdf

astrogeek 03-30-2014 05:28 PM

In another thread I once posted some instructins for quickly getting oriented with Vim - find it here, and look over the other helpful posts in that thread as well.

Here is a short paste from that post that might help you get going quickly...

Quote:

Next, get oriented quickly!

I think the most difficult thing for people who simply open vi or a clone is that they see the blank page and begin typing - and weird stuff happens! Then they can't get out of it and they leave in frustration thinking the learning curve is too steep!

So to get past that point as quickly as possible note the following:

1. Vi(m) has two modes - command mode and insert mode (also called normal mode and edit mode respectively).
2. When you first start vi it is always in command mode, so key presses are interpreted as commands, not text.
3. To enter insert mode from command mode simply press i, then begin typing your text.
4. To return to command mode at any time simply press the ESC key.

You will see helpful status messages in the lower left corner of the terminal window as you change modes.

To leave vi you must be in command mode (pres ESC if not sure) then try one of these:

ZZ (shift-zz) - writes (saves) the current edits and exits.
:wq - writes (saves) the current edits and quits (same as ZZ).
:q - quit, prompts you to save any unsaved edits first (:w will write the to file)
:q! - quits without saving edits.
Also - from a terminal simply type vimtutor to get the always present on demand Vim tutor!

AlexBB 03-30-2014 07:13 PM

Many thanks to everyone for posting. I actually used gedit and it worked. Much simpler but I will learn Vim. - Alex

chrism01 03-31-2014 04:19 AM

Native/short way to exit+save in vi/vim
Code:

:x


All times are GMT -5. The time now is 11:29 AM.