Questions tagged [filetype-html]
Questions about the html file type
62
questions
0
votes
0
answers
22
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 ) ...
0
votes
1
answer
327
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 ...
0
votes
1
answer
63
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!
<...
0
votes
2
answers
147
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, ...
0
votes
0
answers
41
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 ...
1
vote
1
answer
116
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 ...
3
votes
1
answer
91
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 ...
4
votes
1
answer
608
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 ...
1
vote
0
answers
229
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).
...
1
vote
2
answers
225
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>
<!-------------------------------...
0
votes
0
answers
177
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>
...
4
votes
1
answer
293
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 ...
1
vote
0
answers
366
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 (??), ...
4
votes
2
answers
340
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 ...
1
vote
2
answers
858
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&...
2
votes
2
answers
557
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 ...
0
votes
0
answers
126
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 ...
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 ...
0
votes
0
answers
115
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 ...
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 ...
2
votes
1
answer
282
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 ...
1
vote
1
answer
131
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 ...
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&...
1
vote
0
answers
233
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 ...
2
votes
1
answer
517
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!
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&...
1
vote
1
answer
507
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?
1
vote
0
answers
62
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 ...
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 ...
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 ...
1
vote
1
answer
470
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 ...
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/...
8
votes
2
answers
534
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 ...
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 ...
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 ...
2
votes
1
answer
576
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 ...
4
votes
2
answers
128
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 <...
1
vote
0
answers
436
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="...
0
votes
2
answers
298
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. ...
7
votes
0
answers
763
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).
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, ...
1
vote
0
answers
321
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"
>
<...
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&...
4
votes
3
answers
229
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.
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 ...
3
votes
1
answer
730
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 ...
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 ...
4
votes
2
answers
333
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-...
3
votes
1
answer
629
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>
...
10
votes
1
answer
437
views
Disabling partial HTML indentation in Vim
Caveat: I'm not a web developer.
That being said, there are rare occasions where I have to edit HTML. When I do, I've noticed a behavior in Vim that I don't like, and hope that I can change via ...