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 -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -