How do I remove the first 5 characters in each line in a text file?
I have a file like this:
4 Alabama 4 Alaska 4 Arizona 4 Arkansas 4 California 54 Can 8 Carolina 4 Colorado 4 Connecticut 8 Dakota 4 Delaware 97 Do 4 Florida 4 Hampshire 47 Have 4 Hawaii
I'd like to remove the number and the space at the beginning of each line in my txt file.
Click and hold down mouse button and select the first character of every line, and release. Press the DELETE key.
To delete one character, position the cursor over the character to be deleted and type x . The x command also deletes the space the character occupied—when a letter is removed from the middle of a word, the remaining letters will close up, leaving no gap. You can also delete blank spaces in a line with the x command.
:%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/^.....//
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With