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?
- Why does ENOENT mean “No such file or directory”?
- sudo: npm: command not found
- In the shell, what does ” 2>&1 ” mean?
- How do I grep recursively?
- How do I grep recursively?
- How to get the list of all installed color schemes in Vim?
- What is the meaning of *nix?
- Where is my .vimrc file?
- In the shell, what does ” 2>&1 ” mean?
- grep –ignore-case –only
- What are .a and .so files?
- How to make vim paste from (and copy to) system’s clipboard?
- How do I grep recursively?
- How to set default vim colorscheme
- How can I check if a directory exists in a Bash shell script?
- OS X: equivalent of Linux’s wget
- Connect: Socket operation on non-socket
- Connect: Socket operation on non-socket
- What is the difference between read and pread in unix?
- OS X: equivalent of Linux’s wget
- How do I use grep to search the current directory for all files having the a string “hello” yet display only .h and .cc files?
- How can I quickly delete a line in VIM starting at the cursor position?
- SSH using python script
- How can I exclude directories from grep -R?
- 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”
- Autocompletion in Vim
- What is a bus error? Is it different from a segmentation fault?
- What does WEXITSTATUS(status) return?
- Who can access a file with octal permissions “000” on Linux/UNIX?
- What does the line “#!/bin/sh” mean in a UNIX shell script?
- How to cat <
> a file containing code? - Extract file basename without path and extension in bash
- Given two directory trees, how can I find out which files differ by content?
- Which characters need to be escaped when using Bash?
- Vim Can’t Save File (E212)
- Vim Can’t Save File (E212)
- Move cursor to end of file in vim
- Diff command along with Grep gives “Binary file (standard input) matches”
- OSError – Errno 13 Permission denied
- What is cp: cannot stat error in Unix, I get this error when trying to copy thing from one folder to another
- cp: missing destination file operand after
- What is a bus error? Is it different from a segmentation fault?
- What can cause a “Resource temporarily unavailable” on sock send() command
- Why does using from __future__ import print_function breaks Python2-style print?
- How to download a file from server using SSH?
- What is the ASCII Code of ½?
- 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?
- What is the difference between “#!/usr/bin/env bash” and “#!/usr/bin/bash”?
- How do you make Vim unhighlight what you searched for?
- How to use vim in the terminal?
- How to use vim in the terminal?
- Why should we check WIFEXITED after wait in order to kill child processes in Linux system call?
- What does `set -x` do?
- Backspace key not working in Vim/vi
- Command to change the default home directory of a user
- Is there any simple way to benchmark Python script?
- Sorting data based on second column of a file