Preserve Formatting When Pasting Text in PhpStorm

Maintaining structure and indentation when pasting code in PhpStorm


In the last article, we saw how to forward a user to edit their own page in the Manager after they successfully log in. In this one, we'll look at a quick shortcut that lets you preserve the formatting of text or code when pasting it into PhpStorm.

MODX logo

 

Preserve Your Formatting

If you're a regular use of PhpStorm, you probably know this, but for new users, this can save a lot of headaches.

I write these blog posts in PhpStorm in filenames ending with .html. PhpStorm is great at formatting code when you paste it into a .php document, but I often write test PHP and JS code and make sure it works before adding it to an article. If I paste that code into the .html files, it ends up being left justified, removing all indentation from the code. Each line remains as a separate line, but all of them are flush left.

The solution is to paste the code with Ctrl-Shift-Alt-V. That will preserve the formatting. You may still have to massage the code slightly, but it will be much easier than if it's all left justified.

You can highlight a section and move it right or left with tab and Shift-tab.

Coming Up

In the next article, we'll look at what causes the "Call to a member function get() on null" error and how to prevent it.

 


For more information on how to use MODX to create a web site, see my web site Bob's Guides, or better yet, buy my book: MODX: The Official Guide.

Looking for high-quality, MODX-friendly hosting? As of May 2016, Bob's Guides is hosted at A2 hosting. MODX will work fine at most hosting services, but having a MODX-friendly host can prevent a lot of frustration. Better yet, the A2 Solid-State-Drive servers are configured to handle the many Ajax and database calls made by MODX — especially the MODX Manager. My Manager runs about four times as fast as it did on my previous host. I particularly recommend the Swift package with the Performance Plus option.



Comments (0)


Please login to comment.

  (Login)