Skip to content

Instantly share code, notes, and snippets.

@SantoshSrinivas79
Last active December 12, 2018 07:15
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SantoshSrinivas79/84bc4dc821fd0a453706 to your computer and use it in GitHub Desktop.
Save SantoshSrinivas79/84bc4dc821fd0a453706 to your computer and use it in GitHub Desktop.
The ultimate vim distribution

The ultimate vim distribution

vim is an extremely powerful editor and it is becoming high time for me to start learning vim well enough to hack on a lean and mean system.

##Distributions

There are likely many distributions of vim available. I plan to use the following distribution as the vim of my choice!

spf13-vim - The Ultimate Vim Distribution

I will use this on windows since I have a lot of flexibilty on other system that I hack on!

##Additional Useful Plugins

Put these into ~/.vimrc.local

" HTML {
Bundle 'Valloric/MatchTagAlways'
Plugin 'Chiel92/vim-autoformat'
Plugin 'The-NERD-Commenter'
Bundle 'keepcase.vim'
Plugin 'dkprice/vim-easygrep'
" }

##Keyboard tips

  • Shift between tabs using (source: linux - In vim, how can I quickly switch between tabs? - Super User):

    • Next tab: gt
    • Prior tab: gT
    • Numbered tab: nnngt
  • Moving around in vim

    • Use ^ or 0, in normal mode, to move to the beginning of a line.
    • Use $, to go to end of line
  • Cut and Copying out of vim

    • set mouse = r disables going into visual mode. you can then copy and cut out of vim
      • Often the line numbers interfere. Use this to enable or disable line numbers
        • Disable set nonumber
        • Enable set number
  • Copy Multiple Lines

    Position the cursor at the beginning of the text you want to cut/copy. Press v to begin character-based visual selection, or V to select whole lines, or Ctrl-v or Ctrl-q to select a block. Move the cursor to the end of the text to be cut/copied. While selecting text, you can perform searches and other advanced movement. Press d (delete) to cut, or y (yank) to copy. Move the cursor to the desired paste location. Press p to paste after the cursor, or P to paste before.

  • Match HTML tags

    Add the following entry to ~/.vimrc.bundles.local

        Bundle "Valloric/MatchTagAlways"
  • Comment code using NERD Commenter

,+c+space seems to work!

  • Jump to matching bracket

Press % .. source: Moving to matching braces - Vim Tips Wiki

  • Deleting a file using NERDTREE

    • Browse to the file using NERDTREE and then m followed by d
  • Jump to matching HTML Tag

Press % .. source: http://stackoverflow.com/a/501001

  • Fold and Unfold HTML tags (Collapse or Expand HTML tags)

I have found zfat (or, equally, zfit) works well for folding with HTML documents. za will toggle (open or close) an existing fold. zR opens all the folds in the current document, zM effectively re-enables all existing folds marked in the document.

Source: How to fold/unfold HTML tags with Vim - Stack Overflow

  • Indenting of visual blocks

In normal mode, type >> to indent the current line, or << to unindent. Each command can be used with a count. The operators > and < do the same for motions, text objects and visual selections. For all commands, pressing . repeats the operation.

For example, typing 5>>.. shifts five lines to the right, and then repeats the operation twice so that the five lines are shifted three times.

In insert mode, Ctrl-T indents the current line, and Ctrl-D unindents.

When indenting or unindenting, lines are shifted one 'shiftwidth' to the right or left.

Source: Shifting blocks visually - Vim Tips Wiki

  • Setting the colorscheme for spf13

Do : colorscheme seoul256 ... this seemed most colorful with enough distinction

##Git tips from vim using Fugitive

Source: Fugitive.vim - working with the git index

  • Use gdiff. More importantly use diffget and diffput. Make sure to check where you are working in the working copy or the index copy!

##Git tips

  • Get list of all logs in commit history
    • git log --name-status
    • git log --name-only
    • git log --stat
    • git rev-list --all --header - many more options here

##s3cmd

  • Upload files so that they are publicly accessible
    • s3cmd put --acl-public --guess-mime-type storage.jpg s3://logix.cz-test/storage.jpg
  • List of files in a s3 bucket
    • s3cmd ls s3://s3orionss/orionjs/

##Resources

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