You are not logged in.
Pages: 1
Is there some config line I need to get decent auto indentation in (x)html files in Vim?
Atm there is no auto-indentation whatsoever while typing, and 'gg=G' does absolutely nothing (which is expected from the first fact, I realise =P).
Cheers.
- KD
Offline
Try this in your .vimrc :
set autoindent
set smartindent
set shiftwidth=4
If it is not already the case ....
Cheers,
Chicha
Offline
Try this in your .vimrc :
set autoindent set smartindent set shiftwidth=4
If it is not already the case ....
Cheers,
Chicha
Thanks for the response, Chicha. Sadly I already have those.
For anyone responding, my .vimrc can be seen in this thread.
- KD
Offline
Arff ...
I have no idea then, sorry
Did you try vim.org for a script/tips ? we never know ...
Offline
Arff ...
I have no idea then, sorry
Did you try vim.org for a script/tips ? we never know ...
Yeah, I looked but found nothing relevant I searched for 'html', 'xhtml', 'indent', and 'format', and nothing useful came up.
- KD
Last edited by KomodoDave (2007-05-04 14:01:46)
Offline
I did too and same result, unfortunatly ...
Can you post a sample xhtml file which cause indentation problems in your vim (if it is not condidential of course ) so that I try with my vim and see if it is a config problem or a vim problem ?
Offline
Hmmmm xhtml indentation works for me. I'm not sure what I'm doing differently.
Offline
Hmmmm xhtml indentation works for me. I'm not sure what I'm doing differently.
I feel enlightened *cough* =P I haven't changed much from your .vimrc; i've only added stuff, and nothing that directly relates to indentation, afaik. Grr...
- KD
Offline
I did too and same result, unfortunatly ...
Can you post a sample xhtml file which cause indentation problems in your vim (if it is not condidential of course ) so that I try with my vim and see if it is a config problem or a vim problem ?
et voila:
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta name="keywords" content="komodo dave, komododave, kd blog, kdblog"/>
<meta name="description" content="Articles and blog by KomodoDave" />
<meta name="revised" content="N David Brown, 29/04/2007" />
<meta name="refresh" content="5" />
<title></title>
<link rel="stylesheet" type="text/css" href="stylesheets/main.css" />
<script src="javascript/head_script.js"></script>
</head>
<body>
<div id="title_links">
<img class="title_links" name="title_link" id="title_links_about" src="images/title_links_about.png"/>
<img class="title_links" name="title_link" id="title_links_articles" src="images/title_links_articles.png"/>
<img class="title_links" name="title_link" id="title_links_blog" src="images/title_links_blog.png"/>
</div>
<img id="title_kd" src="images/title_kd.png"/>
<img id="title_bars" src="images/title_bars.png"/>
</body>
</html>
Last edited by KomodoDave (2007-05-04 23:58:01)
Offline
copy, pasta, gg=G
http://img205.imageshack.us/img205/3137 … entfw0.png
Offline
copy, pasta, gg=G
http://img205.imageshack.us/img205/3137 … entfw0.png
I guess it must be something in my .vimrc then (linked above) O_o I'll scour it and see what comes up.
Cheers for posting, phrak.
- KD
Offline
Start vim with the -V option to see if any indent type files are sourced.
In your vimrc you set the filetype of *.html files to htmlm4. This shouldn't be what is causing the problem, but you might try commenting that line out just to be sure.
Offline
Start vim with the -V option to see if any indent type files are sourced.
In your vimrc you set the filetype of *.html files to htmlm4. This shouldn't be what is causing the problem, but you might try commenting that line out just to be sure.
Here's vim -V myfile | grep sourcing
sourcing "/usr/share/vim/syntax/php.vim"
line 86: sourcing "/usr/share/vim/syntax/html.vim"
line 165: sourcing "/usr/share/vim/syntax/javascript.vim"
finished sourcing /usr/share/vim/syntax/javascript.vim
line 190: sourcing "/usr/share/vim/syntax/vb.vim"
finished sourcing /usr/share/vim/syntax/vb.vim
line 200: sourcing "/usr/share/vim/syntax/css.vim"
finished sourcing /usr/share/vim/syntax/css.vim
finished sourcing /usr/share/vim/syntax/html.vim
line 109: sourcing "/usr/share/vim/syntax/sql.vim"
line 37: sourcing "/usr/share/vim/syntax/sqloracle.vim"
finished sourcing /usr/share/vim/syntax/sqloracle.vim
finished sourcing /usr/share/vim/syntax/sql.vim
finished sourcing /usr/share/vim/syntax/php.vim
line 17: sourcing "/usr/share/vim/ftplugin/php.vim"
line 20: sourcing "/usr/share/vim/ftplugin/html.vim"
finished sourcing /usr/share/vim/ftplugin/html.vim
finished sourcing /usr/share/vim/ftplugin/php.vim
It uses /usr/share/vim/syntax/html.vim and ..../ftplugin/html.vim, by the looks of it.
I tried commenting out that line, thank you nj, but it sadly made no difference.
- KD
Offline
Run ':set ft?' in vim to make sure the filetype is not set to php. If it is php, you can run ':verbose set ft?' to see where the filetype was last set.
Do you have anything in your ~/.vim/{after,ftdetect,ftplugin} folders? Try renaming your .vim folder to make sure no plugins are the problem.
Offline
Run ':set ft?' in vim to make sure the filetype is not set to php. If it is php, you can run ':verbose set ft?' to see where the filetype was last set.
Do you have anything in your ~/.vim/{after,ftdetect,ftplugin} folders? Try renaming your .vim folder to make sure no plugins are the problem.
Clearly you know your vim commands ':set ft?' gave me 'php', and the ':verbose' command gave me
filetype=php
Last set from /usr/share/vim/filetype.vim
I've tried renaming each of my folders in ~/.vim/ sequentially, testing whether any plugins are causing the problem. They don't seem to be though.
Is it possible some plugin I installed at one point in the past overwrote /usr/share/vim/filetype.vim, and that's what's causing the problem? I'll try reinstalling vim now and get back to you.
Edit: Nope, still no joy >_< I tried reinstalling vim, having removed it first, and everything's still the same
- KD
Last edited by KomodoDave (2007-05-05 01:28:05)
Offline
I'm such an idiot. I was trying to indent in my file 'index.php', which of course is going to produce a filetype of php, lol. Is .phtml a php/html hybrid? Is there a syntax file for html and php combined?
Sorry, and thanks a lot for your advice; that ':set ft?' is a useful tidbit to remember, nj.
- KD
Offline
Looking at filetype.vim, the only reason it sets the filetype to php is due to the filename being *.php or *.php[0-9]. Is this the case for your file?
If not, then you can use an autocmd similar to that htmlm4 line to change the filetype to xhtml.
Edit:
Beaten to the answer
I've never done much with php, so I'm not sure how dual html/php indenting works. There is a phtml type, but from a quick test it doesn't seem to indent the html at all.
By the way, the ? in the :set command tells you the current state of a variable and is not specific to just the filetype. So you can use, for instance, :set tabstop? to see what the tabstop is.
Happy vimming
Last edited by nj (2007-05-05 02:00:19)
Offline
^^ yeah, it's .php, lol. Oops =S
I'll put in an autocmd to use the html syntax file for .php files.
Thanks for all your help; it's very much appreciated.
- KD
Offline
Pages: 1