EE485B Vscode
EE485B Vscode
EE485B 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
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
5
Make your first file with vscode
1. Launch vscode
6
Make your first file with vscode
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
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…’
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
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
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
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