Skip to content

Instantly share code, notes, and snippets.

@gawen
Created February 14, 2020 12:49
Show Gist options
  • Select an option

  • Save gawen/003b5d7da386ed2cc84d42d6f94bc63c to your computer and use it in GitHub Desktop.

Select an option

Save gawen/003b5d7da386ed2cc84d42d6f94bc63c to your computer and use it in GitHub Desktop.

Revisions

  1. gawen created this gist Feb 14, 2020.
    50 changes: 50 additions & 0 deletions README
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,50 @@
    i: interactive mode
    v: visual mode
    escape to go back to no mode

    # classic commands
    :e <filename>: open <filename> in current window
    :e **/<filename>: fuzzy search for <filename>
    :w [<filename>]: write current window
    :q: quit

    suffix 'a' for all files
    :wqa: write every file and quit
    :w!: force writing even if file changed

    # copy/paste
    yy: copy current line
    dd: cut current line
    p: paste default buffer
    "ap: paste register 'a'

    in visual mode,
    y: copy current selection
    d: cut current selection
    "ay: copy current selection in register 'a'
    "ad: cut current selection in register 'a'

    Special register: '+', which is the system clipboard
    "+y: copy current selection in system clipboard
    "+p: ...
    "+d: ...

    # search & replace
    /<expr>: search for expression
    *: search for current expression under cursor
    n: next match
    shift+n: previous match
    :%s/<before>/<after>/g: replace regexp <before> by <after> in current file
    :%g/<expr>/d: delete every line with regexp <expr>

    # window
    :new: open horizontal window
    :vnew: open vertical window

    # cli
    :!<bash>: run <bash> in terminal
    :r!<bash>: run <bash> in terminal and pipe output to current buffer

    # protips
    ctrl+wF: open filepath which is under current cursor
    :r!rg <expr>: search for <expr> in all your files and print in your current buffer (after a :new)