73

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
  • 69,112

6 Answers6

100

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
  • 61,330
39

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.

11

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,723
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
  • 73,717
Noosrep
  • 2,184
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
1

I install vim without sudo, in docker container,

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