EE485B Vscode

Download as pdf or txt
Download as pdf or txt
You are on page 1of 29

EE485: Introduction to Environments & Tools

for Modern Software Development


Visual Studio Code

A lightweight but powerful source code editor

It runs on Windows, macOS, and Linux

A rich ecosystem of extensions for other languages


With built-in support for JavaScript, TypeScript, and Node.js

For brevity, we will call Visual Studio Code as vscode!

3
Why not emacs? not vim? but vscode?

Fact: emacs and vim are also wonderful source code editors
FYI: I am using vim for writing my code

Then, why vscode?


Easy to start

The most important reason why we introduce vscode for you!

Better GUI (Graphical User Interface) support

vim and emacs are originally designed for CUI(Character User Interface);
thus, although they support GUI, it is very limited unlike vscode

Better cross-platform

vim and emacs are mainly designed for *nix (Unix-like) platform

vscode focuses on cross-platform; that’s why they use JavaScript for their
extensions, which can be cross-platform

4
Installation

Go to https://code.visualstudio.com

Download Visual Studio Code for your platform

Then, install Visual Studio Code

5
Make your first file with vscode

1. Launch vscode

6
Make your first file with vscode

2. Click new File and write a sample program to the file

3. Click [File]  [Save] and store your file as “hello.c”

You can find “hello.c” in the directory that you selected!


7
Visual Studio Code Interface

Status Bar

8
Visual Studio Code Interface

Activity Bar

9
Visual Studio Code Interface

Explorer view

10
Visual Studio Code Interface

Search view

11
Visual Studio Code Interface

Source control view

12
Visual Studio Code Interface

Run view

13
Visual Studio Code Interface

Extensions view

14
Visual Studio Code Interface
[View]  [Command Palette]
e.g., Control+Shift+P in Windows

15
Keyboard shortcuts
https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf

16
Keyboard shortcuts
Command Palette also shows shortcuts for you

17
Install Extensions
Go to Extension view
Recommended: C/C++
e.g., IntelliSense

18
Install Extensions
Recommended: Remote – SSH
Allows to create files in remote servers
We will explain it later

19
Remote-SSH: Connect to Host
After installing the extension, choose ‘Remote-SSH: Connect to Host…’

Then, type your [ID]@eelab5.kaist.ac.kr to connect the server

Choose Linux for your remote server

20
Create a file in remote server
Create a file similar to the local environment

If you connect to a server with ssh, you will see that your file is created

21
Avoid repeated password typing with SSH key
One tedious task: Repeatedly typing your password
How to avoid? Use SSH key (Windows)
Assumption: your workstation is secure. If not, use ssh-agent w/ a non-empty passphrase
1. Launch PowerShell
2. Create SSH Key with ssh-keygen without a passphrase

22
Avoid repeated password typing with SSH key
3. Copy .ssh/id_rsa.pub to .ssh/authorized_keys in your remote server

4. Setup permissions
$ chmod 700 ~/.ssh
$ chmod 600 ~/.ssh/authorized_keys

4. Do ssh [ID]@eelab5.kaist.ac.kr to check whether your setup is working


If your setup is successful, you should get server without entering password

23
Compile, Run & Debug
Honestly speaking, there is a more powerful way to compile, run, and debug in
visual studio
If you are interested in, please check https://code.visualstudio.com/docs/cpp/config-linux

But, we recommend you to use separate terminals to compile, run & debug your
code.
Compile: gcc209 –o hello hello.c
Run: ./hello
Debug: gdb ./hello

Reason: We want you to get familiar with Linux

24
Example: Setup assignment 2 with vscode
1. Download and extract assignment2.tar.gz to your local machine
# eelabg1.kaist.ac.kr
$ wget https://ee209.kaist.ac.kr/assignments/assignment2/assignment2.tar.gz
$ tar –xvf assignment2.tar.gz
$ rm assignment2.tar.gz

2. Opens the directory with vscode

25
Homework (eelab5 -> eelabg1 in the log below)
Task: Setup SSH key and vscode, and connect to a remote server
Submit a pdf document containing
1. a screenshot for SSH log
On Windows, it starts with “Running script…” (but is platform dependent)
Your log should not contain “Showing password prompt”
2. What platform you are on: 1) whether you are on a VM 2) Your host OS 3) Guest OS
(if you are on VM)
Deadline: 10:25am on March 29 (next class)

Invalid!

Correct

26
Homework: MacOS (invalid)

Invalid!

27
Homework: MacOS (valid)

28
29

You might also like