What is the most concise code you can write for dos2unix and unix2dos (CR/LF conversion) using Python 2.6+? These functions must accept a filename argument and do an in-place replacement.
Is there a best practice for preventing mixed eol-styles in a subversion repository.
I know that svn:eol-style=native can be set as an auto-prop, but I would have to ensure that it was set for all committers. I'm also reluctant to do a retrospective, repository-wide change of svn:eol-style if there is a less invasive solution.
I'm currently working on a project where we'd like to allow a user to export their data to CSV. Some of the data we present has multiple values for a single cell, and so we use the standard CSV method of putting each value on its own line:
Column A, Column B, Column C
Value A, "Value B1
Value B2", Value C
Most of the time this works fine, but…
I am editing a LaTeX file with vim. When I am in the \begin{itemize} environment, is there any way to tell vim to autoinsert \item whenever I open a new line?
Another noob regex problem/question. I'm probably doing something silly so I thought I'd exploit the general ingenuity of the SO regulars ;)
Trying to match newlines but only if they occur within either double quotes or single quotes. I also want to catch strings that are between quotes but contain no newlines.
Okay so there's what i got, with…
I want to write text files with DOS/Windows line endings '\r\n' using python running on Linux. It seems to me that there must be a better way than manually putting a '\r\n' at the end of every line or using a line ending conversion utility. Ideally I would like to be able to do something like assign to os.linesep the separator that I want to use…
I'm currently using the following to split a file into words - Is there some quicker way?
while read -r line
do
for word in $line
do
words="${words}\n${word}"
done
done
Not sure what could be the problem.
I'm dumping data from an array $theArray into theFile.txt, each array item on a separate line.
$file = fopen("theFile.txt", "w");
foreach ($theArray as $arrayItem){
fwrite($file, $arrayItem . '\n');
}
fclose($file);
Problem is when I open theFile.txt, I see the \n being outputted literally.
Also if I…
I want to write text files with DOS/Windows line endings '\r\n' using python running on Linux. It seems to me that there must be a better way than manually putting a '\r\n' at the end of every line or using a line ending conversion utility. Ideally I would like to be able to do something like assign to os.linesep the separator that I want to use…
Hey !
I started doing a new project in PHP / MySql . The Aim of this project is to manage articles for a magazine that i am the editor of.
So the content of the articles, i decided i would store with the "TEXT" column type of MySql
Now when i retrieve this column and print it with echo, the newlines are not there. Its all on the same line. …
In a DrScheme project, I'm using a MrEd editor-canvas% with text% and inserting a string from a literal in a Scheme file. This results in an extra blank line in the editor for each line of text I'm trying to insert.
I've tracked this down to the apparent fact that string literals from outside modules are getting extra line breaks. Here's a full…
I am looking for the best br2nl function. I would like to replace all instances of <br> and <br /> with newlines \n. Much like the nl2br function but the opposite.
I know there are several solutions in the PHP manual comments but I'm looking for feedback from the SO community on possible solutions.
When I'm using PDcurses and I try to have a while loop exit when the enter key is pressed with while(key != KEY_ENTER), the while loop never exits. However, when I try to have the same loop exit with while((char)key != '\n'), it exits successfully whenever I pressed enter. What's the difference?
I have a ToString() method that looks like this:
public override string ToString()
{
return "something" + "\n" + "something";
}
Because there are several "something"'s and each is long, I'd like to see
something
something
Sadly, I'm seeing
"something\nsomething"
Is there a way to get what I want?
I have a certain text in Java, and I want to use pattern and matcher to extract something from it. This is my program:
public String getItemsByType(String text, String start, String end) {
String patternHolder;
StringBuffer itemLines = new StringBuffer();
patternHolder = start + ".*" + end;
Pattern pattern =…
Dear reader,
I'm faced with a bit of an issue. The scenario is that I have a multi-line text box and I want to put all that text into one single string, without any new lines in it. This is what I have at the moment:
string[] values = tbxValueList.Text.Split('\n');
foreach (string value…
Using Visual Studio 2010 Professional, I have a ToString() method that looks like this:
public override string ToString()
{
return "something" + "\n" + "something";
}
Because there are several "something"'s and each is long, I'd like to see
something
something
Sadly, I'm seeing
"something\nsomething"
Is there a way…
I have some xml that I manually construct in a function that is something like:
$xml = "<myxml>";
$xml .= "<items>";
$xml .= "<item1>blah</item1>";
$xml .= "</items>";
$xml .= "</myxml>";
When I output the string though I'd like the newlines to be present. How can I add this to the string…
Is there any way of telling istream to keep going until it hits \n instead of normal white space and with out the use of getline and also keeping any format options in the stream?
Thanks.
I have a file where I want to convert "\n" to " " and "\n\n" to "\n".
For example:
I
had
a
toy
.
It
was
good
.
Becomes:
I had a toy .
It was good .
Does anyone have a Unix one-liner for this operation?
I would like to insert a line break into the first space between words in a string variable. Here is my code so far:
<cfset myPosition = find(" ", #myVar#)>
<cfset lineBreak = Chr(13)&Chr(10)>
<cfset myVar = insert(#lineBreak#, #myVar#, #myPosition#)>
What am I doing wrong?
In a DrScheme project, I'm using a MrEd editor-canvas% with text% and inserting a string from a literal in a Scheme file. This results in an extra blank line in the editor for each line of text I'm trying to insert.
I've tracked this down to the apparent fact that string literals from outside modules are getting extra line…