Skip to content

Instantly share code, notes, and snippets.

@JamesAtIntegratnIO
Last active July 26, 2021 20:06
Show Gist options
  • Select an option

  • Save JamesAtIntegratnIO/7232126ae80895757468116519ce1dc4 to your computer and use it in GitHub Desktop.

Select an option

Save JamesAtIntegratnIO/7232126ae80895757468116519ce1dc4 to your computer and use it in GitHub Desktop.

Vim Cheat Sheet

Basic File/Dir work

:pwd                        # List current Directory
:cd ${/some/dir}            # Change to some dir
:e ${/some/file}            # Edit some file
:term                       # Open a terminal

Buffer Management

Handy Buffer Commands

:b${#}                      # switch buffer to desired buffer number
:ls                         # list all buffers
:vs                         # Vertical Split: Split the buffer vertically
:vs ${/file/name}           # Vertical Split and open a file into the buffer
:bs${#}                     # Horizontal split existing buffer number to new buffer
Ctrl + ww                   # Switch between buffers in view. Instead of the last `w` you can also use an arrow key to direct to which buffer to switch to.

Buffer Deletion

:bd                         # deletes the current buffer, error if there are unwritten changes
:bd!                        # deletes the current buffer, no error if unwritten changes
:bufdo bd                   # deletes all buffers, stops at first error (unwritten changes)
:bufdo! bd                  # deletes all buffers except those with unwritten changes
:bufdo! bd!                 # deletes all buffers, no error on any unwritten changes

Less Safe Buffer Deletion

:bw                         # completely deletes the current buffer, error if there are unwritten changes
:bw!                        # completely deletes the current buffer, no error if unwritten changes
:bufdo bw                   # completely deletes all buffers, stops at first error (unwritten changes)
:bufdo! bw                  # completely deletes all buffers except those with unwritten changes
:bufdo! bw!                 # completely deletes all buffers, no error on any unwritten changes

:set confirm                # confirm changes (Yes, No, Cancel) instead of error

NerdTree

ctrl + e                     # Open Nerdtree (specific to spf13 vim)
t                           # Open new NerdTree buffer to slected folder
CC                          # Change NerdTree root directory to the currently selected directory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment