While it's fully possible to execute your programs locally (directly on your computer) given that you've installed the proper tools, your grade will always be based on what your programs do when executed on the engineering servers. In certain cases, the same program can behave differently depending on its execution environment (e.g., the computer that it's being executed on). Hence, it's critical that you always execute your programs on the engineering servers so that there are no surprises during grading.
This means that you need some way of getting your code onto the engineering servers where you can execute it. You have a few options:
We're going with the terminal-based text editor option. The engineering servers have several terminal-based text editors already installed and available for use. We're going to use Vim. Vim stands for "Vi improved". Vi, in turn, is a much older terminal-based text editor that was created by Bill Joy at UC Berkeley in the 1970's as a part of his work on BSD UNIX. (Vi is also available on the engineering servers, but we'll be using Vim instead).
Vim has its quirks, but it's also very powerful if you know how to use it. You will often find yourself editing files on a remote system and Vim almost always available, so it is very useful to have at least a basic familiarity with it. And for the advanced features that IDEs support out-of-the-box (e.g., frontend linters to detect and highlight syntax errors), there are Vim plugins for that (e.g., this one).
All that being said, this is not a Vim course, so we'll only be using Vim in a relatively basic capacity. Open your terminal and connect to the engineering servers over SSH. Use cd to navigate to the directory where you want to write code while following along with the lectures (I recommend using mkdir to create a directory named lecture-notes inside your cs162 directory, and then navigate into it). Then, execute the following command:
vim hello.pyThis command starts Vim, telling it to open the file called hello.py in your working directory (if the file doesn't exist, it will be created automatically). The moment you execute the command, your entire terminal will be taken over by the Vim user interface. It will look vaguely like this:

Vim is a text editor, which means it can (of course) be used to edit the file that you just created and opened (hello.py). However, at this stage, if you naively try to write some text, it won't work as you'd expect. This is because Vim has multiple modes of operation. When first opened, it will be in Normal Mode by default. In order to insert text, you must first switch to Insert Mode. You can do this by pressing the "i" key on the keyboard. After doing so, you should see -- Insert -- appear at the bottom-left of the terminal:

At this point, you may now start writing text into the file. I didn't tell you this, but we named the file hello.py because .py is the standard Python source code file extension, and we're going to write a brief "Hello, World!" Python program. Copy and paste the following code directly into Vim (you should be able to paste from your system clipboard into Vim via Ctrl+Shift+V in PowerShell, assuming you've enabled it in your PowerShell settings, or via Cmd+V in a Mac Terminal):
def main():
print("Hello, World!")
if __name__ == '__main__':
main()
We've written our code, and it's time to run it. First, we have to save the file and quit Vim. Recall that Vim is a terminal-based text editor, and recall that terminals are primarily text-based. This means that there are no menu buttons to click on to save or exit Vim (if you click the X button in the menu bar at the top of your terminal, that will exit out of your entire terminal—not just Vim). Indeed, actions such as saving and quitting require executing text-based commands. As it turns out, executing text-based commands is the entire purpose of Normal Mode (it's sometimes even referred to as Command Mode). To switch back to Normal Mode, press the escape key on your keyboard. The -- Insert -- text should disappear from the bottom-left of your terminal again.
While in Normal Mode, there are at least two kinds of commands that you can execute: a) simple hotkey commands, where you press a single key and it performs some corresponding action, and b) complete commands, which are prefixed with a colon (:). Currently, our goal is just to save and quit. There are no hotkey commands for this, so we have to execute a complete command. First, type a colon. It should appear at the bottom-left of your terminal:

After the colon, you can type any one of various Vim commands and press enter to execute it. The basic commands that you'll use most frequently are as follows:
There are countless other commands, some of which allow you to do much more advanced things (e.g., find and replace, enable line numbers, create macros, remap keys so that they do more complex things, etc). We'll discuss some of them shortly.
Let's save the file and quit Vim. Type wq after the colon and press enter. You should now find yourself back in your shell once again. If you execute ls, you should now see hello.py in your working directory:
(base) guyera@flip4:lecture-notes$ ls
hello.py
(This lecture isn't about Python, but if you're curious, you can execute the Python program that we just wrote by typing python hello.py into the terminal and pressing enter; refer to my "Hello, World!" Python lecture notes for more information).
If you wish to edit the file some more, simply execute the same command as earlier: vim hello.py. Since hello.py already exists, this will simply open the file in Vim for editing rather than creating it.
That's it for the basics. Now onto some slightly more advanced Vim tricks (Vim is very powerful, but it would take several weeks if not an entire term to cover all of its capabilities, so I'll just tell you enough to bring your Vim skills up a notch and make your life a bit easier).
(If you've already configured a .vimrc file to your liking, you can skip these first few steps). First, use Vim to create and open a file named .vimrc within your home directory. It must have this exact name, and it must be in your home directory. An easy way to do this is by executing the following shell command from your terminal:
vim ~/.vimrcThe ~ is an alias for your home directory, similar to how .. is an alias for a given directory's parent, so this creates the .vimrc file in your home directory as needed. Recall that files starting with a . are hidden files, so you'll only be able to see it in your home directory later on via ls -a.
Now, copy and paste the following contents into the file within Vim (recall that you can paste while in Insert Mode via Ctrl+Shift+V, assuming your terminal configuration has been setup properly):
set nu
set mouse=a
filetype plugin indent on
set autoindent
colorscheme desert
set colorcolumn=81
syntax on
set expandtab
set tabstop=4
set softtabstop=4
set shiftwidth=4
Now save and quit Vim (press escape to enter Normal Mode, then type :wq and press enter).
Let me explain what we just did. A .vimrc file specifies a list of Vim commands that Vim should execute automatically every time it starts up. Each one of the above Vim commands enables a certain feature in Vim. By putting them in your .vimrc file, they'll be re-enabled every time you start Vim (these features do not persist, hence it's necessary to put them in your .vimrc file if you want them to always be enabled).
The above commands enable the following respective features:
These settings alone will surely make Vim easier to use, but you'll be even more proficient if you can master some of the (slightly) more advanced commands and hotkeys detailed below. (Keep in mind that many hotkeys and commands are case-sensitive. For example, pressing the U key while in Normal Mode with caps lock off will do something different from pressing the U key with caps lock on).
Here's a complete example:
:%s/hello/goodbye/gc
This would step through each of the occurrences of the word "hello" in the file and ask you if you'd like to replace it with the word "goodbye". To replace an occurrence, press the y key (for "yes"). To skip an occurrence (leaving it as-is), press the n key (for "no"). To stop the find-and-replace command at any point, press the q key (for "quit").
There are a few more options here as well. The "c" at the end of the find-and-replace command stands for "confirm". If you omit it, Vim will instantly replace all occurrences as if you pressed the y key for each one of them.
The % symbol at the beginning means "search the entire file". If you want, you can instead write .,$ (that's a period, then a comma, then a dollar sign) in place of the % symbol. This means "search the entire file starting from the line that my cursor is on". This is especially helpful for, say, renaming a local variable within a single function.
Again, there are countless more Vim commands and hotkeys that we don't have time to cover. If you want to improve your Vim skills beyond what's covered in this lecture, I recommend studying Vim mappings, macros, abbreviations, and, if you really want to get your hands dirty, plugins and plugin development.