Sunday, November 20, 2016

HTML Indentation in VIM editor

fig 1: HTML Text before indentation
        To indent html content follow the below steps:
1) type esc + :filetype
 it will show you like this....

filetype detection:OFF  plugin:OFF  indent:OFF 

2) To turn on these services, type following three commands

i) Esc + :filetype plugin on
ii) Esc + :filetype indent on

 after this if you  type first command again, you will get following result

filetype detection:ON  plugin:ON  indent:ON

3) Esc + :set filetype=html
4) Esc + :set tabstop=3 (to make the tab space to 3.. default tab space is 8)
5) Esc + v (for visual) + select all text (using up or down arrow) + =

after the above steps you should get your code indented as below

fig 2: HTML Text after indentation
 Note that after doing indentation, if closed your file and reopened it you may not see indentation. It just because, above steps perform indentation on temporary basis.

If you want to keep changes for long time do following steps before above steps.

1) open a file named .vimrc
2) .vimrc file present in /home/user((avinash) in my case)/.vimrc
3) Delete all content of its, if any present and put following lines in it

filetype plugin on
filetype indent on
set filetype=html
set tabstop=3

save and close the file

4) copy this file in /root/ directory also

now you will get your indented code back every time you opens the file.

0 comments:

Post a Comment

    Translate

    Protected by Copyscape