Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I copied some data from an app and it has lots of ^Ds and ^Ms in it. I got rid of ^D with no problem using :%s/^D//g and I know I can remove ^M with something like :%s/^V^M//g but the problem is that I'm running on windows and ^V is Ctrl-V, which pastes data from the clipboard into gvim. How do I escape the paste function of ^V/ctrl-V in Windows for vim?

share|improve this question
up vote 6 down vote accepted

from :help CTRL-V-alternative:

                                                *CTRL-V-alternative* *CTRL-Q*
Since CTRL-V is used to paste, you can't use it to start a blockwise Visual
selection.  You can use CTRL-Q instead.  You can also use CTRL-Q in Insert
mode and Command-line mode to get the old meaning of CTRL-V.  But CTRL-Q
doesn't work for terminals when it's used for control flow.
share|improve this answer

Another Way, specific for ^M, would be to use :%s/\r//g since ^M is a carriage return.

share|improve this answer

To use your familiar MS Windows hotkeys for copy, paste etc. use the mswin.vim file as your configuration. Copy it from your install path to where your $HOME directory is, renamed to _vimrc. Type :echo $HOME to figure out where that is. Usually something like C:\Users\'username'. Restart gVim and your regular Windows Ctrl-V, Ctrl-C type of hotkeys should work.

See Where should .vimrc file be located on Windows 7? for a little more guidance.

share|improve this answer

Please use :%s/\r/**\r\l**/g. This will convert your carriage return to Windows style carriage return + line feed combination.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .