this is a cataloging of commands and shortcuts i have found useful along my coding journey
-
ctrl + f to search for the cli term you are looking for (annotated w/ keywords and descriptions)
-
search using the roman numeral indexed legend for system or technology lookup
Index | Technology | System |
---|---|---|
I | Visual Studio Code | IDE |
II | Visual Studio | IDE |
III | Bash | Terminal |
IV | Powershell | Terminal |
V | Command Prompt | Terminal |
VI | Oh My Zsh! | Terminal |
VII | Node | Framework |
VIII | .Net | Framework |
IX | CSS | Framework |
X | Ubuntu | Operating System |
XI | Windows | Operating System |
XII | SQL | DB |
XIII | Cron | Misc. |
XIV | Postman | Misc. |
XV | Tree | Misc. |
XVI | Git | Misc. |
command palette
ctrl + shift + p
enable psehll integrated terminal enhancements (preferences settings json)
"terminal.integrated.suggest.enabled": true
ScreenCast Mode (great for presentations)
ctrl + shift + p
// type "screencast"
// select Developer Toggle Screencast Mode
Clear command suggestions for integrated terminal (for powershell can reduce time to activate shell from ~600ms -> ~50ms
ctrl + shift + p
Terminal: Clear Suggest Cache
open file "side by side" (in new panel)
ctrl + \
open file in second panel
ctrl + enter
focus file explorer panel
ctrl + 0 // <<-- 1, 2, 3 etc.. == panels
search file explorer
ctrl + p
focus terminal
ctrl + `
focus source control view
ctrl + shift + g
check for changed settings
ctrl + shift + p // cmd palette
// search by "@modified"
// this will filter only settings
// you have made changes to
inside terminal to do "reverse lookup history" (commands entered)
ctrl + r
open/close sidebar
ctrl + b
goto/go to definition
fn + f12
goto/go to references
shift + fn + f12
select current line
ctrl + l
open markdown preview
ctrl + shift + v
Side by side Markdown edit and preview
ctrl + k, v # ctrl + k, then release, press v
change coding language
(inside text editor)
ctrl + k, m # release ctrl + k, then press m
copy file relative path
ctrl + k, ctrl + shift + c
go to line #
ctrl + shift + p
:#
// backspace the > then :number
navigate history (tabs?)
ctrl + tab
alt + left # navigate back
alt + right # navigate forward
navigate to specific line
ctrl + g
add additional cursors to all occurrences
ctrl + shift + l
replace all occurrences in the open file
ctrl + h
ctrl + K + M
–> “change language mode” –> JSON to format JSON stringified object grabbed from browser
JavaScript Console Debugging
console.log({object}) /* will print as console.log("object:": { ... }); */
console.dir(object, {depth: null}) /* will print all of the data rather than compared to console.log which only returns top level, not nested data */
run application
ctrl + fn + f5 # <<-- default run
fn + f5 # <<-- debug run (slower)
build project
ctrl + shift + b
open breakpoints window
ctrl + alt + b
open terminal (View.Terminal) shortcut added
ctrl + shift + t
quick launch
ctrl + q # search commands keywords e.g: "new"
extract code snippet to new Method
// highlight target code
ctrl + r, ctrl + m
// this will move the highlighted code to a new method with this signature:
// private void NewMethod()
// the targeted code will be the body of this new method
multiline comment
shift + alt + a # multi line /* */
ctrl + k, ctrl + / # single line (can be multi) //
ctrl + k, ctrl + c # alternate single line comment
ctrl + k, ctrl + u # uncomment
see all references
alt + 2 // <<-- shows where used
<summary></summary> C#Docs
/// <-- will auto populate this...
/// <summary>
/// Comment goes here
/// </summary>
// e.g.
/// <summary>
/// Comment goes here
/// </summary>
///
create a new file in project
shift + fn + f2 # with Add New File extension
---
ctrl + shift + a
ctrl + n # alternate option
ctrl + shift + n # new project
create new Class in project
(custom) (j === insert)
ctrl + shift + j, c // release then press c
create new Interface in project
(custom) (j === insert)
ctrl + shift + j, i // release then press i
link proj dependencies, link proj as reference
cd \IntoProj
dotnet add reference ..\ParentProj\Proj.csproj
// find the .csproj level to link
// requires dotnet sln command to be complete..
link VS solution files dotnet sln
cd .. // cd to root or whatever .sln level you want to link to
dotnet sln add YourProj\WithSolution.csproj
format
ctrl + k, ctrl + d # formats entire DOCUMENT (d = doc)
ctrl + k, ctrl + f # formats selection (f = format)
focus text editor
esc # literally, just hit escape once...
navigate tabs | close tabs
ctrl + tab # next tab
ctrl + shift + tab # prev tab
ctrl + fn + f4 # close active tab
alt + w + l # close all tabs
navigate to solution explorer
ctrl + alt + l # ctrl + tab navigate tabs here too
ctrl + ; # to solution explorer w/ search bar
go to line start
fn + k # k === "home"
ctrl + / + leftArrow # Edit.LineStart
go to line end
fn + , # , === "end"
ctrl + / + rightArrow # Edit.LineEnd
go to Class(?)
ctrl + click // highlighted class
search file name
ctrl + , # type name of file to find
Go To
ctrl + g # go to line
fn + f12 # go to definition
ctrl + fn + f12 # go to declaration
ctrl + d # go to next (highlighted selection)
Go To All
(NICE)
ctrl + t # backspace to clear out "symbol"
navigate back to prev window
ctrl + -
find closing brace
ctrl + ]
open toolbox
ctrl + alt + x
multi cursor edit (also in Edit menu)
ctrl + alt + click // add 2nd caret
ctrl + alt + dbl-click // add 2nd word selection
ctrl + alt + click + drag // add 2nd selection
shift + alt + . // add next matching text
shift + alt + ; // add all matching text
shift + alt + , // rm last selected occurence
shift + alt + / // skip next matching occurence
alt + click // add a box selection
esc OR click // clear all selections
add cursor above/below
ctrl + alt + upArrow
ctrl + alt + downArrow
collapse/expand code blocks
ctrl + m, ctrl + m
replace
ctrl + h
replace all occurrences
alt + a # once you have entered what you would like to sub
delete to...
ctrl + delete # delete to start of word
ctrl + backspace # delete to end of word
save all
ctrl + shift + s
view in browser
ctrl + shift + w
bookmark
(a keyboard chord is multiple shortcuts in a row)
ctrl + k, ctrl + k
View >> Bookmark Window
to view all Bookmarksnext split pane
fn + f6
collapse markup element (html)
ctrl + m, ctrl + m
add breakpoint (highlight line first)
fn + f9 # <<-- press again to remove
continue to next breakpoint (inside debugger)
fn + fn5
step over (inside debugger)
fn + f10
step into method (inside debugger)
fn + f11
step out of method (if accidentally stepped in)
shift + fn + fn11
exit debugger
ctrl + shift + fn + f5
replace (find and replace)
ctrl + h
rename all properties
ctrl + r, ctrl + r
solution explorer (folder explorer)
ctrl + alt + l
copyLinesDown (without VSCode extra mappings
ctrl + d
alternate copyLinesDown option
# without any selection
ctrl + e
ctrl + v
alt + up/down # <<-- to move
extensions with .user will not get checked-in
httpenv.json.user
auto fix suggestions
alt + enter
open Test Explorer
ctrl + e, t
run tests
ctrl + r, t // runs selectred
ctrl + r, a // runs all tests
ctrl + r, l // "repeat last run"
extract method
ctrl + r, ctrl + m
ctrl + alt + j
ctrl + click
on var
or type identifier
to open object definition, which will show all attributes and methods on datatype “constructor” parent object (“struct
” in C#) (available methods)Console.WriteLine()
cw # press tab twice
public CodeSnippetExamples() { }
“Constructor”
ctor # press tab twice
public string LastName { get; set; }
“Property”
prop # press tab twice
propfull # <-- creates FULL prop w/ getter & setter
try { } catch (Exception) { throw; }
try/catch block
try # press tab twice
tryf # try/finally block
catch (... ex)
for loop
for # press tab twice
forr # for loop decrement
foreach loop
including collection
var names = new List<string>();
foreach # press tab twice
foreach (var name in names) { }
while loop
while # press tab twice
do { } while (true);
do # press tab twice
populate snippets from context menu
ctrl + k, ctrl + x
# for example, surround With or e.g. Wrap {} w/ braces
view Unity Project Explorer
alt + shift + e
// filters sln/proj to unity files
following are bash specific
Explorer Windows File System (so helpful connecting sub-system partition to main OS)
open windows file explorer GUI for WSL
explorer.exe .
echo
or cat
write to a file with Bash:cat >> /path/to/existingFile.text<< EOF
some text line 1
some text line 2
some text line 3
EOF
switch cat >>
to cat >
to create a file instead of append
cat > /path/to/newFile.text<< EOF
some text line 1
some text line 2
some text line 3
EOF
(( expression ))
<– this will execute/perform an expression
print BASH env
printenv
echo variables
(example how to access vars in BASH)
echo $LANG # <-- LANG env var (bash)
$RANDOM in BASH will create a random number
echo $RANDOM # <-- 22024 : between 0 and 32767
I=0 # <-- passing this in the terminal will persist a var
(( I++ )) # <-- I will now become 1 and persist
# we don't need to prepend $ for vars in (( expression ))
this will print expressions for (( expression )) operations
help let
View file "long" with permissions list
ls -l
-rw-r--r--
in front of the file indicates the permissions: r
= read, w
= write, x
= execute
output: -rwxr-xr-x
<– see x
by 3 different “users” (all users can execute now)
Give executable permissions to a file
chmod +x filename.whatever
man
command is “manual” (like help
)
man bash # <-- prints manual for bash
man sleep # <-- prints manual for sleep (binary)
-e
flag needed for special characters
echo -e "\n~~ Countdown Timer ~~\n"
lists root of the file system
ls /
ls /bin will list all binaries on the file system. Bash lives here: #!/bin/bash which will use bash commands. we can access other binaries or libraries here
lists bash commands
help
things we can pass to the bash TEST command (for testing true/false (for ifs or [[ EXPRESSIONS ]]))
help test
( expression ) # <-- evaluates expression/returns value
help [[ expression ]] # <-- output below
( EXPRESSION ) Returns the value of EXPRESSION
! EXPRESSION True if EXPRESSION is false; else false
EXPR1 && EXPR2 True if both EXPR1 and EXPR2 are true; else false
EXPR1 || EXPR2 True if either EXPR1 or EXPR2 is true; else false
When the `==' and `!=' operators are used, the string to the right of
the operator is used as a pattern and pattern matching is performed.
When the `=~' operator is used, the string to the right of the operator
is matched as a regular expression.
The && and || operators do not evaluate EXPR2 if EXPR1 is sufficient to
determine the expression's value.
Exit Status:
Returns success if EXPR evaluates to true; fails if EXPR evaluates to
false or an invalid argument is given.
we can evaluate any expression in the BASH terminal or .sh script:
[[ 4 -le 5 ]] # <-- `-le` === less-than-or-equal
echo $?
echo $? # <-- prints last bash command's EXIT STATUS
0 # <-- 0 === true (0 === no errors)
[[ 4 -ge 5 ]]
echo $?
1 # <-- 1 === false (> 0 === contains errors | "false")
[[ 4 -ge 5 ]]; echo $? # <-- run multiple comands on single line with `;`
1 # <-- output
we can think of 0
return as TRUE but it actually means command had 0 errors
(EXIT STATUS)
check if a file exists (and output EXIT STATUS)
-a | -e
THIS WILL CHECK THE FOLDER FROM WHERE THE COMMAND WAS ENTERED
[[ -a countdown.sh ]]; echo $?
0 # <-- output 0 if file exists
to list all variables in BASH
declare -p
all variables: @ | *
ARR=("a" "b" "c")
echo ${ARR[@]}
declare -p ARR
# --> declare -a ARR=([0]="a" [1]="b" [2]="c")
# --> -a === array
Read (capture user INPUT)
capture user input
read
Return IP address of Windows Machine as seen from WSL VM
ip route show | grep -i default | awk '{ print $3}'
set -x
at the top of a script enables debugging (printing executed commands to the terminal)
#!/bin/bash
set -x
# Your script goes here
get current path
(Get-Item .).FullName
pipe to clipboard
(Get-Item .).FullName | Set-Clipboard
run cmd prompt in pshell
cmd // starts cmd prompt in window
exit // returns to pshell in window
run "external commands" like .bat or .cmd, executables (.exe) or non-native cmdlets and command-line tools (like in your PATH or full pathed)...
&
call operator
& notepad.exe
& calc.exe
& "C:\Path\To\SomeExecutable.exe"
run single cmd prompt command in pshell
cmd /c <command>
// e.g.
cmd /c dir // like ls
cmd /c set # displays your system env
cmd /c set > file_name.txt // like cat
list all running processes w/ binary program names
netstat -ba # will require elevated perm
netstat -ban # this will also show IPs
get powershell version
$PSVersionTable.PSVersion
open persistent PS profile file
will create new $PROFILE if not exists
code $PROFILE.AllUsersAllHosts
put this inside your $PROFILE.ps1
opens specified dir on shell launch
Set-Location C:\Users\User\Dev
to Set-Alias that takes params
function ListAll { # script block/fn
Get-ChildItem -Force
}
Set-Alias ls-a ListAll # create Alias/invoke
# Set-Alias -Name list -Value cmdlet/fn
# this above syntax only works for no params
create a symbolic link shortcut to path
New-Item -itemtype symboliclink -Path "PathWhereYouWantToPutShortcut" -name "NameOfShortcut" -value "PathOfWhatYourTryingToLinkTo"
start transcript of entire session to local file
Start-Transcript
Stop-Transcript # stop when done
find windows IPs
ipconfig
find WSL IPs
wsl hostname -i
wsl hostname -I
Rename directory (like bash mv)
Rename-Item "D:\temp\Test Test1"
open Visual Studio IDE latest version
start devenv
open Visual Studio IDE specific solution (folder or file)
start devenv solution1.sln # file extension? solution?
# because I have multiple VS installed on my machine, i need to include the entier absolute path to the executable in order to run from CLI
open current folder in windows explorer
ii . # <<-- alias Invoke-item
create a new file
New-Item example.txt
ni example.txt -type file
append to file
"content to add" | add-content -path .\README.md
# OR
"content to add" >> .\README.md
overwrite file contents
"overwrite stuff" > .\README.md
string literals vs evaluation
'Hello $ man' # doesn't evaluate special characters or anything
"../blob/$Version" # $Version is evaluated as a variable expression
delete recursive rm -rf
Remove-Item -Recurse -Force <path>
move item(s)
Move-Item -Path .\whatever\files -Destination .\destination -force
copy item(s) -recurse if folder
Copy-Item -Path .\the\files -Recurse -Destination .\the\destination -force
return the IP addr of the WSL (linux distro) VM
wsl hostname -I
display directory contents
dir // <<-- windows/cmd version of `ls`
display system env
set
write env to file
set > file_name.txt
pipe to clipboard
// ... | clip
where pip3 | clip
initiate reboot ("windows terminal")
shutdown /r /t 0
(this might only work in windows terminal)
runs zsh powerlvl10k setup (prompt styling)
p10k configure
find all running node processes
ps -ef | grep node
find node process by port
lsof -i :3000
kill process
kill -9 PROCESS_ID
restore nuget packages
dotnet restore
run C# program.cs (entry point)
dotnet run
create new console app .NET
dotnet new console -o ./CsharpProjects/TestProject
# pass `--use-program-main` for Program Class template
push package to nuget.org
dotnet nuget push <.\path\to\packed.1.0.0.nupkg> --api-key <abcdef12345> --source https://api.nuget.org/v3/index.json
(VSCODE)
generate assets for build and debug
ctrl + shift + p // cmd pallette
// enter ".net: g"
// select ".NET: Generate Assets for Build and Debug"
CSS Caching with ASP.NET
<!-- tick disable browser cache in browser dev tools... and/or... -->
<!-- in html markup (razor or w/e framework working w/ .NET)... -->
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true">
<!-- asp-append-version="true" will append a new version ID to the css file that is compiled down... -->
<!-- ...this ensures proper caching on changes to source -->
copy css class declarations from web browser
/* When inspecting and adjusting CSS in browser dev tools... */
/* ...highlight all class declarations you made... */
/* ...right click and select "copy all declarations" */
check Ubuntu version
lsb_release -a
search for software to install
<application>
sudo apt search <audacity>
install from cli
sudo apt install audacity
killall <-- terminates process
killall <snap-store>
turn on/off windows features
Control Panel > Programs > Programs and Features > Turn Windows featrures on or off
telnet "allows connecting to other computers remotely"
// In "Turn Windows features on or off"
// ... check the Telnet box
[x] Telnet
Use Telnet to check the port
telnet <address> <port_number>
telnet google.com 80
dumbest windows shortcut ever
switch entire windows dekstop
ctrl + win + right // next (new)
ctrl + win + left // prev (all old)
inside file explorer:
ctrl + l // focus address bar
cmd // enter cmd to open cmd in this location
powershell // open powershell in this location
anywhere, but useful inside file explorer
more options include copy path, open powershell here, open linux shell here
shift + right-click // opens menu with more options
FIND COLUMNT in DB
SELECT * FROM information_schema.columns WHERE column_name = 'My_Column'
SELF REFERENCING TABLE
SELECT a.something, b.other
FROM mytable a, mytable b
WHERE a.sometest val ...
AND b.othertest val...
WHEN to clean up CURSOR
IF CURSOR_STATUS('local', 'X') >= -1
BEGIN
CLOSE X;
DEALLOCATE X
END;
list all schemas in DB
SELECT name FROM sys.schemas
-- dbo -> [dbo].table
-- lu -> [lu].table
-- etc
fix SSMS won't see new objects/tables
Edit > Intellisense > Refresh Local Cache
OR
ctrl + shift + r
For Ubuntu/Debian, you can find cron
logs at:
/var/log/syslog
variables created/stored in "Environments" in postman can be passed into fields using
Client ID:
Client Secret:
grep nri // <--
To get a list of all listening TCP ports using lsof
sudo lsof -nP -iTCP -sTCP:LISTEN
using ss tool (formerly netstat) to list all open ports
ss -tulpn
tree [OPTIONS] [directory]
(“.
” might not be necessary)
List folder structure only directories from current directory
tree -d .
List folder structure only directors at depth 1
tree -d -L 1 .
List folder structure and all hidden files
tree -a .
tagging commits, usually for release
git tag -l # the -l (list) flag is opt
# lists all current tags
git tag v1.0.0 2261e84e
# tags a commit by sha
git tag v1.0.1
# tags your current commit
git tag -a v1.0.2 -m "annotate this tag"
# -a flag for annotate -m for message
git show v1.0.0
# this will show associated commit
git log --pretty=oneline
# shows all commits pretty
git push origin --tags
# this will push all tags that aren't already on the remote up
using the git stash stack
git stash # puts all workind dir changes on top of stash stack
git stash apply # brings back that level of the stack into working dir (un staged)
git stash pop # same as apply except "pops" that level off the stack (dropping it)
git stash drop # removes the top level of the stack
git stash list # shows the entire stack, the newest is always the lowest number
git stash -u # same as git stash --include-untracked
# will include more than just modified and staged
git stash --all # similar to -u ?
git stash --patch # stash hunk at a time
git status
git status -s # short output
if you have changes on your remote that you didn't mean to track:
add dir and/or files to .gitignore
then use this command to remove from the index (the actual location in <baseOfRepo>/.git/index which is your staging area)
git rm --cached put/here/your/file.ext # for files
git rm --cached folder/\* # for directory of files
# append --dry-run # to see what will happen w/o executing
git push ... # to update removal and untrack to remote
CAUTION: i have only used this on auto-generated files, so i safely know they will be recreated locally upon deletion...
proceed with caution by backing up files if this is not the case for you...
bring committed changes back to working directory (e.g. for committed files you want to stash that have not been pushed
git reset HEAD~1 --soft
probably best reset option. discard 2 of 3 git areas
git reset --mixed
# discards commit and staged changes (in the git index) but KEEPS changes in your working dir (files in IDE)
show remote repo branches state compared with local branches
# git remote show <remote alias>
git remote show origin
git add --patch "hunks"
git add -p # shows hunks diff in CLI
tool for giff from all commits on current branch
gitk --all
switch to FILE and discard changes (destructive)
git restore
move between branches (replaces checkout) doesn't discard changes
git switch # only takes branch as arg
# checkout is for switching tags and commits
how to proceed in interactive rebase
# git rebase -i or something
# once you decide the strategy for rebasing (specific files squash, pick, reword, etc)
# then how to continue after handling merge conflicts and whatnot
git add README.txt && git rebase --continue
Erratic Distortion Lost & Found