vimLab -- Logging into a moon and Using the Vim Editor

------------------------------------------------
Part 1: Get a Linux shell window into a CS moon
------------------------------------------------

1. Reboot a lab machine to Linux, if it's not alread there.

2. Login with your usual CS userid/password
   If you don't know your CS userid, or forget password 
     -see sysadmin in ENG 244, 246, 248, or
     -email request@cs.torontomu.ca

3. You're now logged into that specific lab machine
     From there, get a shell window into a CS moon: 
       open a terminal: Ctrl-Alt-T
       inside terminal, type: ssh moon.cs.torontomu.ca  
       Then login with your CS userid/password (if necessary)
       If it asks you about a key, type: yes

---------------------------------------
Part 2: Learn how to use the Vim editor
---------------------------------------

0. Do NOT use VSCode to edit files. It is NOT ALLOWED for CPS393.
   If you care WHY, read the rest of this section; otherwise skip down to 1.
   Why? Because in CPS393 we learn to use Linux utilities. And VSCode has built-in functionality 
   that allows you to (kind of) bypass some Linux utilities.  This is convenient once you already 
   KNOW HOW to use the utilities, but it's not great now, when you're trying to LEARN them.
   When you get to a test, you may find you can't answer the questions because they ask you to 
   USE UTILITIES which you never properly learned (since you relied on VScode's functionality 
   instead). Some past students failed because of this issue--thus, VSCode is now prohibited. 
   But remember it for the future because it is a good free editor with extended functionality 
   similar to a full IDE.

1. From a moon shell window, go into your home directory by typing:
      cd

2. Copy the file vimTutorial.txt from the labs directory into your home
   directory by typing:
      cp /usr/courses/cps393/Labs/vimLab/vimTutorial.txt vimTutorial.txt

3. Verify the copy worked. Type:
      ls
   You should now see vimTutorial.txt listed. If you don't, try the above 
   commands again, paying special attention to SPACES, DOTS, and CAPITALs

4. Before you start the vim tutorial, note this: If you are trying a vim command (like
   saving a file), but you find that instead of DOING the command, vim is just displaying
   what you type into your file, that means you are stuck in insert-mode. You need to 
   get back to normal-mode; to do this, press the ESC key. It's OK to press ESC multiple 
   times. When in doubt, ESC!

   Start the vim tutorial by editing the file you just copied over:
   vim vimTutorial.txt

5. Exit vim. 
   Press ESC key so you're in Normal mode. 
   Type one of the following, depending on whether you want to
   save the file before exiting, or not
   :wq
   :q!

6. Logout. 
   Close your shell window by typing: exit
   (if you have more than one shell window open, close each one).
   Logout of your lab machine. 


---------------------------------------
Part 3: Submit
---------------------------------------
1. Use vim to create a file in your home directory named myInfo.txt 
   In this file include a line for each of the following, where "X" is your info.
   Note that you should use spaces, not tabs, to line things up.
   Note the last line contains your TMU (long) username (what you use to 
   access D2L). This often differs from your (short) CS username/userid.

   Last Name:  X
   First Name: X
   Student ID: X
   my.ryerson user name: X

2. Save your file and exit vim.

3. Verify that your file contains what you expect by displaying it:
   cat myInfo.txt
   If there are errors, use vim to correct them.

4. Submit myInfo.txt by its due date.
   This file has instructions for submitting: /usr/courses/cps393/dwoit/labs/SUBMITTING
   You can see its contents by:
   cd /usr/courses/cps393/dwoit/labs
   cat SUBMITTING


---------------------------------------
Getting Help with Vim
---------------------------------------

THERE IS MUCH ONLINE HELP FOR VIM, e.g.:
      A simple tutorial and sandbox: https://openvim.com/
      A reference card: http://tnerual.eriogerg.free.fr/vimqrc.html

SUMMARY OF VIM COMMANDS (on moons):
  /usr/courses/cps393/dwoit/courseNotes/vim-cheat-sheet.txt  
  /usr/courses/cps393/dwoit/courseNotes/vim-summary.txt

