Skip to content

Instantly share code, notes, and snippets.

@wilmoore
Last active November 11, 2024 19:22
Show Gist options
  • Select an option

  • Save wilmoore/302f29590581f79daa96aa1423f3f525 to your computer and use it in GitHub Desktop.

Select an option

Save wilmoore/302f29590581f79daa96aa1423f3f525 to your computer and use it in GitHub Desktop.
Software Engineering :: Operating Systems :: Linux :: Terminal :: Line Editor

Software Engineering :: Operating Systems :: Linux :: Terminal :: Line Editor

⪼ Made with 💜 by Polyglot.

reference

Here's a markdown table depicting the common line editing keybindings for Linux terminal emulation in both Vim mode and the default Emacs mode. This table covers basic navigation, editing, and history manipulation commands.

Action Emacs Mode Vim Mode (Normal)
Move cursor left Ctrl + b h
Move cursor right Ctrl + f l
Move to the start of line Ctrl + a 0 or ^
Move to the end of line Ctrl + e $
Delete character under cursor Ctrl + d x
Delete character before cursor Backspace X
Delete from cursor to end of word Alt + d dw
Delete from cursor to start of word Ctrl + w db or b then d
Delete from cursor to end of line Ctrl + k D or d$
Delete from cursor to start of line Ctrl + u d0
Paste (after cursor) Ctrl + y p
Paste (before cursor) Not default P
Undo Ctrl + _ or Ctrl + x Ctrl + u u
Redo Not default Ctrl + r
Search history backward Ctrl + r / (then n for next match, N for previous)
Search history forward Ctrl + s ? (then n for next match, N for previous)
Complete command Tab Tab
Execute command Enter Enter
Cancel Ctrl + c Ctrl + c
Clear screen Ctrl + l Ctrl + l

Note:

  • The Vim mode keybindings assume you have set your terminal to use Vim-style line editing, which might require enabling Vim mode explicitly with something like set -o vi.
  • Some terminals or shell environments might not support all keybindings by default, or they may require additional configuration.
  • This table is not exhaustive and focuses on the most commonly used line editing commands.

Here's a markdown table that outlines the keybindings for line editing in Linux terminal emulation, comparing the default Emacs mode and Vim mode. This table includes some of the most commonly used commands for both modes.

Function Emacs Mode Vim Mode (Normal Mode) Vim Mode (Insert Mode)
Cursor Movement
Move cursor left Ctrl-b h <Esc>h
Move cursor right Ctrl-f l <Esc>l
Move to start of line Ctrl-a 0 <Esc>0
Move to end of line Ctrl-e $ <Esc>$
Editing Text
Delete char under cursor Ctrl-d x <Esc>x
Delete char before cursor Backspace X <Esc>X
Delete to start of line Ctrl-u d0 <Esc>d0
Delete to end of line Ctrl-k D <Esc>D
Undo Ctrl-_ or Ctrl-x Ctrl-u u <Esc>u
Cut/Copy/Paste
Cut text (kill) Ctrl-k (to end of line) d$ <Esc>d$
Copy text (yank) Alt-w after selecting text y <Esc>y
Paste text (yank) Ctrl-y p <Esc>p
Search and Replace
Search backward Ctrl-r ? <Esc>?
Search forward Ctrl-s / <Esc>/
Replace N/A :s <Esc>:s
Miscellaneous
Execute command Ctrl-j or Enter :command <Esc>:command
Cancel editing Ctrl-c <Esc> <Esc>
Enter command mode N/A : <Esc>:
Enter insert mode N/A i i

Please note that the keybindings in Vim mode can vary slightly depending on whether you are in normal mode or insert mode. In insert mode, you often need to press <Esc> first to return to normal mode before you can use the normal mode commands.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment