45

Vim ships with a macro called matchit that does this for you; all you need to do is activate it with runtime macros/matchit.vim in your vimrc. This will enable you to jump from, eg, a <div> to its </div>. Note that your cursor will have to be inside the angle brackets; if you're on the angle brackets, % will jump from one bracket to the other as ...


23

You can jump between tags using visual operators, in example: Place the cursor on the tag. Enter visual mode by pressing v. Select the outer tag block by pressing a+t or i+t for inner tag block. Your cursor should jump forward to the matching closing html/xml tag. To jump backwards from closing tag, press o or O to jump to opposite tag. Now you can either ...


15

The following vim command would creates an html rendering of the current file. :TOhtml It saves the file in the same folder (with .html extension) and it will include styles, foreground/background colours and syntax highlighting, so the file can be straight web published as well as printed. For more options (like adding line numbers, compability with old ...


11

Here is a simple ad-hoc solution to put in ~/.vim/after/ftplugin/html.vim: inoremap <buffer> > ></<C-x><C-o><C-y><C-o>%<CR><C-o>O Breakdown: ></ insert '></' <C-x><C-o><C-y> use the built-in omni-completion to finish the closing tag <C-o>% ...


10

The 'foldmethod' is a window-local option; setting it from your ~/.vimrc doesn't necessarily have the right effect. Because syntax folding is bound to the html filetype, these settings belong to ~/.vim/after/ftplugin/html.vim: setlocal foldmethod=syntax This depends on having filetype plugin on in your ~/.vimrc, which you probably have. You can also ...


9

For what you want to do, emmet-vim, as nobe4 suggested, is your best bet. In insert mode, li{item $}*10<c-y>, will expand 10 <li>s with item N prefilled as the text. You'll start editing the contents of the first one. While still in insert mode, pressing <c-y>n will move to the next tag for editing. If your list items are not a sequence ...


6

After you've added your files to the arguments list with :n ./**/*.f90 (:args + filenames would do the same thing and is perhaps more obvious) you can use: :argdo exe 'TOhtml' | wq :argdo will execute its following commands for each buffer that's in the argument list. Note that you need to use TOhtml with :execute since it isn't defined to allow a ...


6

Vim already comes with Markdown support so what happens is that you have two Markdown ftplugins doing the same thing. Since you "fixed" one (~/.vim/ftplugin/markdown.vim) without "fixing" the other ($VIMRUNTIME/ftplugin/markdown.vim), your fix is simply overridden by the built-in ftplugin. If you insist on disabling HTML support in markdown buffers you can ...


5

You can read more about why this happens by looking at :help :syn-sync. The short answer is that vim decides to redraw the screen and starts from some point in the middle of the file. It incorrectly guesses the syntax at this starting point and it messes up the rest of the file. To fix this, I generally use this mapping, which I got from Steve Losh's ...


5

The syntax items within which Vim will highlight spelling mistakes are defined using the @Spell and @NoSpell clusters. See :help spell-syntax (and the rest of the :help spell and :help syntax files) for full details. The quick and dirty fix to get your desired result is to create a new file in your Vim config directory: .vim/after/syntax/html.vim with the ...


5

As I understood you, you want to convert content of current window to HTML. Try to run this command: :runtime! syntax/2html.vim more info here: :help convert-to-HTML


5

Overriding a plugin manually Unless you intend to change all of the settings set by Vim's existing html ftplugin, you want your plugin to be loaded before it. The setting of the b:did_ftplugin variable will then cause Vim's version to exit immediately. Placing the plugin in your ~/.vim/ftplugin directory will cause it to be loaded before Vim's included ...


5

Put this in your .vimrc file: autocmd BufRead,BufNewFile *.htm,*.html setlocal tabstop=2 shiftwidth=2 softtabstop=2 Briefly, autocmds get processed when the specified events occur for the specified file name patterns. Here we just set the tab values for the current buffer to the desired value in the event of reading or creating a file with .htm or .html ...


4

Ok, this is probably not the best solution because it is pretty invasive. But, it's all I could come up with so I will give it to you. One thing we can do is basically manually do the highlighting ourselves. So we could easily do something like: syn match quotedErubyBlock '"<%.\{-}%>"' This will define a new highlighting section that matches "<...


4

I recommend the tidy-html5 plugin. As a web developer myself, I also recommend aligning the HTML tags a little differently, AirBnb React Styleguide (most legible) <a href="http://someverylongurl.com/foo/bar/blaz/SinwzvO.jpg"> <img src="http://someverylongurl.com/foo/bar/blaz/Sinwzv0.jpg" class="ri" alt="This is an image" > </...


3

I had to add the code below to my vimrc to get the p tag to work. I also included all the block level elements that are listed in the link in the original question as well (though this is overkill) to prevent any other changes (like Vim patch 7.4.356) from overriding my preferred settings. " " HTML indentation " let g:html_indent_script1 = "inc" let g:...


3

The xmledit (http://vimawesome.com/plugin/xmledit) plugin allows to jump between open and close tags using <localleader>% Often <localleader> will be \, so you can jump with \% NOTE: Unlike matchit, you don't have to put your cursor inside the tag. Placing it right on the < or > is perfectly fine for the xmledit plugin. :) NOTE 2: A drawback ...


3

From /usr/share/vim/vim74/syntax/html.vim: syn region htmlString contained start=+"+ end=+"+ contains=htmlSpecialChar,javaScriptExpression,@htmlPreproc syn region htmlString contained start=+'+ end=+'+ contains=htmlSpecialChar,javaScriptExpression,@htmlPreproc To add spelling support, we need to add the @Spell keyword (see :help spell-syntax) like so:...


3

See vim-closetag It's exactly what you're looking for. From it's README: If this is the current content: <table| Now you press >, the content will be: <table>|</table> And now if you press > again, the content will be: <table> | </table> Note: | is the cursor here


3

You'll need to modify the contains of syn region htmlTag to include your new htmlArgId. The full line would be: syn region htmlTag start=+<[^/]+ end=+>+ fold contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent,htmlCssDefinition,@htmlPreproc,@htmlArgCluster,htmlArgId I just tacked on ,htmlArgId at the end; the rest is from /usr/share/...


2

vitVS<article> seems to do what you want. v to start select mode it to select "inner tag" V to start line-wise visual mode S<article> to surround It would be better to start with line-wise visual mode, and go from there, but it changes it back to 'normal' (non-line wise) visual mode.


2

In vim we can read (:help :range): /{pattern}[/] - the next line where {pattern} matches That means if there is no next line - no match can be found, because there is only one current line (all lines together). So to search starting from the first/current line, we need to use 0;/foo. 0;/that - the first line containing "that", also matches ...


2

Unfortunately, the it text-object starts right after the opening tag with a zero-width match. The only solution I see is to visually select the lines you want with V{motion} before pressing S. It is less magical than ysit<article> but oh well…


2

A sequence of normal mode commands aborts as soon as one command (e.g. a search) fails. So, if the n jump to the next match fails (with Pattern not found: <h1>), the following vitd isn't executed. That's your condition, and it works for me that way (using Vim in Ex mode via vim -e). Note that you have another bug in your script: By first searching for ...


2

You can achieve this using foldexpression. The best would be to create a function, that analyzes each line and returns an actual foldlevel. Here is a short example, that should get you started: set fen fdm=expr fde=getline(v:lnum)=~#'<[^>]*>'?'a1':getline(v:lnum)=~#'</[^>]*>'?'s1':'=' Read the details at :h fold-expr (especially the ...


2

Based on @SatoKatsura's comments, here is a shell script (for UNIX like systems) which will install js-beautify and setup the python executable as a command. Just to clarify, this will install the main js-beautify repo which contains the js-beautify program intended to be run on nodejs, but this script will not link to the nodejs script - instead it links ...


2

As pointed by "Karl Yngve Lervåg" in his comments, combining the answers of both "Karl Yngve Lervåg" and "Antony" gave me the desired result. So, after opening the first .f90 file, you should use the below command :args ./**/*.f90 | argdo exe 'TOhtml' | wq The only trouble which I am still facing with the above method is: generated html files doesn't have ...


2

I would suggest the following combined command: :args ./**/*.f90 | argdo execute TOhtml First, use args to fill the argument list, then use argdo to execute the TOhtml command. There should be no reason to wq, since there is no change to the files, thus I would instead do e.g. :qa when you were finished and happy.


2

I would probably do this with a mapping: :nmap ^B o<li></li>^[4hi The plan is to insert to tags and then place the insert inbetween them, so that you can type in the text, escape back into normal mode and then do ctrl-b again. (PS, the ^B and ^[ are entered using ctrl_V, but you probably knew that already.) To put in ten rows in single command,...


Only top voted, non community-wiki answers of a minimum length are eligible