开发者

vim - html in php files: how to change tab size for html only

开发者 https://www.devze.com 2023-03-28 16:27 出处:网络
How to change the indent, tab size for HTML markup within PHP files? I dont want to change the indent size for php code. Desired tab sizes: HTML - 2, PHP - 4

How to change the indent, tab size for HTML markup within PHP files? I dont want to change the indent size for php code. Desired tab sizes: HTML - 2, PHP - 4

so it looks like this:

<dl>
  <dt>Term</dt>
  <dd>
    <span>Definition</span>
  </dd>
  <dd>
<?php 
if ($a > $b) {
 开发者_开发百科   echo $a;
    while ($c) {
        echo $d; 
    }
}
?>
  </dd>
</dl>


If this is to be done one time, I'd use (if there is not much code to be fixed) block-wise edit:

Ctrl+V I Space Space Esc


autocmd FileType html setlocal shiftwidth=2 tabstop=2
autocmd FileType php setlocal shiftwidth=2 tabstop=4

Add following code to your .vimrc file.

0

精彩评论

暂无评论...
验证码 换一张
取 消