简体   繁体   中英

Does anyone know of a text editor that allows you to indent highlighted chunks of code all at once?

I am extremely OCD when it comes to the layout of my code, and it's a pain to press the down arrow key and Tab a hundred times in a row. Does anyone use a text editor that has the function of indenting chunks of code at the same time? Such as, if I have this:

<div>
    <img src="blahblah" style="float:left" />
    <span>Hey it's a picture.</span>
</div>

<div>
    <img src="somephoto" style="float:right" />
    <span>Another picture</span>
</div>

...then I come back later and want to wrap both divs in another div, but it comes out like this:

<div>
<div>
    <img src="blahblah" style="float:left" />
    <span>Hey it's a picture.</span>
</div>

<div>
    <img src="somephoto" style="float:right" />
    <span>Another picture</span>
</div>
</div>

When I want it to look like this:

<div>
    <div>
        <img src="blahblah" style="float:left" />
        <span>Hey it's a picture.</span>
    </div>

    <div>
        <img src="somephoto" style="float:right" />
        <span>Another picture</span>
    </div>
</div>

Obviously this is a minor example, but when it comes to large files this becomes quite a hassle. I use Bluefish on Ubuntu and Notepad++ on Windows, and neither seem to come with the capability to indent a block of code all at once. What are your thoughts?

Any decent text editor, including Notepad++, can do this.

Select the lines and press Tab .

Yup go with Notepad++, its brilliant. Dont forget Shift + Tab too though, just as useful:)

Any decent text editor will have this functionality implemented into the editor.

They already mentioned Notepad++ , but there's also Geany which is available for Windows and Linux (Also has the ability for auto close tags), Droidedit for Android, Smultron for OS X users, and if you love web based apps like myself there's the CodeMirror JavaScript library.

If you want to indent a large selection of code use Tab . If you want to unindent/outdent a large selection of code use SHIFT + Tab .

Becomes very helpful. Also CTRL + F to find text, CTRL + H to replace text (Notepad++ has a replace all function, but Geany does not)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM