如何自动修复嵌套标记页面的缩进?

时间:2013-09-04 10:15:51

标签: javascript html emacs indentation

我在Emacs上得到了这个标记:

     <div class ...>
     <div class 2 ...>
<div class  ="modal fade" id="contactModal" tabindex="0" role="dialog">
           <div class    ="modal-dialog">
      <div class     ="modal-content">
  <form id   ="contactForm" class="form-horizontal" role="form" action="/contact"> 

是否有一种简单的方法可以通过层次结构在Emacs中格式化此代码,以便它更具可读性?,如下所示:

<div class ...>
     <div class 2 ...>
        <div class  ="modal fade" id="contactModal" tabindex="0" role="dialog">
           <div class    ="modal-dialog">
             <div class     ="modal-content">
                <form id   ="contactForm" class="form-horizontal" role="form" action="/contact"> 

1 个答案:

答案 0 :(得分:3)

M-x indent-region,通常绑定到<TAB>

适用于区域,因此您需要标记要缩进的文档部分,或C-x h标记整个缓冲区。

http://www.gnu.org/software/emacs/manual/html_node/elisp/Indentation.html