Il suffit de mettre ce code dans supprbf.vim,
de faire un " :so supprbf" dans le fichier à nettoyer et d’appeler " :call SupprTextbf()". Notre fichier est ainsi nettoyé
function! SupprTextbf()
" while search("textbf","W")>0
execute "normal gg"
let found=0
while search("\\\\textbf","W")>0
execute "normal /\\\\textbf"
execute "normal d7l"
execute "normal ma"
execute "normal %"
execute "normal d1l"
execute "normal g`a"
execute "normal d1l"
let found=found+1
endwhile
" endwhile
echo "trouve et modifie: ".found." textbf"
endfunction
Edition
Et si on veut transformer en plugin, pour n’avoir qu’à taper SupprTextbf, c’est simple, il suffit de mettre dans votre /.vim/plugin/ un fichier contenant :
command! -nargs=0 -bar SupprTextbf call s:SupprTextbf()
function! s:SupprTextbf()
" while search("textbf","W")>0
execute "normal gg"
let found=0
while search("\\\\textbf","W")>0
execute "normal /\\\\textbf"
execute "normal d7l"
execute "normal ma"
execute "normal %"
execute "normal d1l"
execute "normal g`a"
execute "normal d1l"
let found=found+1
endwhile
" endwhile
echo "trouve et modifie: ".found." textbf"
endfunction