Question

I want to use vi to get rid of all characters in the file that are not spaces and newlines. The syntax I know, removes the entire line which is not what I want, how can I edit it? Thanks.

:1,$g:[a-z|A-Z]:d
Was it helpful?

Solution

Global Substitution with Vim

With Vim, you can use a global substitution to remove everything but spaces and newlines. For example:

:%s/[^ \n]//g
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top