alvin's blog

Linux sed command - use sed and wc to count leading blanks in a file

I use JSPs and servlets to generate a lot of the pages around here, and today I looked at how many blank spaces and blank lines are generated by the JSP's. I don't think I can do much about the blank lines (actually, I just haven't looked into it yet), but about those blanks spaces ...

Out of curiosity I decided to look at this -- how many blank spaces are there at the beginning of lines that I could delete just through formatting? Would deleting those characters help reduce my bandwidth costs (at the expense of slightly uglier JSP's)?

vi search replace - how to repeat vi commands across multiple files

Another cool feature of the vi and vim editors is that you can easily re-use some search and replace commands across files. For example, I was just editing several HTML files and needed to do the exact same thing to each file: find a certain line, and then delete that line and the line right after it. Fortunately this is very easy to do in vi.

To edit multiple files in vi I first issue this command from the Linux command prompt:

Mac Firefox URL shortcut - keystroke to select the Firefox URL field

For a while on the Mac I kept finding myself always clicking on the URL/location field in Firefox and Safari. Then one day I noticed this, and wondered why I was doing that instead of using the keyboard command/shortcut to highlight the field and then typing. That answer was easy -- I didn't know what the keyboard command was. It's not the same as it was on Windows.

Turns out it's very simple: [command][L] does the trick.

Syndicate content