SUMMARY OF VIM COMMANDS (from course site):
  https://www.cs.torontomu.ca/~dwoit/courses/cps393/Labs/vim-files/vim-summary.txt
  https://www.cs.torontomu.ca/~dwoit/courses/cps393/Labs/vim-files/vim-cheat-sheet.txt
  https://www.cs.torontomu.ca/~dwoit/courses/cps393/Labs/vim-files/vim-colors.txt
  


-----------------------------------------------------
Ways to get a moon shell window (terminal) FROM HOME
-----------------------------------------------------

  Note that c. and d. below are presented more visually (with images!) 
  in file "Connect to Moon Remotely Handout.pdf", which is available (along with 
  other useful instructions and videos) at: https://bit.ly/2ZWNR7J 
  (access using your my.torontomu.ca userid/password, NOT your CS ones)

  c. Remotely from your own windows machine (Win10 or later): 
     Open either cmd (Command Prompt App) or PowerShell App from 
     windows-start-button
     Inside that window, type this (where "userid" is your CS userid):
       ssh userid@moon.cs.torontomu.ca
     You might have to type "yes" to verify authenticity
     Then login with your usual CS userid/password

  d. Remotely from your own windows machine by downloading and installing 
     PuTTY from  http://www.putty.org/ 
     Open PuTTY client, and connect as follows:
     In the "Host Name" box, type: moon.cs.torontomu.ca
     If necessary:
        In "Port" box, type: 22
        For "Connection Type" select: SSH
     Then click "open"
     Then login with your usual CS userid/password

  e. From your own Mac machine: 
     Open a terminal. 
     Type this (where "userid" is your CS userid): ssh userid@moon.cs.torontomu.ca
     You might have to type "yes" to verify authenticity
     Then login with your usual CS userid/password

  f. Remotely from a browser:
     Only possible if you request vdi access from a sysadmin first (request@cs.torontomu.ca)
     https://vdi.cs.torontomu.ca/
     First, you are asked to login to your my.torontomu account (not CS account!)
     Next, you are presented with a GUI desktop similar to lab rooms

  For cps393, c-f above are the only acceptable means of accessing moons from home.


--------------------------------
Run X-applications remotely
--------------------------------
    
  Lab machines booted to linux default to the GNOME desktop GUI.  You can use gui-based 
  apps (X-apps), such as gvim (gui-based vim), gedit (gnome editor), etc.  X-apps will 
  be available when doing your cps393 tests, but they're not required (you can use vim 
  instead of gvim, etc.)

  TO USE MOON X-APPS FROM YOUR LINUX HOME MACHINE: 
    Use ssh with XForwarding, like: 
    ssh -X userid@cs.torontomu.ca
    Or run specific remote X-apps, such as gvim, like: 
    ssh -X userid@cs.torontomu.ca gvim 

  TO USE MOON X-APPS FROM YOUR WINDOWS HOME MACHINE: 
    You can use putty, but you must first have an X-server running to display the 
    remote X11 app (X-app). You can use Xming which can be downloaded from 
    https://sourceforge.net/projects/xming/  
    BEFORE starting putty, start Xming from the Windows Start menu. It just runs 
    silently (but you'll see it in the taskbar).
    Then, start putty WITH X11 FORWARDING:
      Expand SSH in the putty side-menu, and select X11. Then check "Enable X11 forwarding". 
      Then go back to the Session side-menu and type in moon.cs.torontomu.ca as Host Name 
      and Open.
    Now you can run X-apps like gvim &, gedit & (but note X-apps can take quite awhile to 
    start--so wait for them!) The '&' is optional, but if you don't include it, your shell 
    window can't be used for anything else until you exit the X-app. 
    Note that Xming is no longer free, but you can still download the older, free version.

  A GOOD GUIDE (WITH IMAGES!) TO X11 FROM HOME USNG Xming is at: 
  https://cat.pdx.edu/platforms/windows/remote-access/xming/
  But note your Host Name will differ (moon.cs.torontomu.ca), and you need to ignore
  the end part (Matlab and VNC).
  
  For future reference: there are other free apps to display X11 on your home machines, 
  such as mobaXterm, VcXsrv, Cygwin/X BUT THESE ARE NOT ALLOWED FOR CPS393. If you care
  why, read on:
  Why? Some students who used other means in the past ended up failing because of it, mainly 
  because on the cps393 tests they discovered they really HADN'T learned the Linux utilities 
  properly because they had been relying some functionality provided by these other applications.