photo
Jordan Sissel
geek

Sat, 15 Apr 2006

Sexy vim "text objects" feature

Read about text objects in vim with :help text-objects

Text objects are basically direction macros for simple deletion/copy/changing. For instance, diB This will delete everything between the nearest { and closing }. That is:

static int update() {
	if (u) {
		printf("Update\n");
	} else {
		printf("No update\n";
	}
}
Paste the above code in vim. Put the cursor on the first printf (line 3) and, in command mode, do diB - undo that and try ciB. The d command will delete the code block, where as c will do the obvious and delete the code block and leave you in insert mode.

These text object direction things are quite neat. Again, check out the help page on it (:help text-objects). Neat little shortcuts.

Comments: 0 (view comments)
Tags:
Permalink: /productivity/vim-text-objects
posted at: 03:08


0 responses to 'Sexy vim "text objects" feature'


Leave a reply

You need javascript enabled to use this form. Anti-spam efforts ongoing. Also, if the comment doesn't show up, it's because the form expired. Go back and copy your comment, reload the form, and resubmit. Apologies if this is a hassle, I'm just playing with antispam methods right now. If this insists on not working, please email me about it.

Name (required)
E-mail (optional. Not posted or recorded anywhere, ever)
URL (also optional)
Comment:


Search this site

Navigation

Metadata

Home About Resume My Code

Articles

ARP Security Dynamic DNS with DHCP OpenLDAP+Kerberos+SASL PPP over SSH SSH Security: /bin/false Week of Unix Tools Work Efficiency

Projects

fex firefox tabsearch firefox urledit grok keynav liboverride newpsm (FreeBSD) nis2ldap pam_captcha poor man's backup Solaris audio utility xboxproxy xdotool xmlpresenter xpathtool misc scripts

Presentations

Yahoo! Hack Day '06 Unix Essentials Vi/Vim Essentials

Tag Cloud

Calendar

< April 2006 >
SuMoTuWeThFrSa
       1
2 3 4 5 6 7 8
9101112131415
16171819202122
23242526272829
30      

Friends

BarCamp Kent Brewster Tantek Çelik John Resig Wesley Shields Tyler Shields

Technorati