1

This is what I have in my vimrc:

if empty(glob('~/.vim/autoload/plug.vim'))
  silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
    \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
  autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif

call plug#begin('~/.vim/plugged')
Plug 'junegunn/vim-plug'
Plug 'Valloric/YouCompleteMe', { 'do': './install.py' }
call plug#end()

filetype plugin indent on
set smartcase
set incsearch
set hlsearch
set smartindent
set wildignore=*.pyc
set number
set nowrap

let g:netrw_list_hide= '.*\.pyc$'
let g:html_indent_inctags = "html,body,head,tbody,div"

Now if I have a name.html file that starts with DOCTYPE and has all the html body etc tags the autoindent works correctly.

But if I have another file.html in which I have written different things many of which not being correct html format and then I select a specific part of the text that is proper html and then press = it doesn't work. Here is the part of file that is pure html and I can't autoindent:

 <ul class="pagination">
   <li class="page-item"><a class="page-link" href="#">Previous</a></li>
     <li class="page-item"><a class="page-link" href="#">1</a></li>
       <li class="page-item"><a class="page-link" href="#">2</a></li>
         <li class="page-item"><a class="page-link" href="#">3</a></li>
           <li class="page-item"><a class="page-link" href="#">Next</a></li>
           </ul> 

This is what I do to select that part when I'm in the normal mode:

152GV158G=

Any idea on where the problem is coming from and how to fix it!?

  • You are using a plugin for html, right? Which one? My guess: it cannot recognize the format in the file you mention. You should run your file through tidy-html. That should solve your problem – mike Dec 18 '17 at 9:34
  • @mike I'm using nth else than what is shown in my vimrc. My question is why does it work fine if the file is a complete html file and why does it not work if just a part of it is html and still the name of the files ends with .html – yukashima huksay Dec 18 '17 at 10:36
  • What happens, when you just :set filetype=html and then try to indent? You should have a filtetype plugin for html (thats included), its just not activated, because you have a mixed html file – mike Dec 18 '17 at 11:02
  • @mike didn't work. – yukashima huksay Dec 18 '17 at 11:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.