User login


CTags and Vim

Thanks in part to


(If not already installed: sudo apt-get install exuberant-ctags)

ctags -R -f ctagstags --languages=php .

In .vimrc,

set tags=ctagstags;/

In .bashrc

What is the s/findthis/replacewiththis syntax called?

what is the s/find/replace syntax called?


that's called search and replace with regular expressions

ed is the line editor used by vi [which includes this]
sed is just a stream version of ed

s is the substitution command.

Indent lines in Vim

To indent a set of eight lines in vim, from the first one, in normal (esc) mode:


To indent a curly braces block, go to a curly brace and:


To mark and indent (using 'm' as the marking letter, the first m is the marking command):

Enter mm at the top of block to indent, go down to the end of what needs to be indented, and type >'m

Find the function definition of the current function or find uses of a given function

'gd' doesn't do anything for me (recommended here: )

The asterisk works great though!

  • Read the string under the cursor and go to the next place it appears. (For instance, if your cursor was somewhere on the word "bob," the cursor would move to the next occurance of "bob" in your file.)

Same as above, except it moves the cursor to the previous occurrence.

Vim snippets with SnipMate for PHP and Drupal

See also:

git clone git://
cd snipmate.vim
cp -R * ~/.vim

vi ~/.virmrc (v ~/customhome/.vimrc-agaric for me.)

:filetype plugin on
:helptags ~/.vim/doc

Sudo save a file from within Vim

In Vim, save a file you edited in vim without the needed permissions

:w !sudo tee %

Create rewrite rules from new and old URLs using the power of Vim to munge text

As part of the move of Agaric content from to, we needed to create a bunch (1,592 to be precise) redirects that look like this one:

RewriteRule ^nice-menus-drop-down-bug [NC,R=301,L]

Stefan, in his wizardry, had already pulled a tab-separated-value file of the old path to the new URL, so that what we had was:


Vim search and replace between set lines

regular expression change on next lines vi
Doesn't even need a regexp. Just find and substitute.

Replace all occurrences of "link" with "visited" between lines 221 and 225:


Syndicate content