There's a problem occurring to me when executing BigQuery load data operation, a seem-to-be one-line string in Vim is actually treated as multiple lines when I examining into the error log.
After opening this file in Vim, we could see that there're several ^m marks in the string (if it's not visible, invoke `:set list` command). According to Vim's digraph table, this is the representation of CARRIAGE RETURN (CR).
A specific sum-up for \r and \n is as follows:
\r = CR (Carriage Return) // Used as a new line character in Mac OS before X
\n = LF (Line Feed) // Used as a new line character in Unix/Mac OS X
\r\n = CR + LF // Used as a new line character in Windows
Consequently, we should merely use \n as the new-line-character since almost all server are Unix-based, thus omitting \r when programming.
The way to replace \r\n with \n in Vim is to execute `:%s/\r//g`, whereas in CLI, we could apply `cat original_file | tr -d '\r' > remove_cr_file` to achieve the same effect.
Showing posts with label vim. Show all posts
Showing posts with label vim. Show all posts
Thursday, November 12, 2015
Wednesday, October 22, 2014
Keep the Original Format Of Text When Pasting to Vim (A.K.A. Turning Off Auto-Indent Feature Of Vim)
Sometimes when we paste some text to vim, we are more likely to retain the format of the text. But by default, vim will add indent to our text automatically, just like:

Solution 1:
Vim provides the ‘paste’ option to maintain the pasting text unmodified:
Solution 2:
Alternatively, vim offers the ‘pastetoggle’ option to turn ‘paste’ on and off by pressing a key. What we need to do is appending the following code in ~/.vimrc. Then we can just press key 'F2' to switch between ‘paste on’ and ‘paste off'.
© 2014-2017 jason4zhu.blogspot.com All Rights Reserved
If transfering, please annotate the origin: Jason4Zhu

Solution 1:
Vim provides the ‘paste’ option to maintain the pasting text unmodified:
:set paste :set nopaste
Solution 2:
Alternatively, vim offers the ‘pastetoggle’ option to turn ‘paste’ on and off by pressing a key. What we need to do is appending the following code in ~/.vimrc. Then we can just press key 'F2' to switch between ‘paste on’ and ‘paste off'.
set pastetoggle=<F2>
© 2014-2017 jason4zhu.blogspot.com All Rights Reserved
If transfering, please annotate the origin: Jason4Zhu
Subscribe to:
Posts (Atom)
