Giao diện
Quick Reference Cheatsheets 📋
Tất cả shortcuts và commands quan trọng nhất ở một nơi.
VS Code Shortcuts
Navigation
| Shortcut | Action | Use Case |
|---|---|---|
Ctrl + P | Quick Open | Open files instantly |
Ctrl + Shift + P | Command Palette | Access all commands |
F12 | Go to Definition | Jump to source |
Alt + Left/Right | Navigate Back/Forward | Return to previous location |
Ctrl + G | Go to Line | Jump to specific line |
Ctrl + Shift + O | Go to Symbol | Navigate within file |
Editing
| Shortcut | Action | Use Case |
|---|---|---|
Ctrl + D | Select Next Occurrence | Multi-cursor editing |
Alt + Click | Add Cursor | Manual multi-cursor |
Ctrl + Shift + L | Select All Occurrences | Rename all instances |
Alt + Up/Down | Move Line | Reorder code |
Shift + Alt + Down | Duplicate Line | Copy similar code |
Ctrl + / | Toggle Comment | Comment/uncomment |
Ctrl + Shift + K | Delete Line | Remove line quickly |
View Management
| Shortcut | Action | Use Case |
|---|---|---|
Ctrl + B | Toggle Sidebar | More screen space |
Ctrl + \ | Split Editor | View 2 files |
Ctrl + 1/2/3 | Focus Editor Group | Switch between splits |
Ctrl + W | Close Editor | Close current file |
Ctrl + K, Z | Zen Mode | Distraction-free coding |
Ctrl + ` | Toggle Terminal | Quick terminal access |
Search & Replace
| Shortcut | Action | Use Case |
|---|---|---|
Ctrl + F | Find | Search in file |
Ctrl + H | Replace | Find and replace |
Ctrl + Shift + F | Find in Files | Search entire project |
Ctrl + Shift + H | Replace in Files | Replace across project |
F3 / Shift + F3 | Find Next/Previous | Navigate search results |
Code Folding
| Shortcut | Action | Use Case |
|---|---|---|
Ctrl + Shift + [ | Fold Region | Collapse code block |
Ctrl + Shift + ] | Unfold Region | Expand code block |
Ctrl + K, Ctrl + 0 | Fold All | Collapse everything |
Ctrl + K, Ctrl + J | Unfold All | Expand everything |
Git Commands
Basic Workflow
bash
# Check status
git status
# Stage changes
git add . # Stage all
git add file.txt # Stage specific file
# Commit
git commit -m "message" # Commit with message
git commit --amend # Amend last commit
# Push/Pull
git push # Push to remote
git pull # Pull from remote
git fetch # Fetch without mergeBranching
bash
# Create branch
git branch feature-name # Create branch
git checkout -b feature-name # Create and switch
# Switch branch
git checkout main # Switch to main
git switch feature-name # Modern syntax
# Merge
git merge feature-name # Merge into current branch
# Delete branch
git branch -d feature-name # Delete local branch
git push origin --delete feature-name # Delete remoteHistory & Inspection
bash
# View history
git log # Full history
git log --oneline # Compact view
git log --graph --all # Visual graph
# View changes
git diff # Unstaged changes
git diff --staged # Staged changes
git diff branch1..branch2 # Compare branches
# Show commit
git show <commit-hash> # Show commit detailsUndo Changes
bash
# Discard changes
git checkout -- file.txt # Discard file changes
git restore file.txt # Modern syntax
# Unstage
git reset HEAD file.txt # Unstage file
git restore --staged file.txt # Modern syntax
# Undo commit
git reset --soft HEAD~1 # Keep changes staged
git reset --hard HEAD~1 # Discard changes (dangerous!)
git revert <commit-hash> # Create new commit that undoesStash
bash
# Save work temporarily
git stash # Stash changes
git stash save "message" # Stash with message
git stash list # List stashes
git stash pop # Apply and remove stash
git stash apply # Apply without removing
git stash drop # Delete stashTerminal Commands
Navigation
bash
# Change directory
cd /path/to/dir # Absolute path
cd .. # Parent directory
cd ~ # Home directory
cd - # Previous directory
# List files
ls # List files
ls -la # List all with details
ls -lh # Human-readable sizes
# Current directory
pwd # Print working directoryFile Operations
bash
# Create
touch file.txt # Create empty file
mkdir dirname # Create directory
mkdir -p path/to/dir # Create nested directories
# Copy/Move/Delete
cp source dest # Copy file
cp -r source dest # Copy directory
mv source dest # Move/rename
rm file.txt # Delete file
rm -rf dirname # Delete directory (careful!)
# View files
cat file.txt # Print entire file
less file.txt # View with pagination
head -n 10 file.txt # First 10 lines
tail -n 10 file.txt # Last 10 lines
tail -f file.txt # Follow file (live updates)Search
bash
# Find files
find . -name "*.js" # Find by name
find . -type f -mtime -7 # Modified in last 7 days
fd "\.js$" # Modern alternative (faster)
# Search content
grep "pattern" file.txt # Search in file
grep -r "pattern" . # Recursive search
grep -i "pattern" file.txt # Case insensitive
rg "pattern" # Modern alternative (faster)Process Management
bash
# View processes
ps aux # All processes
ps aux | grep node # Find specific process
top # Interactive process viewer
htop # Better top (if installed)
# Kill process
kill <PID> # Graceful kill
kill -9 <PID> # Force kill
pkill node # Kill by nameNetwork
bash
# Check connectivity
ping google.com # Test connection
curl https://api.example.com # Make HTTP request
wget https://example.com/file.zip # Download file
# Port usage
netstat -tuln # List listening ports
lsof -i :3000 # What's using port 3000Permissions
bash
# Change permissions
chmod +x script.sh # Make executable
chmod 644 file.txt # rw-r--r--
chmod 755 script.sh # rwxr-xr-x
# Change owner
chown user:group file.txt # Change owner and group
chown -R user:group dir/ # RecursiveNode.js / npm Commands
Package Management
bash
# Initialize project
npm init # Interactive setup
npm init -y # Skip questions
# Install packages
npm install # Install from package.json
npm install package-name # Install package
npm install -D package-name # Install as dev dependency
npm install -g package-name # Install globally
# Update packages
npm update # Update all packages
npm update package-name # Update specific package
npm outdated # Check for updates
# Remove packages
npm uninstall package-name # Remove package
npm prune # Remove unused packagesScripts
bash
# Run scripts
npm start # Run start script
npm test # Run tests
npm run build # Run build script
npm run dev # Run dev script (custom)
# List scripts
npm run # List all available scriptsTroubleshooting
bash
# Clear cache
npm cache clean --force # Clear npm cache
# Reinstall
rm -rf node_modules package-lock.json
npm install # Fresh install
# Check versions
node -v # Node version
npm -v # npm versionDocker Commands
Container Management
bash
# Run container
docker run image-name # Run container
docker run -d image-name # Run in background
docker run -p 8080:80 image # Port mapping
docker run -v /host:/container image # Volume mount
# List containers
docker ps # Running containers
docker ps -a # All containers
# Stop/Start
docker stop container-id # Stop container
docker start container-id # Start container
docker restart container-id # Restart container
# Remove
docker rm container-id # Remove container
docker rm -f container-id # Force removeImage Management
bash
# List images
docker images # List all images
# Build image
docker build -t name:tag . # Build from Dockerfile
# Pull/Push
docker pull image-name # Download image
docker push image-name # Upload image
# Remove
docker rmi image-id # Remove image
docker image prune # Remove unused imagesCleanup
bash
# Remove all stopped containers
docker container prune
# Remove all unused images
docker image prune -a
# Remove all unused volumes
docker volume prune
# Remove everything
docker system prune -aKeyboard Shortcuts by Platform
Windows/Linux
| Action | Shortcut |
|---|---|
| Copy | Ctrl + C |
| Paste | Ctrl + V |
| Cut | Ctrl + X |
| Undo | Ctrl + Z |
| Redo | Ctrl + Y |
| Select All | Ctrl + A |
| Save | Ctrl + S |
| Find | Ctrl + F |
macOS
| Action | Shortcut |
|---|---|
| Copy | Cmd + C |
| Paste | Cmd + V |
| Cut | Cmd + X |
| Undo | Cmd + Z |
| Redo | Cmd + Shift + Z |
| Select All | Cmd + A |
| Save | Cmd + S |
| Find | Cmd + F |
Regular Expressions Quick Reference
Basic Patterns
| Pattern | Matches | Example |
|---|---|---|
. | Any character | a.c matches "abc", "a1c" |
\d | Digit (0-9) | \d{3} matches "123" |
\w | Word character | \w+ matches "hello" |
\s | Whitespace | \s+ matches spaces |
^ | Start of string | ^Hello matches "Hello world" |
$ | End of string | world$ matches "Hello world" |
Quantifiers
| Pattern | Meaning | Example |
|---|---|---|
* | 0 or more | a* matches "", "a", "aa" |
+ | 1 or more | a+ matches "a", "aa" |
? | 0 or 1 | a? matches "", "a" |
{n} | Exactly n | a{3} matches "aaa" |
{n,} | n or more | a{2,} matches "aa", "aaa" |
{n,m} | Between n and m | a{2,4} matches "aa", "aaa", "aaaa" |
Common Patterns
regex
# Email
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
# URL
^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b
# Phone (US)
^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$
# Date (YYYY-MM-DD)
^\d{4}-\d{2}-\d{2}$
# Hex Color
^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$HTTP Status Codes
Success (2xx)
| Code | Meaning |
|---|---|
| 200 | OK - Request succeeded |
| 201 | Created - Resource created |
| 204 | No Content - Success, no response body |
Redirection (3xx)
| Code | Meaning |
|---|---|
| 301 | Moved Permanently |
| 302 | Found (Temporary Redirect) |
| 304 | Not Modified (Cached) |
Client Errors (4xx)
| Code | Meaning |
|---|---|
| 400 | Bad Request - Invalid syntax |
| 401 | Unauthorized - Authentication required |
| 403 | Forbidden - No permission |
| 404 | Not Found - Resource doesn't exist |
| 422 | Unprocessable Entity - Validation failed |
| 429 | Too Many Requests - Rate limited |
Server Errors (5xx)
| Code | Meaning |
|---|---|
| 500 | Internal Server Error |
| 502 | Bad Gateway - Invalid response from upstream |
| 503 | Service Unavailable - Server overloaded |
| 504 | Gateway Timeout - Upstream timeout |