views:

130

answers:

2

Is there a keyboard shortcut to format code within Notepad++ ? I'm mainly working with HTML, CSS and Python code.

For example:

<title>{% block title %}    {% endblock %}</title>      
<link rel="stylesheet" href="/media/style.css" type="text/css" media="screen" 
/>
    </head>

To:

    <head>
    <title>
        {% block title %}
        {% endblock %}
    </title>
    <link rel="stylesheet" href="/media/style.css" type="text/css" media="screen" />
    </head>

I remember Visual Studio doing it with CRTL+K+D and Netbeans having the feature too but can't find it within Notepad++, if it can even do it.

A: 

Here is a list of the available shortcuts in Notepad++.

If there is the functionality that you wish not available, you are able to define own macros and assign them to a custom shortcut (i am not used to use macros).

Thariama
I don't see a shortcut option there that formats code. As for a macro I have no idea how I'd go about that. Thanks anyway.
mongoose_za
macros are described here: http://stackoverflow.com/questions/362444/how-to-write-macro-for-notepad
Thariama
+1  A: 

Look for a function called "HTML Tidy". It should be somewhere under "Tools". It's not a keyboard shortcut, but perhaps you can map that command to a keyboard shortcut in some way.

EDIT: Ah, here it is: TextFX -> HTML Tidy -> Tidy: Reindent XML

Remember to have the HTML code selected before you do this.

gablin
Hey there, I used that and it works nicely with only HTML. With django tags however seems to just erase them or not format them properly. It's the closest so far. Ta for the tip.
mongoose_za
been trying out your suggested method for a while now and it's close but still not quite what I need. I guess the Django tags are what really seem to through the formatter out.
mongoose_za
@mongoose_za: Hm, strange that Notepad++ handles those tags differently. Oh well.
gablin