Gregg's MOTD

Tips & Tricks that I've Encountered Over the Years...

Vim Keyboard Shortcuts

September 02, 2023 — Gregg Szumowski
  1. gg Move to the first line of the file
  2. G Move to the last line
  3. gg=G Reindent the whole file
  4. gv Reselect the last visual selection
  5. < Jump to beginning of last visual selection
  6. > Jump to end of last visual selection
  7. ^ Move to first non-blank character of the line
  8. g_ Move the last non-blank character of the line (but you remove trailing whitespace, right)
  9. g_lD Delete all the trailing whitespace on the line
  10. ea Append to the end of the current word
  11. gf Jump to the file name under the cursor
  12. xp Swap character forward
  13. Xp Swap character backward
  14. yyp Duplicate the current line
  15. yapP Duplicate the current paragraph
  16. dat Delete around an HTML tag, including the tag
  17. dit Delete inside an HTML tag, excluding the tag
  18. w Move one word to the right
  19. b Move one word to the left
  20. dd Delete the current line
  21. zc Close current fold
  22. zo Open current fold
  23. za Toggle current fold
  24. zi Toggle folding entirely
  25. << Outdent current line
  26. >> Indent current line
  27. z= Show spelling corrections
  28. zg Add to spelling dictionary
  29. zw Remove from spelling dictionary
  30. ~ Toggle case of current character
  31. gUw Uppercase until end of word (u for lower, ~ to toggle)
  32. gUiw Uppercase entire word (u for lower, ~ to toggle)
  33. gUU Uppercase entire line
  34. gu$ Lowercase until the end of the line
  35. da" Delete the next double-quoted string
  36. + Move to the first non-whitespace character of the next line
  37. S Delete current line and go into insert mode
  38. I insert at the beginning of the line
  39. ci" Change what’s inside the next double-quoted string
  40. ca{ Change inside the curly braces (try [, (, etc.)
  41. vaw Visually select word
  42. dap Delete the whole paragraph
  43. r Replace a character
  44. [ Jump to beginning of last yanked text
  45. ] Jump to end of last yanked text
  46. g; Jump to the last change you made
  47. g, Jump back forward through the change list
  48. & Repeat last substitution on current line
  49. g& Repeat last substitution on all lines
  50. ZZ Save the current file and quit Vim

Tags: cli, vim, cheatsheet, shortcuts, motd

SSH Escape Sequences

July 21, 2023 — Gregg Szumowski

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.

  1. Press the Enter key.
  2. Press the tilde followed by a period.
  3. 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

June 02, 2023 — Gregg Szumowski

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.

Tags: cli, windows, terminal, shortcuts, motd