64

I really hope someone on this subject can help me.

I recently enrolled for a programming course and one subject requires me to program in c/c++ on Linux os. I've had previous c++ experience on the .net framework building console apps and winforms.

The problem is this course wants us not to use any IDE of any sort, the only thing we allowed to use is the terminal and something called 'vi commands'. How can get started with?

Braiam
  • 67,791
  • 32
  • 179
  • 269
user3306195
  • 657
  • 1
  • 5
  • 3

6 Answers6

87

I suggest you install vim. From the terminal Ctrl+Alt+t:

sudo apt-get update
sudo apt-get install vim

Several dependencies will also be installed. Then start a new project, again from the terminal:

vim new_project.c

Learn more about vim:

man vim
chili555
  • 60,188
37

After installing vim running

vimtutor

from the commandline you'll get "a 30 minute tutorial that teaches the most basic Vim functionality hands-on" as it calls itself.

10

vi is super frustrating if you don't know your way around it. You get a sea of little tildes and you're supposed to know what to do? Eesh.

I recommend at least installing gvim so you have a help menu, which you can use for reference. It isn't an IDE so you aren't cheating on your class. Do apt-get install gvim -- when you can't remember how the heck you're supposed to open a dang file or save one, you can look at the menu. The keyboard shortcuts are listed on the menus. Just make sure that you actually type out the keyboard commands, even if you have to check a menu to remember them.

The really basic things that you need to know to avoid going insane:

  • i puts you in edit mode so you can type
  • esc takes you out of the edit mode
  • :w saves your file
  • :q quits the editor
  • :q! quits an unsaved file

Other resources: this looks like a great getting started tutorial: http://www.openvim.com/tutorial.html as does the WikiBooks edition of Learning the vi editor

Amanda
  • 9,333
  • Having teachers like this in the past I would not put it past them to have a final exam or test where the students have to demonstrate proficiency in a practical test. Also, using an enhanced vi editor is a good idea but most professional systems only have the basic version installed. – Underverse Feb 13 '16 at 13:53
  • I'm going to push back on "most professional systems." – Amanda Apr 06 '16 at 18:06
  • Okay. "many professional systems" to cover many government departments with highly restrictive software policies, several banks, over 30 fortune 500 companies from the comments around the place about lack of software available for SSH editing. I no longer find the situation where what you would consider to be basic tools for the job are not available to be abnormal – Underverse Apr 07 '16 at 01:26
9

First: install vim. Otherwise you're in for a world of pain. Second: you should try looking for something called a 'cheat sheet'. They're useful documents which contain mostly commands and a small explanation. Some examples:

Not all those commands will be useful to you, but nothing stops you from creating your own cheat sheet

Jorge Castro
  • 71,754
Noosrep
  • 2,154
3

If you want to become a vim ninja in a fun way, try this: http://vim-adventures.com/. You learn all the basic vim functionality by playing a fun little game.

And as an extra: if you prefer moving around with the arrow keys instead of the letters and you want backspace to behave as in nano (at least I do), you can add the following in your ~/.vimrc file (if you do not have one, just create it):

set nocompatible "must be first line 
set backspace=indent,eol,start 
George
  • 417
  • 4
    Note that only the first three levels of VIM Adventures are free. To learn more than some basics (the keys hjkl, bew, x, and B) from the game, it costs $25. Though it might be helpful to learn those basics using the game and then continue to a different tutorial (like vimtutor) when the game shows the paywall. – Rory O'Kane Mar 30 '14 at 21:39
1

I install vim without sudo, in docker container,

apt-get update
apt-get install vim
Zgpeace
  • 111