tags:

views:

42

answers:

2

I want to add this code:

<link rel="stylesheet" type="text/css" href="css/global.css" />
<!--[if lt IE 8]>
    <link rel="stylesheet" type="text/css" href="css/iehacks.css" />
<![endif]-->

to all the files in a folder right before the </head> tag

+2  A: 

I'm not sure if this is possible with vim, but you can always execute a shell command from it. Both sed and perl can do inplace file edits. Have a look here and here.

Bozhidar Batsov
+1  A: 

I would record a macro to insert the text, then do a :bufdo to apply it to all open files.

Example:
Open all files in vim, then record a macro in register x with qx, go to the top of the file with gg, search for the end of the head-tag with /\/head, open a line before that with O (big O), then type or paste your text as usual, write your file with :w, end the recording with q.

After that, run :bufdo normal @x to apply it to all open buffers.

Duddle
I'll try that. Can you give me an example?
janoChen
So do I do :bufdo after or before?
janoChen