Skip to content

Instantly share code, notes, and snippets.

@karlpokus
Last active November 23, 2016 13:33
Show Gist options
  • Save karlpokus/c635a60d553e14fd62e134c502641075 to your computer and use it in GitHub Desktop.
Save karlpokus/c635a60d553e14fd62e134c502641075 to your computer and use it in GitHub Desktop.
vim like a baos

the cli

# Open 1+ files
$ vim file
$ vim -p [file|*|*.md] [file]
# Pipe to vim
$ echo foo | vim -

the editor

modes

  • ESC normal mode
  • i insert mode
  • v visual mode

navigation

  • h left
  • j down
  • k up
  • l right
  • w start of next word
  • e end of word
  • b beginning of word
  • 0 beginning of line
  • $ end of line
  • g+g beginning of file
  • G end of file
  • [n] + G go to line number
  • * move to next word under cursor
  • # move to previous word under cursor

actions

  • /searchterm
  • n next search result
  • N previous search result
  • o insert new line of text
  • x delete letter
  • X backspace
  • r replace letter under cursor without going into insert
  • . repeat previous command
  • d+d delete line
  • d + [n] + w delete n words
  • y+y copy line
  • y+y+p copy line and paste after current
  • :! [command] Commands from within vim

tabs

# new tab
:tabnew [file]
# close tab
:tabc
# previous tab
:tabp
# next tab
:tabn [number]
# first tab
:tabr
# last tab
:tabl
# list of open tabs
:tabs
# ?
:next

File management

# write (only if there are changes) and quit
:x 
# save
:w [filename]
# quit
:q
# save and quit
:wq
# force save and quit (even without permission)
:wq!
# quit without saving
:q!
# undo
u
# redo
ctrl + R
# help
:help
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment