Reputation: 55283
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
Upvotes: 0
Views: 75
Reputation: 190
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.
Upvotes: 0
Reputation: 56595
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.
Upvotes: 2