THE CRANK HOUSE

Home
RSS Reader
Monday Night Golf
HowTo's
Scott Moriarty
Crankhouse Classic
Tour of Worcester Pics
Site Overview

Downloads

Download Page
NTimer
scheck

Friends

Bill Rowell
Kyle Bradshaw
Dan Pickett

Important Links

The Basics of UNIX Philosophy

Bad Vista

vim Tips

Regular Expressions

Delete lines containing a specific pattern.

:g/matchpattern/d

Find all tags in a file containg mark up (HTML and XML ).

:g/<[^>]*>/

Fixing indents

I have a bunch of C# source files, that I edited in both vim and Visual Studio 2005. The TAB character did not translate properly between the 2 editors. I know of 2 ways to fix the indents in files; one is a few lines at a time and the other is to do the entire file at once.

So say I want to indent 6 lines. First move your cursor to the first line, with the other 5 that need fixing below it. Then issue the following command to vim:
:> 6
	
If you want to remove some indents ( move the lines to the left), then just do this:
:< 6
	

The above method works good if the entire file is not poorly formatted, but if is there is another way to let vim fix it. Just open the file and give the following 4 commands:
:set filetype=cs
:filetype indent on
:e
:gg=G
	

I set the file type to cs ( C# Source ), then turned indenting on, and re-edited the file. I then apply it from the first line to the last line with gg=G.

Valid CSS! Valid XHTML 1.0! Firefox 2 Apache httpd 2.0
Contact: joe at crankhouse d0t c0m
. . . . .