Vi – Useful tricks

  Linux, Unix, vi

I use vi a lot on nix machines and there’s a lot of useful tricks you can do to edit files.


A good trick to get rid of those annoying ^M characters from a dos file is –




So you want to type :%s/  and then ctrl & v and without spaces ctrl & m//g


What you are doing here is just a regular expression, changing ^m for // (nothing – basically removing them from the entire file (g).