Re: sed ignorer une occurence
Le 1 juin 2023 benoit a écrit :
> A certains endroits ça mets deux espaces, je vais chercher pourquoi...
> Mais en attendant de comprendre, je retourne au début et repasse une fois pour les virer et c'est bon ! ;-)
tu dois avoir des espaces en fin de ligne qui trainent, donc peut-être,
pour ne pas supprimer des double espaces qui seraient valides :
(defun ConvertRet ()
"Convertit un retour à la ligne."
(interactive)
(let (
(p1 (region-beginning))
(p2 (region-end)))
(save-restriction
(narrow-to-region p1 p2)
(goto-char (point-min))
(while (re-search-forward "-\\\n" nil t)
(replace-match "" nil t))
(goto-char (point-min))
(while (re-search-forward " \\\n" nil t)
(replace-match " " nil t))
(goto-char (point-min))
(while (re-search-forward "\\([^.]\\)\\\n" nil t)
(replace-match (concat (match-string 1) " ") nil t))
)))
(defun indentBuffer ()
"Convertit un texte jutifié avec des retours à la ligne."
(interactive)
(mark-whole-buffer)
(ConvertRet))
Reply to: