How do I remove the last six characters of every line in Vim?
vim
Solution
You could use `:%s/.\{6}$//` to literally delete 6 characters off the end of each line.
The `:` starts ex mode which lets you execute a command. `%` is a range that specifies that this command should operate on the whole file. The `s` stands for substitute and is followed by a pattern and replace string in the format `s/pattern/replacement/`. Our pattern in this case is `.\{6}$` which means match any character (`.`) exactly 6 times (`\{6}`) followed by the end of the line (`$`) and replace it with our replacement string, which is nothing. Therefore, as I said above, this matches the last 6 characters of every line and replaces them with nothing.
Problem
I have the following characters being repeated at the end of every line: ``` ^[[00m ``` How can I remove them from each line using the Vim editor? When I give the command `:%s/^[[00m//g`, it doesn't work.