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
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.
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.
精彩评论