Pages

Friday, May 9, 2008

Clean Up Indentations in vi

Pasting or adding to existing scripts can often get ugly. To help clean up, you can set tab and shift widths to custom sizes in vi.

To set the length of tabs to n spaces:
  • :set tabstop=n


To shift a block of text n spaces:
  • :set shiftwidth=n

  • mx

  • >

  • move cursor to end of block)

  • `x


To use spaces instead of tab characters with future presses of the TAB key (vim only):
  • :set expandtab