Adding HTML tags to text files

0 views
Skip to first unread message

John Hughes

unread,
Sep 27, 2008, 5:31:45 PM9/27/08
to vim_use
I am trying to write a few basic commands or scripts to make it easier
to turn some plain text into simple HTML. Basically, I am trying to
four things:

1. Add a generic header and footer to the file.

2. Add opening and closing paragraph tags to all the paragraphs in a
selected area.

3. Add opening and closing tags (such as em tags) to the start and end
of a selection.

4. Add opening and closing list item tags to all the paragraphs in a
selected area and opening and closing ordered/unordered list tags to
the start and end of that selection.

I have managed the first of these with:

:%s#\(\_.\)*#<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://
www.w3.org/TR/html4/strict.dtd">\r\r<html>\r\r<head>\r\r<meta http-
equiv="Content-Type" content="text/html; charset=UTF-8">\r
\r<title>Title</title>\r\r</head>\r\r<body>\r\r&\r</body>\r\r</
html>#eg

However, I am not sure how to achieve the others. I suppose the last
point is actually just a combination of the previous two. Any help
would be greatly appreciated.

Thanks in advance.

John
Reply all
Reply to author
Forward
0 new messages