How do you insert a newline after every 80 characters in vim? -


i have long line of characters in vim. i'd insert newline after 80 characters. how do that?

:%s/.\{80}/&\r/g 
  • %: process entire file
  • s: substitute
  • .: matches character
  • {80}: matches every 80 occurrences of previous character (in case, character)
  • &: match result
  • \r: newline character
  • g: perform replacement globally

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

c# - How do I get the Nth largest element from a list with duplicates, using LINQ? -

jsp - "Sending a redirect is forbidden after the response has been committed" in sendRedirect -