Using VIM to make acronyms?

vim

Solution

Assuming one name per line and that the words are space separated, the following works:

%s/\(\w\)\w*\ */\1/g

If you also want to capitalize each letter, add an up-case flag (`\u`):

%s/\(\w\)\w* */\u\1/g

The "very magic" version (see `:help /magic`):

%s/\v(\w)\w*\s*/\u\1/g

Problem

I have a file with lot of full names like .... ``` Light Machine Gun Statistical Analysis System etc ``` I want to capture the first character of every word in a line and want to make an acronym. For example Light Machine Gun would be LMG etc. I want to do it in VI editor record it as a macro and run it over the entire file.If anyone can help me that would be great? Thanks in advance.

Original source