Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [filetype-html]

Questions about the html file type

Filter by
Sorted by
Tagged with
1 vote
0 answers
31 views

Neovim - coc-html keeps inner html head and body tags indented

When I create filename.html file and type enter after the html tag, coc-html keeps inner content of html tag indented: <html> <head> <title>test</title> </...
whiteman808's user avatar
0 votes
0 answers
26 views

Strange auto indent in Javascript in HTML

When writing Javascript in HTML, vim insists on autoindenting like this: if( dur.match(/:/) ) { let xs = dur.split(":") if( xs.length > 3 ) ...
John Allsup's user avatar
0 votes
1 answer
1k views

How can I easily configure my Neovim to provide a vs code like javascript, html & CSS autocomplete, intellisence & highlighting?

I am new to Neovim & overwhelmed by the extremely huge number of ways to configure it, which take hours & have no surity of working for me, as I am using Neovim on my Android via termux (for ...
Ayush Samantaray's user avatar
0 votes
1 answer
72 views

What is the fastest way (lowest number of keys pressed) to add attribute to html tag?

For example, cursor shall be at "*": <Typography gutterBottom component="h1" variant="h4" color="text.primary" sx={{mb: 3}} > Che*ck this! <...
fl_'s user avatar
  • 11
0 votes
2 answers
233 views

Are there color variables for various programming languages? [closed]

I know, in Vim I can get a list with variables for color themes with the command :hi. But there are not the programming languages I need. Is there a way to get specific color variables for JavaScript, ...
Manny's user avatar
  • 1
0 votes
0 answers
59 views

How can I enable html autocomplete in .tmpl files?

I'm editing .tmpl files which are mostly html with some template language syntax inside {{ double curly braces }}. I'm using COC for autocompletion and I want to be able to use the autocomplete ...
hermancain's user avatar
1 vote
1 answer
130 views

Fold until next HTML tag

If my cursor is somewhere on an HTML tag, I’d like to invoke a custom command that folds until the closing tag if it finds it, else returns “0” or something. Should I make a function in VimScript or ...
Julius Hamilton's user avatar
3 votes
1 answer
106 views

Text Object for HTML/XML attributes, e.g. data-foo="bar baz caz"

Is there a plugin or a way to work with HTML text objects, e.g. Say the cursor is in one of the attributes below: <div data-foo="bar baz caz" class="a b c"> I wish to treat ...
run_the_race's user avatar
4 votes
1 answer
760 views

How do I delete a self closing html tag?

I'm trying to delete self closing html tags, like the img tag below. <div><img src='http://mypic.com/1.jpg' /></div> I've tried dit, dat, the tpope/vim-surround plugin, and other ...
Damien Sawyer's user avatar
1 vote
0 answers
247 views

vim doesnt recognize html in string in filetype php. same thing with php code in filetype html

Ive had no luck solving these issues for quite a while now. Problem1 When writing HTML inside a string in a file with filetype=php, the HTML is not recognized (i.e., it has no highlighting or indent). ...
Aiden Choi's user avatar
1 vote
2 answers
242 views

Vim HTML syntax highlight doesn't correctly identify comment endings consisting of minuses

if I edit the following block in vim: <div> foo </div> <!-----------------------------------------------------------> <div> bar </div> <!-------------------------------...
Dr Phil's user avatar
  • 111
0 votes
0 answers
186 views

`filetype plugin indent on` with `filetype=html` over-indents <script>

Since my last system update (I think), I have noticed this very annoying behavior. # vim foo.html # I go to insert mode, I type (no whitespace except newlines) <html> <head> ...
kubi's user avatar
  • 101
4 votes
1 answer
344 views

Syntax coloring is inaccurate for HTML files with CSS code in it

As you can see in the following screencast, when I open an HTML file with some CSS in it, there's some part of the file which does not show syntax coloring. Do you have experience of this? Is it ...
Enlico's user avatar
  • 2,214
1 vote
0 answers
377 views

Vim formatting in css

I am having a very difficult time formatting css in an html file. For example, here is how vim 'thinks' it should be formatted: That is, after the above css section, it gives it 8 indentations (??), ...
David542's user avatar
  • 2,455
4 votes
2 answers
367 views

Easiest way to go to start/end of html element

I seem to be using a hack approach to getting to the start of an html tag. For example: To get to my cursor to be on the t after the tag, I end up doing yit -- this yanks the component (which I don't ...
David542's user avatar
  • 2,455
1 vote
2 answers
977 views

Add matching html tag

In Textmate I can do something like when I have the following: <div> <p>new If I press optshift. it will add in the matching tag. So when I press it once, it will look like: <div&...
David542's user avatar
  • 2,455
2 votes
2 answers
701 views

Is there an instant way of editing matching inner tags?

In Vim, using the text object i>, you can edit an inner tag, and using the built-in matchit plugin, you can even use % to jump between matching opening and closing tags. Let's say you want to ...
lpf's user avatar
  • 43
0 votes
0 answers
136 views

Emmet expand only HTML tags

Hi I'm trying to make emmet expand only Html tags. For example div<c-y>, should be expanded to <div></div> But abc<c-y>, should not be expanded. By default emmet expands ...
builder-7000's user avatar
7 votes
2 answers
2k views

HTML - Wrap current tag inside another tag

I'm editing an HTML file, and my cursor is inside a tag, like this: <textarea class="code-area"></textarea> And I'm trying to wrap all of this tag inside a div tag, so that it'd be like ...
Amir Shabani's user avatar
0 votes
0 answers
129 views

vim disable behavior special tags (eg script)

When editing html, vim applies different rules when inside certain tags (like script/pre/style). I want to have the normal html rules when inside a script tag (using handlebars, and I don't write any ...
Hielke Walinga's user avatar
1 vote
0 answers
72 views

How to indent HTML5 with omitted closing tags properly?

I try writing some HTML5 with omitted closing tags in NVIM v0.3.4, and get this: <ol> <li>3 <li>4 <li>8 <li>9 </ol> This ...
Utkan Gezer's user avatar
2 votes
1 answer
290 views

vim html version of text document black on white

I'm trying to figure out a good workflow for printing source code and studying it. So far, the TOhtml function seems really useful for this purpose. I can create an html file with ease, open it in a ...
Greg Nisbet's user avatar
  • 1,849
1 vote
1 answer
135 views

How can I reindent/prettyify blocks of HTML code?

I've got a lot of HTML files, some of them with garbage indentation. How can I select a block, and then prettify/reindent the HTML within, adding in newlines where appropriate? I can install any ...
cjm2671's user avatar
  • 153
3 votes
6 answers
2k views

Indent on New Line between HTML/XML Tags

I'm currently using imap <silent> <C-c> </<C-X><C-O><C-X><Esc>F<i as per this post and this page to close <></> tags of any kind with <C-c&...
BodneyC's user avatar
  • 33
1 vote
0 answers
242 views

How to get html tag auto completion?

I can't seem to figure out how to implement auto tag completion for html. Is there a plug-in or something else you guys use that works? Is there just one thing I can download that will handle ...
user388297's user avatar
2 votes
1 answer
543 views

NeoVim indents each property:value in CSS

I have a style element in an HTML file. When I type, NeoVim continuously indents each successive line: In my Vim, it works correctly: My vimrc. I would be grateful for any suggestion. Thanks!
Zoltan King's user avatar
0 votes
1 answer
33 views

Automatic format: how to insert needed amount of spaces for vertical aligning? [duplicate]

Given code: <option id='Nicole' data-language='en-AU'>Australian English - female - Nicole</option> <option id='Russell' data-language='en-AU'>Australian English - female - Russell&...
Vitaly Zdanevich's user avatar
1 vote
1 answer
508 views

Question about autocompletion in Vim editor and html document

Why does one of Vim's autocomplete functions (ctrl+n) not work in html documents, while the other (ctrl+p) still does?
user642832's user avatar
1 vote
0 answers
68 views

Automatically create files based on expanding snippets?

when developing for web (in Vim) I'm always using the BEM methodology. I have identified that I always go through the same steps when adding a new block element, and I'm looking for ways to automate ...
eivindml's user avatar
  • 111
0 votes
1 answer
2k views

How to lint HTML file using the vim ale plugin?

Install ale with pathogen. cd ~/.vim/bundle git clone https://github.com/w0rp/ale.git My setting for ale in .vimrc. let g:ale_sign_column_always = 1 let g:ale_set_highlights = 0 The target html ...
showkey's user avatar
  • 1,140
4 votes
1 answer
2k views

How to change indenting for html files?

I code mainly in 2 languages python and HTML. I currently have the indenting configured for python in my neovim configuration file but I would to know how to make neovim auto-detect the type of file ...
KnownAsDon's user avatar
1 vote
1 answer
483 views

Enabling Syntax in Vim Creates Lag

I was trying to learn javascript the other day and was using emacs as I have been trying to learn emacs as well. But after sometimes my left wrist started to hurt(as one's does) so I switched to ...
3N4N's user avatar
  • 5,764
1 vote
0 answers
1k views

vim autoindent not working correctly

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/...
yukashima huksay's user avatar
8 votes
2 answers
545 views

How can I shift only inner contents of HTML element?

How can I quickly shift only inner contents of HTML tag X, when they are on separate lines to the opening and closing X tag? Example below: I want to shift only 2 lines with <p> tags when the ...
Robert Kusznier's user avatar
5 votes
2 answers
5k views

Expand <TAB> into 2 spaces when and only when editing HTML

My current configuration makes vim automatically expand TAB to 4 spaces for me: " Define tab as 4 spaces " Taken from http://stackoverflow.com/questions/1878974/redefine-tab-as-4-spaces set tabstop=4 ...
nalzok's user avatar
  • 195
3 votes
2 answers
1k views

How can I override a syntax keyword match?

I would like the html tag attribute id to be highlighted differently from the rest of the tag attributes. Like the Atom editor: Given this line from the html5.vim plugin syn keyword htmlArg ...
mhinton's user avatar
  • 133
2 votes
1 answer
597 views

Skip over closing html tag?

Plugins such as snipMate, emmet and many others allow me to quickly insert opening and closing html tags. For example by typing span and hitting the correct key (TAB for snipMate, <C-y>, for ...
GaryBishop's user avatar
4 votes
2 answers
131 views

Linewise inner tag without the tag lines?

An example HTML, with the cursor where the brackets are: <foo> <bar> baz quux [] </bar> </foo> I would like to outdent the text inside <...
Amadan's user avatar
  • 734
1 vote
0 answers
440 views

How to select unclosed tag and close it automatically?

Here is my html file already edited,there are two errors in it. <!DOCTYPE html> <html lang="zh-Hans"> <head> <meta charset="utf-8"> <link rel="stylesheet" type="...
showkey's user avatar
  • 1,140
0 votes
2 answers
309 views

How to insert tabs in key remapping?

I wrote the following in my .vimrc file in order to automate getting an HTML file set up. :imap html<tab> \<html><enter> \<tab><head><enter> .... and so on. ...
Addem's user avatar
  • 141
7 votes
0 answers
779 views

Mixed PHP and HTML indenting

Is there a way to have mixed indenting more like Sublime Text (left) than Vim does it? I would like the nested UL to follow the (line 10) to follow along the (main indentation).
Stijn De Lathouwer's user avatar
6 votes
5 answers
7k views

How to generate closing tags for HTML?

I want to do the following: When I insert an HTML tag (which is a sequence of text that starts with <tagname tag_attributes and ends with >), as soon as I press > to insert the > character, ...
Utku's user avatar
  • 305
1 vote
0 answers
323 views

Fix indentation after a multiline HTML tag

I have the following in .vimrc: set tabstop=2 softtabstop=-1 shiftwidth=0 expandtab filetype plugin indent on When I type the following in an HTML file: <html id="somethingverylong" > <...
Koterpillar's user avatar
6 votes
1 answer
2k views

How can I indent JavaScript that's within <script> tags in an HTML file?

If I am viewing a HTML file that someone else wrote, it often has <script> tags containing javascript, e.g. <!DOCTYPE html> <html> <head> </head> <body&...
the_velour_fog's user avatar
4 votes
3 answers
237 views

How do I open several FORTRAN files in Vim and save them as HTML files?

I know the separate answers. For example, To open several files: :n \**/*.f90 To save *.f90 file to HTML: :TOhtml and :wq. However, I don't know how to combine both of them.
Sharma SRK Chaitanya Yamijala's user avatar
8 votes
2 answers
1k views

How do I paste the same line of code X times but change one word in the line each time?

I'm writing HTML lists, and I want to be able to automagically paste 10 list items where the item text is the only thing that changes. I could accomplish this using PHP and then just copying the ...
Azmodeus's user avatar
3 votes
1 answer
741 views

Nested highlighting

In html eruby files, I would like to highlight the <% ... %> text in dark green only when it is inside double quotes. I.e. in in this example: I want it dark green instead of white. I know ...
Jerome Dalbert's user avatar
9 votes
2 answers
3k views

How to override a ftplugin

I am trying to use this plugin I have created a copy of xml.vim and named it html.vim. The problem is that the system ftplugin C:\Program Files (x86)\Vim\vim74\ftplugin\html.vim is loaded before the ...
Fonnae's user avatar
  • 227
4 votes
2 answers
340 views

Why does Vim load unrelated ftplugins?

When I open a file with .md extension, the filetype is set to markdown, as expected. But the ftplugin for HTML is also loaded as I can see since I have some insert mode mappings in there to auto-...
oarfish's user avatar
  • 1,277
3 votes
1 answer
638 views

How to auto fold html tags?

I am new to vim. I have a HTML code with lots of <li></li> with its content that could span multiply lines like below: <ol> <li> text text </li> ...
Lim Yan Chong's user avatar