Yvan Seth's Hole in the Internet

Further Internetual randomness courtesy of Yvan Seth, parsnip wrangler.
/Entries/Technology/General/ <rss>

vim and :g

Tue 2006-10-17 19:06

So many things, like vim, are a land of constant discovery. Just now I have devised:

:g/$/exec "s/$/!".line(".")."|"

What it does is append to every line the string !<line-number>| - which will look absurd to most people, but it is incredibly useful for me. There are probably a billion other ways to do the same thing...

Munged from an example on vim.org that inserts line numbers at the start of the line:

:g/^/exec "s/^/".strpart(line(".")."    ",0,4)

No Responses

Name:
Email: (You must register an email address!)
Url: (optional)
Title: (optional)
Response:
All HTML will be escaped. Paragraphs and new-lines are honoured and you can use *word* for bold and _word_ for underline.
Save my Name, URL, and Email for next time
/Entries/Technology/General/vim and :g

© 2005-2009 Yvan Seth — EMail Yvan | XHTML 1.0 Strict | Add to GoogleSubscribe with Bloglines | Creative Commons License

    follow me on Twitter

    Categories

    Badgers

    Protecting your bits. Open Rights Group