You can quickly jump to a specified column in Vim by simply typing the column number followed by a pipe.
80| # go to the 80th column
Thursday, August 14, 2008
Tar Gzip On-The-Fly
I typically create tarballs by doing "tar cvf file.tar somedir" and then gzipping the resultant tarball. Sometimes there's not enough space on disk to have an intermediate uncompressed file sitting around. As an example, I just made a backup of 48 gigs of MySQL data yesterday. One handy way to avoid storing the uncompressed file on disk is to gzip on the fly.
tar cvf - somedir | gzip -c > somedir.tar.gz
In writing this post, I just noticed that you can also just give tar the -z flag to accomplish the same thing; however, explicitly piping to gzip allows you to specify options to gzip such as compression level.
tar cvf - somedir | gzip -c > somedir.tar.gz
In writing this post, I just noticed that you can also just give tar the -z flag to accomplish the same thing; however, explicitly piping to gzip allows you to specify options to gzip such as compression level.
Wednesday, August 13, 2008
Change Permissions on All Directories
Sometimes I need to recursively set permissions on all directories in a file hierarchy. Other times, I just want to set file permissions while ignoring directories. Fortunately, the find command makes this easy.
# make all directories read, write, execute for owner. read, execute for group and other
find . -type d -exec chmod 755 {} \;
# make all files read, write for owner. read for group and other
find . -type f -exec chmod 644 {} \;
# make all shell scripts read, write, execute for owner. read, execute for group and other
find . -type f -name "*.sh" 755 {} \;
# make all directories read, write, execute for owner. read, execute for group and other
find . -type d -exec chmod 755 {} \;
# make all files read, write for owner. read for group and other
find . -type f -exec chmod 644 {} \;
# make all shell scripts read, write, execute for owner. read, execute for group and other
find . -type f -name "*.sh" 755 {} \;
Tuesday, August 12, 2008
Vim Can Spell
Thanks to Chris Suter for contributing the following tip:
I always knew this was in there somewhere, but usually my compiler tells me when I'm an idiot, so I've never needed it. Latex, however, does not.
:setlocal spell spelllang=en_us
turns on spell-check and highlighting for incorrectly spelled words.
navigation:
]s - next misspelled word
[s - prev "
interaction:
zg - add misspelled word to system dictionary
zG - add misspelled word to buffer-local set of "good" words
zw - add word to 'bad' list
zW - add word to buffer-local 'bad' list
z= - view a numbered list of suggested spellings from which to choose for auto-replacement
side note: Maybe there's a word list for php fn's, since it seems to assume that when you've mistyped something, you obviously meant 0, "zero", false and NULL simultaneously and chooses arbitrarily between them. This might prevent some headaches/suicides.
I always knew this was in there somewhere, but usually my compiler tells me when I'm an idiot, so I've never needed it. Latex, however, does not.
:setlocal spell spelllang=en_us
turns on spell-check and highlighting for incorrectly spelled words.
navigation:
]s - next misspelled word
[s - prev "
interaction:
zg - add misspelled word to system dictionary
zG - add misspelled word to buffer-local set of "good" words
zw - add word to 'bad' list
zW - add word to buffer-local 'bad' list
z= - view a numbered list of suggested spellings from which to choose for auto-replacement
side note: Maybe there's a word list for php fn's, since it seems to assume that when you've mistyped something, you obviously meant 0, "zero", false and NULL simultaneously and chooses arbitrarily between them. This might prevent some headaches/suicides.
Monday, August 11, 2008
SVN: Add All New Files
I've been doing a lot of Ruby on Rails dev work lately, and the framework tends to generate a lot of files. Until recently, I was using a combination of "svn status" piped into grep, awk, and xargs to accomplish adding new files recursively. A friend recently told me to check out the following solution instead.
svn --force add *
The only negative side effect I can see is that it seems to add ignored files back into the tree. This is mostly a non-issue for me, but take note.
svn --force add *
The only negative side effect I can see is that it seems to add ignored files back into the tree. This is mostly a non-issue for me, but take note.
Sunday, August 10, 2008
S3Virge Woes
I decided to salvage an old junk computer over the weekend. I burned a copy of Xubuntu, and proceeded to install. When the installer tried to initialize X, it couldn't, so I had to do the install in safe graphics mode. The video card, a low-end S3Virge 3d/2x, uses the Xorg s3virge driver. After getting everything working in crappy Vesa mode, I stumbled onto a bug report indicating that there was a bug in s3virge resolution detection that was fixed in Git. I recompiled the appropriate driver from Git, and everything works now. SO, for future reference, here are the steps to re-build the s3virge driver from Git in Xubuntu.
# install packages required for build
apt-get install xorg-dev xserver-xorg-dev libtool autoconf automake
# install git
apt-get install git-core
# check out the repo
git clone git://anongit.freedesktop.org/git/xorg/driver/xf86-video-s3virge
# cd into the repo
cd xf86-video-s3virge
# build and install
./autogen.sh --prefix=/usr && make && sudo make install
Not Vim related I know, but I figure this might help someone.
# install packages required for build
apt-get install xorg-dev xserver-xorg-dev libtool autoconf automake
# install git
apt-get install git-core
# check out the repo
git clone git://anongit.freedesktop.org/git/xorg/driver/xf86-video-s3virge
# cd into the repo
cd xf86-video-s3virge
# build and install
./autogen.sh --prefix=/usr && make && sudo make install
Not Vim related I know, but I figure this might help someone.
Tuesday, August 5, 2008
Window Manipulation
If you have two horizontally split windows and would like to increase the size of the current window, you can do ctrl-w +. A count can be issued beforehand, so to increase the height by 10 lines 10 ctrl-w +. Ctrl-w - will decrease the current window height. To set the current window to an absolute height do N ctrl-w _ where N is the number of lines desired.
In a vertically split scheme, you can use ctrl-w < and ctrl-w > to adjust the width. To set the current window to an absolute width, do N ctrl-w | where N is the number of lines desired.
If you have two windows split horizontally and would like to shift to a vertical scheme, you can do ctrl-w H or ctrl-w L depending on which direction you want the current window to go. Ctrl-w J and ctrl-w K will take a vertically split scheme to a horizontal orientation.
In a vertically split scheme, you can use ctrl-w < and ctrl-w > to adjust the width. To set the current window to an absolute width, do N ctrl-w | where N is the number of lines desired.
If you have two windows split horizontally and would like to shift to a vertical scheme, you can do ctrl-w H or ctrl-w L depending on which direction you want the current window to go. Ctrl-w J and ctrl-w K will take a vertically split scheme to a horizontal orientation.
Subscribe to:
Posts (Atom)