IDE and Terminal
- Terminal
- CLI Tools
- Visual Studio Code
- Undo and Redo
- Create nested folders
- Collapse all folders
- Hidden Files
- Search inside a file
- Run/Search for a command
- Duplicate a line
- Move a line
- Fold sections of a file
- Multicursor Editing adding same text to multiple lines
- Replace all Occurence
- Linked Editing for HTML Tags
- Shortcut for Keyboard Shortcuts
- Change keyboard shortcuts
- HTML Trick - Emmet
- Other Stuff
Terminal
Useful Aliases
alias ld='ll -d */'
alias lf='ll -p | grep -v /'
alias cl='clear'
alias histgrep='history | grep'
alias addalias='vi ~/.bashrc'
alias sr='source ~/.bashrc'
alias myip='export TF_VAR_my_ip="$(curl ifconfig.me)/32"'
alias awscreds='sudo vi ~/.aws/credentials'
alias gitacp='git add -A; git commit; git push'
alias gitac='git add -A; git commit'
alias gitst='git status'
CLI Tools
CLI Completion
Enable completion for some of the available CLIs.
# Enable autocompletion for the Kubernetes cluster manager utility kubectl:
source <(kubectl completion bash)
# Enable autocompletion for Helm
source <(helm completion bash)
VIM Shortcuts
Go to top of the file (first line of the file).
gg
Go to bottom of the file (last line of the file).
Shift + g
Copy an entire line.
yy
Paste after a line.
p
Insert an empty line below a line.
o
Set line numbers.
:set number
Go to a line (like line 10).
:10
Powershell and CMD
Checking the IP configurations:
ipconfig
Checking all entries in the ARP cache. ARP maps IP addresses to their respective MAC addresses. Just simply means it checks the connected devices.
arp -a
Find applications or services listening on a certain port, e.g. 3389. Add a “-p” flag to specify protocol, e.g. tcp.
netstat -p tcp -n | find '443' # Command Prompt
netstat -p tcp -n | findstr '443' # Powershell
To display all the routing table entries:
route print
To show the “hops” or router that a connection will go through to reach a specified target. Add “-d” flag to show just the IP address of each hop.
tracert -d youtube.com
Combination of ping and tracert:
pathping youtube.com
To resolve a DNS name. Basically you can provide a DNS name and it will resolve the IP address. Below is a forward DNS lookup.
nslookup youtube.com
“Non-authoritative” means that the local DNS Server cannot resolve the DNS name but its able to find a DNS Server that could resolve it.
Reverse lookup is when you have the IP address and you want to find the DNS name. To do this, set the type to PTR.
nslookup
set type=PTR
8.8.8.8
To view or modify the file system permissions in Windows. Use “icacls”, followed by the directory path. The “.” means current directory.
To refresh DHCP lease:
ipconfig /release
ipconfig /renew
To empty DNS cache:
ipconfig /flushdns
Visual Studio Code
Undo and Redo
Visual studio code follows the same:
# Undo
Ctrl + z
# Redo
Ctrl + Shift + z
Create nested folders
Click the folder icon to add a folder.
To add nested folder, type the subsequent folders after “/”.
Collapse all folders
Hidden Files
Some hidden files normally start with “.” and are excluded from view. You can more excluded files by:
- Click gear icon at the bottom left ⚙
- Select Settings
- Search for “exclude”
-
To add more file format, click Add pattern
Search inside a file
To search for a particular section of a file or a code, we can use the shortcut below. This saves time from scrolling over the whole file. This works with code too.
Ctrl + Shift + P --> @
Run/Search for a command
To run a command, we can also use the same, then type the command.
Ctrl + Shift + P --> >
Duplicate a line
To duplicate a line multiple times, click and hold the keys:
Alt + Shift + Down arrow
Move a line
Similar to cutting a line and pasting it somewhere else in the file, we can also use the shortcut below.
Alt + Up/Down arrow
Fold sections of a file
We can hide sections of a file by “folding” them.
Ctrl + Shift + p
>fold all
Multicursor Editing (adding same text to multiple lines)
To type the same text on multiple places simulatenously:
Alt (hold)
Use the mouse to click the places to edit
Note that in some cases, it could be:
Ctrl (hold)
Use the mouse to click the places to edit
Replace all Occurence
To replace all occurence of a text in a file (for example, the word), select the particular word and:
Shift + o
All occurence of the word will be highlighted and will be edited at the same time.
The number of occurence will also appear at the bottom right.
Linked Editing (for HTML Tags)
To edit the open and closing tag at the same time, we can enable linked editing.
Ctrl + Shift + p
>linked editing
Shortcut for Keyboard Shortcuts
Open the keyboard shortcuts page for the first time by
Ctrl + Shift + P
> keyboard shortcuts
Then select “Preferences: Open Keyboard Shortcuts”
Type “Open keyboard shortcuts”. For the keybinding, click “CTRL (hold), K, S, enter”
The next time you want to see the keyboard shortcuts, just type:
Ctrl (hold) + k + s"
Change keyboard shortcuts
Make sure to follow the step before this to set the shortcut for the keyboard shortcuts page first. To change or set a keyboard shortcut:
Ctrl (hold) + k + s"
HTML Trick - Emmet
This syntax assistance is particularly useful for HTML for writing boilerplate code.
To generate a layout, define the keywords/letters followed by “+” sign. Example:
article>header+h1+p
press tab
which will generate:
<article></article>
<header></header>
<h1></h1>
To create a numbered list with 10 items:
ul>li*5
press tab
which will generate:
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
Other Stuff
-
Terminal - VS Code has a built-in terminal. Cons is that some Linux command doesn’t work inside the terminal (e.g reverse search)
-
Peek definitions/implementations
-
Integration with Git
-
Remote repositories
-
Remote SSH
-
Remote containers
-
.devcontainer
-
Debugger
-
Debugger: Breakpoint and Logpoint
-
HTTP Client like Thunder Client (for API testing)
-
Docker extension
-
VS Code tasks (for repetitive shell commands)
-
Snippets