Unix uses 0xA for a newline character. Windows uses a combination of two characters: 0xD 0xA. 0xD is the carriage return character. ^M
happens to be the way vim displays 0xD (0x0D = 13, M is the 13th letter in the English alphabet).
You can remove all the ^M
characters by running the following:
:%s/^M//g
Where ^M
is entered by holding down Ctrl and typing v followed by m, and then releasing Ctrl. This is sometimes abbreviated as ^V^M
, but note that you must enter it as described in the previous sentence, rather than typing it out literally.
This expression will replace all occurrences of ^M
with the empty string (i.e. nothing). I use this to get rid of ^M
in files copied from Windows to Unix (Solaris, Linux, OSX).
Related Posts:
- How to pretty print XML from the command line?
- What is newline character — ‘\n’
- What are file descriptors, explained in simple terms?
- How to kill a process running on particular port in Linux?
- Display exact matches only with grep
- How to split a delimited string into an array in awk?
- Display exact matches only with grep
- What does it mean to write to stdout in C?
- What do ‘real’, ‘user’ and ‘sys’ mean in the output of time(1)?
- mkdir’s “-p” option
- wait(null) and wait(&status) C language and Status
- Shell script “for” loop syntax
- How to get the current directory in a C program?
- When could or should I use chmod g+s on a file or directory?
- How to Sum a column in AWK?
- Equivalent of *Nix ‘which’ command in PowerShell?
- What is the difference between SIGSTOP and SIGTSTP?
- How to colorize diff on the command line
- How to colorize diff on the command line
- How to read a file into a variable in shell?
- gpg decryption fails with no secret key error
- What is the difference between tar and zip?
- Display current path in terminal only
- What do the dup() and dup2() systems really do?
- What generates the “text file busy” message in Unix?
- Reasoning behind C sockets sockaddr and sockaddr_storage
- How can I send an email through the UNIX mailx command?
- Rename multiple files based on pattern in Unix
- What is the difference between a symbolic link and a hard link?
- SCP Permission denied (publickey). on EC2 only when using -r flag on directories
- binary operator expected error when checking if a file with full pathname exists
- What is special about /dev/tty?
- How do I do ‘mount –bind’ in /etc/fstab?
- How to read backward from the end of file in less or more?
- Getting the last match in a file using grep
- :wq! command in vim
- How do I pause my shell script for a second before continuing?
- How do I exit the Vim editor?
- In the shell, what does ” 2>&1 ” mean?
- How do I grep recursively?
- How do I grep recursively?
- What is the meaning of *nix?
- Where is my .vimrc file?
- In the shell, what does ” 2>&1 ” mean?
- How to make vim paste from (and copy to) system’s clipboard?
- How do I grep recursively?
- How can I check if a directory exists in a Bash shell script?
- Connect: Socket operation on non-socket
- What is the difference between read and pread in unix?
- SSH using python script
- How can I exclude directories from grep -R?
- How to copy to clipboard in Vim?
- Argument list too long error for rm, cp, mv commands
- Difference between using “chmod a+x” and “chmod 755”
- What is a bus error? Is it different from a segmentation fault?
- What does WEXITSTATUS(status) return?
- What does the line “#!/bin/sh” mean in a UNIX shell script?
- Extract file basename without path and extension in bash
- Which characters need to be escaped when using Bash?
- Vim Can’t Save File (E212)
- Vim Can’t Save File (E212)
- cp: missing destination file operand after
- How to download a file from server using SSH?
- Get Unix timestamp with C++
- What is cp: cannot stat error in Unix, I get this error when trying to copy thing from one folder to another
- What is Vim recording and how can it be disabled?
- How to use vim in the terminal?
- What does `set -x` do?
- Backspace key not working in Vim/vi
- Sorting data based on second column of a file
- vim and notepad++
- Variable interpolation in the shell
- Using ls to list directories and their total sizes
- How do I change tab size in Vim?
- How to go back (ctrl+z) in vi/vim
- What is the difference between MacVim and regular Vim?
- What is the recommended way to use Vim folding for Python code
- How to do case insensitive search in Vim
- What is `S_ISREG()`, and what does it do?
- Using grep and ls -a commands
- What’s a quick way to comment/uncomment lines in Vim?
- Vim clear last search highlighting
- Restarting cron after changing crontab file?
- Difference between sh and Bash
- How do I write stderr to a file while using “tee” with a pipe?
- What is the difference between the remap, noremap, nnoremap and vnoremap mapping commands in Vim?
- Vim Opening File E325 Attention Error
- cd into directory without having permission
- Changing case in Vim
- grep for special characters in Unix
- How do I get the current Unix time in milliseconds in Bash?
- Copying a large directory tree locally? cp or rsync?
- Can I nohup/screen an already-started process?
- When does /tmp get cleared?
- SSL Certificate Location on UNIX/Linux
- What does ‘set -e’ do, and why might it be considered dangerous?
- How to remove empty/blank lines from a file in Unix (including spaces)?
- How to forcibly close a socket in TIME_WAIT?
- Can you have more than one ~/.ssh/config file?
- How to check what port mysql is running on