Tagged: vim

Vim: Removing ^M characters at the end of lines

Sometimes when editing files in both Windows and UNIX environments, a CTRL-M character is visibly displayed at the end of each line as ^M in vi. This is how to remove those annoying characters:

Disclaimer:
The information below is the result of my researches in the Internet and of my experiences. It is solely used for my purpose and may not be suitable for others.

:%s/^V^M//g (Ctrl-V)(Ctrl-M)

That's all!
-gibb

Vim: Switching All Text to UPPER case

Here is Vim key combination to switch all text to UPPER case:

Disclaimer:
The information below is the result of my researches in the Internet and of my experiences. It is solely used for my purpose and may not be suitable for others.

ggVGU

gg - Move to the beginning of the file.
V - Visual mode.
G - Select all text.
U - Switch to lower case.

Here is with search and replace function for the entire file: :%s/[A-Z]/\U&/g

Lastly, doing so for single letter: ~

That's a tilde or squiggly.

That's all!
-gibb

Vim: Switching All Text to lower case

One of the beauty of Vi (and Vim) is that with a few key combinations, you can control editing the entire text, a few words/lines, or few letters.

Disclaimer:
The information below is the result of my researches in the Internet and of my experiences. It is solely used for my purpose and may not be suitable for others.

Here is the key combination to switch all text to lower case: ggVGu

gg - Move to the beginning of the file.
V - Visual mode.
G - Select all text.
u - Switch to lower case.

Here is with search and replace function for entire file: :%s/[A-Z]/\L&/g

Lastly, doing so for single letter: ~

That's a tilde or squiggly.

That's all!
-gibb