Tag Info

Hot answers tagged

20

Or does it know when its output is being piped to another command, and format its output differently in this case? Yes. From the full manual (available through info ls if the documentation is installed): If standard output is a terminal, the output is in columns (sorted vertically) and control characters are output as question marks; otherwise, ...


20

The convention for Unix text files is that every line is terminated by a newline, and that newlines are line terminators, not line separators. When Vim saves a buffer as a file, it terminates every line with the end-of-line sequence for that file format, which for Unix is a newline. See :help 'fileformat' If you're using Unix text-processing tools, it's ...


17

There is: dos2unix


14

Here's a way that utilizes bash parameter expansion and its IFS special variable. $ System=('s1' 's2' 's3' 's4 4 4') $ ( IFS=$'\n'; echo "${System[*]}" ) We use a subshell to avoid overwriting the value of IFS in the current environment. In that subshell, we then modify the value of IFS so that the first character is a newline (using $'...' quoting). ...


11

In recent versions of Vim there's a 'listchars' setting that lets you specify which characters should be used for the EOL and TAB characters, and for trailing spaces. You could: set listchars=eol:$,tab:\[SPACE]\[SPACE] ...to display eol chars specially without collapsing tabs (type a space character, not [,S,P,A,...). I don't know of anything ...


11

You could install pcregrep (available in most distro repositories) - which is grep using the pcre library, which does "Perl Compatible Regular Expressions". It has a command line option -M which allows you to do multiline searches - from the man page: "The output for any one match may consist of more than one line." So you could do pcregrep -M ...


10

I remember that Macs always used to use CR despite Unix using LF and Windows using CR+LF Your memory is from the good old times though: Mac OS X, as POSIX-compliant Unix uses the typical Unix LF. CR is a relict from the "classic" Mac OS, it's not used anymore. For example, check the manpage of unix2dos (emphasis mine): In DOS/Windows text files a ...


10

The new line character with the echo command is "\n". Taking the following example: echo -e "This is line 1\nThis is line 2" Would result in the output This is line 1 This is line 2 The "-e" parameter is important here.


10

You can use printf to print each array item on its own line: $ System=('s1' 's2' 's3' 's4 4 4') $ printf "%s\n" "${System[@]}" s1 s2 s3 s4 4 4


9

ls detects it when you pipe its output. You can see it in the documentation: If standard output is a terminal, the output is in columns (sorted vertically) and control characters are output as question marks; otherwise, the output is listed one per line and control characters are output as-is. If you want each file in the output to be placed on a ...


9

This happens when the EOL control characters are not correct. Windows represents newlines with the carriage return + line feed. In Notepad++, you can check for these characters by selecting: View > Show Symbols > [x] Show End of Line You need to modify your script so your data is formatted like this:


8

Use the "Extended" setting in the Replace window (not "Regular expression": I'm sure there's a way to do it with Regular expression, but using "Extended" works fine). Enter ".pPrev.\r\n" in the "Find what" field, and leave the "Replace what" field blank. This will include the \r\n characters in the match and delete the whole line.


7

The correct way to print is echo "$ifc"


7

I think this does what you want: make sure there is an empty line at the end of the file, then join every paragraph (terminated by an empty line). G:a . :g/^./ .,/^$/-1 join Explanation: first go to the end of the file and append an extra empty line with :a (maybe there's a more elegant way to do that; interactively, you can replace the first three lines ...


7

I think \n moves the needle down, and \r moves the needle to the beginning of a line (left align)? I'm not sure, though This is true, more or less, but mostly a historical curiosity. Originally, linefeed (LF) was used to advance the paper by one line on printers and hardcopy terminals (teleprinters); carriage return (CR) returned the print head to the ...


6

CR and LF The American Standard Code for Information Interchange (ASCII) defined control-characters including CARRIAGE-RETURN (CR) and LINE-FEED (LF) that were (and still are) used to control the print-position on printers in a way analogous to the mechanical typewriters that preceded early computer printers. Platform dependency In Windows the traditional ...


6

Go to Find (Ctrl + F) -> tab Replace -> click More... -> Special -> End of paragraph. The symbol is ^p. You can use it in both directions. I have MS Office 2007, but it should work in older versions too.


5

Use the ^ character as an escape: command -option:text^ whatever I'm assuming you're using cmd.exe from Windows XP or similar. This is not actual DOS. If you are using actual DOS (MS-DOS, Win3.1, Win95, Win98, WinME), then I do not believe there is an escape for newlines. You would need to run a custom shell. cmd.exe will prompt you for "More?" ...


5

reopen DOS-formated text file in UNIX formart: :e ++ff=unix you will see ^M(\r) at the end of line. if you want display ^M in hex: :set dy=uhex


5

According to Helixoft: Multiline Search and Replace in Visual Studio you can enable Regular Expressions and then use \n to indicate a new line.


4

Notepad2 Search mode: Regular expression search Replace with: \r\n Notepad++ Search mode: Extended (or Regular expression) Replace with : \r\n


4

Notepad++ Press Ctrl + H. Use the following settings: Find what: ; (with one trailing space) Replace with: \r\n Search Mode: Extended Wrap around: checked Click Replace All. \r\n symbolizes a Windows newline, i.e., carriage return character followed by a linefeed character. Word 2010 Press Ctrl + H. Use the following settings: Find ...


3

You will have to press Enter after the last line. That extra blank line in Notepad++ is just visible in the editor. It isn't really putting any data in the output file. (Besides the EOL character that you want.) P.S. It doesn't matter whether you use Windows, Unix or Mac line-endings. The behavior of Notepad++ is the same for all three. You will have to add ...


3

Try this: function! EnterEnter() if getline(".") =~ '^\s*\(//\|#\|"\)\s*$' return "\<C-u>" else return "\<CR>" endif endfunction imap <expr> <CR> EnterEnter()


3

Depending on the OS, it uses special characters Linefeed and/or Carriage Return to denote a newline (DOS uses both, Linux uses just Linefeed, and I think, but am not certain that OSX uses just Carriage return). The characters associated with Carriage return are 0x0D and Linefeed is 0x0A.


3

Vim will detect the original fileformat (among those configured in 'fileformats'), and write with the same one. The only way for Vim to switch (e.g. from Unix to Windows-style) is via an explicit :setlocal fileformat=dos. It's unlikely that you have that in your config; :verbose setl ff? could tell you. I wouldn't be too concerned about the Git diff ifself ...


3

The nice thing about :global is that it handles added and removed lines very well. So, we can use it to apply the :join command to all lines: :global/^/join An alternative would be a recursive macro.


3

You have to hook into the command-line; either when executing it via <CR>, or immediately when you enter a \n. With :help c_CTRL-\_e, you can evaluate a function and modify the command-line. Here's a demo that you can build upon and improve (the check for a substitution is simplistic right now): cnoremap n <C-\>eTranslateBackslashN()<CR> ...


3

When this issue comes up again, issue the following command in the terminal: reset This should reset your terminal to defaults and hopefully resolve your problem.



Only top voted, non community-wiki answers of a minimum length are eligible