Search code examples
sortingvimtagsblock

Set Shortcut key for vim for Sorting all of the blocks of parent-child in .vimrc


I want to set shortcut key to my vim editor(like php storm) for sorting all of the blocks of parent-child(tags) in html or other programming languages!
For example:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
</body>
</html>

When i press ctrl+alt+z,My *.html file sorted like this:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
    </body>
</html>

Is it possible? If it's, what should i add to my .vimrc?
I remember when i used phpstorm, we had shortcut key for such things!


Solution

  • open the text in vim, try this:

    "if your file is with name foo.html this step can be skipped
    :set ft=html (press enter) 
    gg=G