User login

Vim

CTags and Vim

Thanks in part to
http://sachachua.com/blog/2008/07/eclipse-to-emacs-navigating-your-source-tree/

Set-up:

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

ctags -R -f ctagstags --languages=php --langmap=php:.module.php.inc.engine.profile .

In .vimrc,

set tags=ctagstags;/

In .bashrc

What is the s/findthis/replacewiththis syntax called?

what is the s/find/replace syntax called?

Stefan:

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:

8>>

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: http://jmcpherson.org/editing.html )

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: http://nvie.com/posts/how-i-boosted-my-vim/


git clone git://github.com/msanders/snipmate.vim.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 Agaric.com to data.agaric.com, we needed to create a bunch (1,592 to be precise) redirects that look like this one:

RewriteRule ^nice-menus-drop-down-bug http://data.agaric.com/node/1048 [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:

nice-menus-drop-down-bug http://data.agaric.com/node/1048

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:

:221,225s/link/visited/g

Syndicate content