Saari Development

Ali Rizvi's Technical Blog as a Professional Software Development Engineer

Vim: Using Ruby Regular Expression

leave a comment »

I needed to remove line number from a web copy-pasted code snippet. I know there is a way to configure vim to use the perl style regular expressions but I couldn’t find how quickly.

What I found was:
http://vim.wikia.com/wiki/Perl_compatible_regular_expressions

:rubydo gsub /pattern/,'replacement'</code>

Here is my specific command:

:rubydo gsub /^\s+\d{0,3}\s/, ''

Pre-requisite: look for +ruby in :ver output (if it is -ruby then it would not work).

The above web page also talks about Perl regular expression in Vim and different ways to do that.

Advertisements

Written by imsaar

August 28, 2013 at 2:17 pm

Posted in ruby, vim

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: