VIM - html and javascript
When editing html files we at times want to tidy things up.
vim as such might have out of box indentation for files identified by extension like java, c.
Below can help in case indentation is not setup for html.
add line to .vimrc:
filetype indent on
Now edit file and see if html tags start to indent well as you type.
if above does not work still then try adding below lines also:
set smartindent
If it still does not work in edit window of html file from command mode
:set filetype=html
Now to indent when you do from vim normal mode gg=G it will indent file.
For javascript in style tag need to install jsbeautifier plugin (python).
pip install jsbeautifier
vim as such might have out of box indentation for files identified by extension like java, c.
Below can help in case indentation is not setup for html.
add line to .vimrc:
filetype indent on
Now edit file and see if html tags start to indent well as you type.
if above does not work still then try adding below lines also:
set smartindent
If it still does not work in edit window of html file from command mode
:set filetype=html
Now to indent when you do from vim normal mode gg=G it will indent file.
For javascript in style tag need to install jsbeautifier plugin (python).
pip install jsbeautifier
if it fails then from pypi download tar.gz and run
python setup.py install
It should install without error then test from vim.
Open file which has script tag and highlight it and get into command mode. The command line already has some character. To end of it type !js-beautify and it will indent region.
From shell command prompt you can test if js-beautify is installed.
which js-beautify
Comments
Post a Comment