Vim Keyboard Shortcuts
gg
Move to the first line of the fileG
Move to the last linegg=G
Reindent the whole filegv
Reselect the last visual selection<
Jump to beginning of last visual selection>
Jump to end of last visual selection^
Move to first non-blank character of the lineg_
Move the last non-blank character of the line (but you remove trailing whitespace, right)g_lD
Delete all the trailing whitespace on the lineea
Append to the end of the current wordgf
Jump to the file name under the cursorxp
Swap character forwardXp
Swap character backwardyyp
Duplicate the current lineyapP
Duplicate the current paragraphdat
Delete around an HTML tag, including the tagdit
Delete inside an HTML tag, excluding the tagw
Move one word to the rightb
Move one word to the leftdd
Delete the current linezc
Close current foldzo
Open current foldza
Toggle current foldzi
Toggle folding entirely<<
Outdent current line>>
Indent current linez=
Show spelling correctionszg
Add to spelling dictionaryzw
Remove from spelling dictionary~
Toggle case of current charactergUw
Uppercase until end of word (u for lower, ~ to toggle)gUiw
Uppercase entire word (u for lower, ~ to toggle)gUU
Uppercase entire linegu$
Lowercase until the end of the lineda"
Delete the next double-quoted string+
Move to the first non-whitespace character of the next lineS
Delete current line and go into insert modeI
insert at the beginning of the lineci"
Change what’s inside the next double-quoted stringca{
Change inside the curly braces (try [, (, etc.)vaw
Visually select worddap
Delete the whole paragraphr
Replace a character[
Jump to beginning of last yanked text]
Jump to end of last yanked textg;
Jump to the last change you madeg,
Jump back forward through the change list&
Repeat last substitution on current lineg&
Repeat last substitution on all linesZZ
Save the current file and quit Vim
Tags: cli, vim, cheatsheet, shortcuts, motd
SSH Escape Sequences
Have you ever had an SSH connection timeout on you and you’re left with what looks like a locked session. Repeatedly hitting the Enter key does nothing. It seems that there is nothing that you can do except close the console terminal session…or is there something else?
Many people are not aware that SSH has its own set of keyboard shortcuts. The solution to the above problem is to terminate the connection using the first of these shortcuts.
- Press the Enter key.
- Press the tilde followed by a period.
- Press Enter again. You should now be back at your command prompt.
Supported escape sequences:
~.
- terminate
connection (and any multiplexed sessions)
~B
- send a
BREAK to the remote system
~R
- request rekey
~V/v
- decrease/increase verbosity (LogLevel)
~^Z
- suspend ssh
~#
- list forwarded
connections
~&
- background ssh (when waiting for
connections to terminate)
~?
- this message
~~
- send the escape character by typing it twice
(Note that escapes are only recognized immediately after newline.)
It is important to note that you always press the Enter key before typing the key sequences above.
Tags: cli, ssh, shortcuts, motd
Windows Terminal Keyboard Shortcuts
I have to use Windows where I work but I use the terminal as often as
possible. Microsoft’s Windows Terminal application makes that experience
tolerable. You can even think that you’re using tmux
at
times…well, not really, but you get the idea.
Here are some of the keyboard shortcuts that I use:
Split current terminal window
Alt Shift
- split pane horizontal
Alt Shift
- split pane vertical
Jump to other console
Alt <arrow key>
Resize current terminal window
Alt Shift <arrow key>
Close terminal window
Ctrl Shift W
Others that I don’t use as much
Ctrl + Shift + Number
: Open new profiles/tabs. Use this
shortcut to open a new profile or tab in Windows Terminal. Each number
represents a specific profile in the Terminal. Profiles are numbered in
the top-down form in the profile selection dropdown menu on the title
bar. For example, if the PowerShell profile is in the second position,
you should press the “Ctrl + Shift + 2” to open it.
Ctrl + Alt + Number
: Switch to a specific tab. Use this
shortcut to switch between tabs. Tabs are numbered from left to right
and start with “1.” For example, if you want to switch to the third tab,
press “Ctrl + Alt + 3.”
Ctrl + Shift + Space
: Opens profile selection dropdown
menu. You can then use the up/down arrow keys to select and open the
profile.
Ctrl + Shift + T
: Opens a new tab with the default
profile.
Ctrl + Shift + N
: Opens a new Windows Terminal
instance.
Ctrl + Shift + D
: This shortcut will duplicate or open
another instance of the current tab. However, it will not copy the
content of the original tab.
Ctrl + C
: Copy selected text. Select the text in the
Terminal and press the shortcut to copy it to the clipboard. Once
copied, you can paste it anywhere you want.
Ctrl + V
: Paste clipboard content. Pressing this
shortcut will paste the clipboard contents into the Terminal. Keep in
mind that only compatible content, like text, will be pasted. If you try
to paste incompatible content, like an image, the result will not be as
expected or intended.
Ctrl + Shift + W
: Close the current tab (not the entire
application).
Alt + F4
: Close the Windows Terminal window. If there
are multiple tabs, you might see a warning prompt. In that case, click
“Close all” to continue.
Ctrl + Shift + F
: Opens the “Find” function. It can be
used to find instances of a text or sentence in a terminal tab. This
functionality is similar to what you find in a browser or other
applications like Notepad, Word, etc.
Ctrl + Numpad Add/Minus
: Increase or decrease the text
size in the Windows Terminal tab.
Ctrl + 0
: Reset the font or text size its default
(100%).
Ctrl + Shift + Up/Down arrow
: Scroll up or down in the
Windows Terminal.
Ctrl + Shift + PageUp/PageDown
: Move to top or bottom in
the Windows Terminal.
Alt + Shift + Minus/Plus
: Split current pane
horizontally or vertically.
Ctrl + Shift + P
: Toggle command palette. It can be used
to select and execute a command or action from the available list.
Ctrl + Shift + ,
: This shortcut opens the Settings tab
in the Windows Terminal.
F11
: Toggle fullscreen.