Demo entry 1387999

cheat sheet

   

Submitted by anonymous on Feb 24, 2015 at 00:56
Language: YAML. Code size: 5.4 kB.

#
# Name of cheats
#
--- name
--- Vim
#
# Short description of what this cheat sheet is about
#
--- description
--- Editor
#
# Order in which sections should be displayed
#
--- section_order
---
- Cursor movement
- Insert mode - inserting/appending text
- Editing
- Marking text (visual mode)
- Visual commands
- Cut and paste
- Exiting
- Search and replace
- Working with multiple files
- Tabs
#
# Hash of sections
#
--- sections
---
Cursor movement:
  $: jump to the end of the line
  # 
  # Have to do this ugliness with single quotes - the command is two of them
  #
  '''''': To the position before the latest jump, or where the last "m'" or "m`" command
    was given.
  '0': jump to the start of the line
  5G: go to line 5
  B: jump backwards to the start of a word (words can contain punctuation)
  E: jump forwards to the end of a word (words can contain punctuation)
  G: go to the last line of the document
  W: jump forwards to the start of a word (words can contain punctuation)
  ^: jump to the first non-blank character of the line
  b: jump backwards to the start of a word
  e: jump forwards to the end of a word
  # 
  # Short description plus a boolean to indicate advanced
  #
  h:
  - move cursor left
  - 1
  j: move cursor down
  k: move cursor up
  l: move cursor right
  w: jump forwards to the start of a word
Cut and paste:
  2dd: delete (cut) 2 lines
  2yy: yank (copy) 2 lines
  D: delete (cut) to the end of the line
  P: put (paste) before cursor
  d$: delete (cut) to the end of the line
  dd: delete (cut) a line
  dw: delete (cut) word
  p: put (paste) the clipboard after cursor
  x: delete (cut) character
  y$: yank (copy) to end of line
  yw: yank (copy) word
  yy: yank (copy) a line
Editing:
  .: repeat last command
  Ctrl+r: redo
  J: join line below to the current one
  S: delete line and substitute text (same as cc)
  c$: change (replace) to the end of the line
  cc: change (replace) entire line
  cw: change (replace) to the end of the word
  r: replace a single character
  s: delete character and substitute text
  u: undo
  xp: transpose two letters (delete and paste)
Exiting:
  :q: quit (fails if there are unsaved changes)
  :q!: quit and throw away unsaved changes
  :w: write (save) the file, but don't exit
  :wq: write (save) and quit
  :x: write (save) and quit
Insert mode - inserting/appending text:
  A: insert (append) at the end of the line
  Esc: exit insert mode
  I: insert at the beginning of the line
  O: append (open) a new line above the current line
  a: insert (append) after the cursor
  ea: insert (append) at the end of the word
  i: insert before the cursor
  o: append (open) a new line below the current line
Marking text (visual mode):
  Ctrl+v: start visual block mode
  Esc: exit visual mode
  O: move to other corner of block
  V: start linewise visual mode
  aB: a block with {}
  ab: a block with ()
  aw: mark a word
  iB: inner block with {}
  ib: inner block with ()
  o: move to other end of marked area
  v: start visual mode, mark lines, then do a command (like y-yank)
Search and replace:
  /pattern:
    # 
    # (Optional) A detailed explanation of the term that could be displayed on click
    # or mouseover. Even though we may not offer this immediately, we would need a
    # hash-like structure to accommodate it, unlike the bare strings above.
    #
    detail: You will notice that when you type the "/" the cursor jumps to the last
      line of the Vim window, like with colon commands.  That is where you type the
      word.  You can press the backspace key (backarrow or <bs>) to make corrections.  Use
      the <left> and <right> cursor keys when necessary.
    # 
    # The shorter, default description to display
    #
    short: search for pattern
  :%s/old/new/g: replace all old with new throughout file
  :%s/old/new/gc: replace all old with new throughout file with confirmations
  ?pattern: search backward for pattern
  N: repeat search in opposite direction
  n: repeat search in same direction
Tabs:
  '#gt': 'move to tab number #'
  :tabclose/:tabc: close the current tab and all its windows
  ':tabmove #': 'move current tab to the #th position (indexed from 0)'
  :tabnew filename, :tabn filename: open a file in a new tab
  #
  # List alternates with slashes or commas
  # 
  :tabonly/:tabo: close all tabs except for the current one
  Ctrl+wt: move the current split window into its own tab
  gT:
    #
    # Have an alts key so we could eventually do something cool with them.
    # Initially we might just concatenate them together with slashes or commas
    #
    alts:
    - :tabprev
    - :tabp
    short: move to the previous tab
  #
  # Alternates with commas
  #
  gt, :tabnext, :tabn: move to the next tab
Visual commands:
  &lt;: shift text left
  '&gt;': shift text right
  d: delete marked text
  y: yank (copy) marked text
  '~': switch case
Working with multiple files:
  :bd: delete a buffer (close a file)
  :bnext/:bn: go to the next buffer
  :bprev/:bp: go to the previous buffer
  :e filename: edit a file in a new buffer
  :sp filename: open a file in a new buffer and split window
  :vsp filename: open a file in a new buffer and vertically split window
  Ctrl+wh: move cursor to next buffer (right)
  Ctrl+wl: move cursor to previous buffer (left)
  Ctrl+wq: quit a window
  Ctrl+ws: split window
  Ctrl+wv: split window vertically
  Ctrl+ww: switch windows

This snippet took 0.02 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).