How can one close HTML tags in Vim quickly?
Check this out..
closetag.vim
Functions and mappings to close open HTML/XML tags
https://www.vim.org/scripts/script.php?script_id=13
I use something similar.
how can I find the close html tag quickly in vim?
You should be able to do this with the matchit plugin by typing % when your mouse is on the opening tag.
http://www.vim.org/scripts/script.php?script_id=39
Navigating HTML tags in Vim
The matchit.vim
macro gets you most of the way there, allowing you to move to a closing tag with %
as you would matching parens or braces. It's included in many Vim distributions including the standard download, but often not enabled by default.
http://www.vim.org/scripts/script.php?script_id=39
Delete text in between HTML tags in vim?
dit
will delete the text between matching XML tags. (it
is for "inner tag block".)
See :h it
and :h tag-blocks
.
vim how to fold an html tag
zf
indeed is the command to create a manual fold. For that to work, you need to have
:setlocal foldmethod=manual
(There will be an E350
otherwise.) The at
is a text object for a tag. You can check what it comprises by applying it to visual mode instead: vat
.
Note that manual folding is tedious; I'd recommend to use the syntax folding that comes with the built-in HTML syntax plugin. Just put
:setlocal foldmethod=syntax
in ~/.vim/after/ftplugin/html.vim
to enable it.
Also note that so far (as of Vim 7.4.1830), the default HTML syntax script only folds a multi-line tag itself, not the text between the opening and closing tag. To achieve that, you need a syntax extension, see here.
Vim Join opened Html tags to same line
You can utilize Vim's built-in inner tag text object to delete (dit
) or change (cit
) the whitespace / text inside the tags. (This assumes the tags are indented; without indent, you still need a J
to join the end tag to the current line.)
How to jump to beginning of Tag in HTML vim which has long html content
Using key sequence vatoESC will do it.
Check out the answer here: https://stackoverflow.com/a/10881471/5039312
best way to add comments in HTML Closing tag with VIM
Writing html the normal way is tedious. Instead, use the emmet style;
Emmet is a plugin for many popular text editors which greatly improves
HTML & CSS workflow.
It's vim plugin is emmet-vim;
emmet-vim is a vim plug-in which provides support for expanding
abbreviations similar to emmet.
You can achieve your desired behaviour using c
filter:
.product-list|c
will expand to:
<!-- .product-list -->
<div class="product-list">|</div>
<!-- /.product-list -->
To insert only the second comment add to your .vimrc
:
let g:user_emmet_settings = {
\ 'html' : {
\ 'comment_type': 'lastonly'
\ }
\}
Then:
.product-list|c
will expand to:
<div class="product-list">|</div><!-- .product-list -->
(|
is the cursor position after expansion.)
Change HTML tag in vim, but keeping the attributes (surround)
I have xml.vim plugin (https://github.com/othree/xml.vim) . If you had it too, your requirement is rather easy.
Just move cursor to tag, press <leader>c
(lowercase c), then input new tagname, only tag name will be changed.
If you press <leader>C
(Big C), also rename the tag/element, but also original attributes are removed.
Related Topics
Excel Crashes When Attempting to Inspect Dispstaticnodelist
Ie Offsetting and Ignoring Height/Width of Anchor Focus Outlines
Giving Background-Color to Body Applying Whole Page. Why
How to Make Rounded Border in Ie8 with CSS
Adjusting and Image Size to Fit a Div with Bootstrap
Styling Autocomplete Dropdowns in Browsers
Cordova List All Files from Application Directory (Www)
How to Get The Parent Url from an Iframe's Content
Why Do HTML Entity Names with Dec < 255 Not Require Semicolon
Why Are CSS-Styles Not Inherited by HTML Form Fields
HTML5 Canvas Scrolling Vertically and Horizontally
Get Url and Save It | Chrome Extension
Center <Img/> Inside a <Div> with CSS