Skip to content

Instantly share code, notes, and snippets.

@scmx
Last active September 26, 2017 09:12
Show Gist options
  • Save scmx/ceca53670634d9a9f972ae1189d23a09 to your computer and use it in GitHub Desktop.
Save scmx/ceca53670634d9a9f972ae1189d23a09 to your computer and use it in GitHub Desktop.
Using <Ctrl> to stay on the home row in your terminal and vim #terminal #vim #osx #unix

Here are some tricks you can use to be able to stay on the home row (asdfghjkl etc) when you're in a terminal or in vim.

Terminal

  • <Ctrl>+l Clear the terminal
  • <Ctrl>+a go to beginning of line
  • <Ctrl>+e go to end of line
  • <Ctrl>+p instead of <Up>, to see previous command
  • <Ctrl>+n instead of <Down>, to see next command
  • <Ctrl>+k + <Ctrl>+u Cut current command
  • <Ctrl>+y Paste command

Terminal + Vim

  • <Ctrl>+u to clear the current line
  • <Ctrl>+j instead of <Enter>
  • <Ctrl>+h instead of <Backspace>
  • <Ctrl>+w instead of <Alt>+<Backspace> to erase current word
  • <Ctrl>+i instead of <Tab>
  • <Ctrl>+ä instead of <Esc> (or <Ctrl>+[ depending on your keyboard layout)

If you are confused by some of this, then take a look at this excellent article

But why is the escape key triggered by the [ character? Why not another character? https://garbagecollected.org/2017/01/31/four-column-ascii/

More goodies here https://superuser.com/a/362115/299642
and here http://teohm.com/blog/shortcuts-to-move-faster-in-bash-command-line/

Bonus: Using Escape

  • <Esc> . to repeat last argument of previous command
  • <Esc> b to jump backward to previous word
  • <Esc> f to jump forward to next word
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment