Home > programming > Multi-Line Strings and Text Editors

# Multi-Line Strings and Text Editors

March 30Hits:2

PHP conveniently allows two main methods of using multi-line strings, where a string constant is broken over many lines. However, it can be hard to find a syntax highlighting text editor that will correctly highlight multi-line strings in PHP.

When I was switched text editors recently, support for multi-line strings when syntax highlighting was high on my list of required features.

I find multi-line strings convenient for writing SQL, as writing a non-trivial SQL query on one line does not make for very readable code.

Here are two examples of multi-line strings in PHP. The first is simple a quoted string split over multiple lines.

 $sql = " SELECT product.productid, product.title FROM product WHERE product.type='boardgame' "; This next example uses heredoc syntax, which allows you to specify a token to end the string with. $sql = SELECT product.productid, product.title FROM product WHERE product.type='boardgame' ENDOFSTRING;

The text editor I now use is Syn, which supports multi-line quoted strings but not heredoc syntax. Given the choice, I would rather use quoted strings than heredoc.

Here are all of the editors I evaluated.

Syn can highlight multi-line strings, but I found a couple of bugs in the latest version on their site, which is dated February 2004. Incidentally, if you email the developer, he'll be happy to give you a later build where the bugs are fixed. Alas, the fixes haven't made it into an official build.

I was very impressed with Notepad++ for its speed and responsiveness as well as for additional features such as code folding. Notepad++ does highlight multi-line strings correctly, but I couldn't find a way of showing a 'folder view' panel similar to that found in editors such as Syn, HTML-Kit, JEdit and Editplus. If anybody knows a way, please let me know.

TextPad does multi-line strings. What turned me off from this editor was that I couldn't find a folder view panel, and I couldn't specify bold or italic when setting up my syntax highlighting. The lack of bold and italic support is not as important to me.

JEdit does support multi-line strings in its syntax highlighting. It is a very impressive editor with a large range of plug-ins, but unfortunately I found it very slow to load. Responsiveness was one of my main criteria, and one of the reasons I chose the light-weight Syn for now.

UltraEdit looks great, but unfortunately does not have syntax highlighting for multi-line strings. According to their website, this will be supported in version 11.

Crimson editor is nice, but doesn't have support for multi-line strings. I don't know if this will be added in a future version.

HTML-Kit is a fantastic editor and used to be my editor of choice until relatively recently. While it supports heredoc syntax, it does not have support for regular multi-line strings in quotes. According to their FAQ, support will not be added and isn't available in a plugin due to architecture limitations. However, I'd definitely recommend this editor if you are not concerned with multi-line strings.

EditPlus has no support for multi-line strings, or for bold/italic when configuring syntax highlighting. Otherwise, it is very nice and has a folder view, and lots of nice extra features.

Why the need to support multi-line strings? It is just a personal preference of mine. There are alternative ways to achieve the same effect, however. For one, there is heredoc syntax, which is (to my surprise) supported by more editors that regular multi-line strings, though still not the majority. Other alternatives are workarounds such as the following:

• ### I have a multi-line string that I need to iterate over, but I'm not using bash. Advice?April 22

I'm using Dash because this is to run on my rPi. Bash is not an option. I'm rewriting a Bash script to work with Dash. I'm hoping to make it as POSIX-compliant (portable) as possible. The thing is it's difficult to find help on how to do loops throug

• ### How to use Powershell to filter out multi-lines group of text from a file?January 14

I have an error log that I would like to filter out all the known errors using Powershell. I know how to filter by line in powershell, but my problem is that the errors in the error log span multiple lines, but they always start with a date time. Eg:

• ### How to embed multi-line block of text in mathsOctober 18

What is the best way to embed a multi-line block of text, surrounded by curly braces, in maths mode? The best I can do is the following hack. ${\text{bounded WD-representations} \brace \text{of W_K over \overline{\mathbf{Q}}_l}}$ ------------

• ### How to copy and paste $n$ lines from a text editor to $n$ cells?June 21

If I copy from an external editor to Mathematica notebook a block of lines (with a code) line 1 line 2 ... line n then whole text is copied to a single cell. I can now use n-1 times "Divide cell" and manually create n new cells for each line. If

• ### How to insert javascript HTML code into Multi line Sharepoint 2007 text fieldNovember 3

I have a Javascript variable that contain HTML code as follows: <DIV>Hello World<BR>Welcome to SharePoint Stack Exchange</DIV> So, how do I insert it into the SharePoint 2007 Multi line text field (The meaning of a SharePoint 2007 Multi

• ### Why are line numbers in text editors and programming IDEs so often disabled by default?July 6

It feels like most environments for editing code have line numbers hidden by default. For example, Eclipse, IntelliJ, Oracle SQL Developer, and Vim all seem to have the default setting as not showing line numbers, and so developers must go into the s

• ### How do I do multi-line editing in Atom editor?August 14

I've been reading all over and I can't find anything on how to do this in Atom on Windows? And by multi-line editing, I mean being able to expand your cursor across multiple-lines, and being able to type, and that whatever you have typed replicates o

• ### Linux - Bash - Copying multi-line strings from source to terminalDecember 13

I am writing notes as I prepare a system so I have something to follow if/when I need to prepare another system. Also I am hoping to use these notes and implement into a puppet configuration at some point. I am trying to write multi-line bash command