63

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?

4
  • 1
    I would dare to say that if the course isn't to learn vi/vim he shouldn't care over what platform I develop.
    – Braiam
    Feb 13, 2014 at 19:16
  • How does the professor know that you aren't using an IDE? Do you have live lessons where you are required to code? Is the exam done on a computer?
    – Bakuriu
    Feb 13, 2014 at 21:17
  • vi should be on most systems already, it's a standard part of Unix. One of the advantages of knowing vi is that it's pretty much guaranteed to be on any Unix-like system, even things like Busybox.
    – david25272
    Feb 14, 2014 at 3:51
  • 1
    possible duplicate of How to edit a file in vi editor (arrow keys prints letters)? Sep 16, 2014 at 15:39

6 Answers 6

86

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
0
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.

1
  • 4
    He is asking "How to install". You are saying "After installing". Logic for some reason.
    – atilkan
    Sep 11, 2015 at 20:12
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

3
  • 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, 2016 at 13:53
  • I'm going to push back on "most professional systems."
    – Amanda
    Apr 6, 2016 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 7, 2016 at 1: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

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 
1
  • 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. Mar 30, 2014 at 21:39
1

I install vim without sudo, in docker container,

apt-get update
apt-get install vim

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .