Categories
Uncategorized

Stuff I Need to Remember – VIM

Search and place stuff in groups…

:%s/^\([^ ]*\)£\([^ ]*\)¶.*$/\2 \1/

        % = all lines
        s = Search
        ^ = from the start
\([^ ]*\) = Make a set (set 1)...
        £ = ... until you come across this character
\([^ ]*\) = Make another set (set 2)...
        ¶ = ... until you come across this character
      .*$ = delete the rest of the line
       \2 = write set two
       \1 = write set one.

# Running the script on this line
This 15 more stuff £ this is some stuff ¶ all until the end.

# will return this
this is some stuff This 15 more stuff

Macros to get all the links I need from the HTML source

# Delete all lines unless they contain "threadTitle"
:v/threadTitle/d

# Remove all tabs and spaces
:%s/\t\|\s//g

# Get the actual link I need
:%s/^\([^ ]*\)href="\([^ ]*\)"id=.*$/\2/

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

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

Google photo

You are commenting using your Google 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 )

Connecting to %s