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

rdbms - what exactly the undo information lives in oracle? -

bash - How do you programmatically add a bats test? -

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