How do I remove first 5 characters in each line in a text file using vi? How do I remove first 5 characters in each line in a text file using vi? unix unix

How do I remove first 5 characters in each line in a text file using vi?


:%s/^.\{0,5\}// should do the trick. It also handles cases where there are less than 5 characters.


Use the regular expression ^..... to match the first 5 characters of each line. use it in a global substitution:

:%s/^.....//


As all lines are lined up, you don't need a substitution to solve this problem.Just bring the cursor to the top left position (gg), then:CTRL+vGwlx