Why can't I add a link tag for rich html: 5?
html: 5 will expand by default with emmet.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
</body>
</html>
I want to set it up like the following when I deploy html: 5 in my vim.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<link href="" >
</head>
<body>
</body>
</html>
Here is my attempt.
vim snippets.json
#to change the line containing doc": as
doc": "html>(head>meta[charset=${charset}]+meta:vp+meta:edge+link[href=\"\"])+body",
Why is there still no link tag on html: 5 extension?
source to share
I am assuming you are using the emmet-vim plugin .
It stores the complete configuration emmet
, including the snippets section, internally
.vim/autoload/emmet.vim
, so it doesn't see the changes you made to the offline file snippets.json
.
Here's what the plugin documentation at vim.org says:
You can customize the behavior of an extension with overriding configuration. This configuration will be merged when loading the plugin.
let g:user_emmet_settings = {
\ 'indentation' : ' ',
\ 'perl' : {
\ 'aliases' : {
\ 'req' : 'require '
\ },
\ 'snippets' : {
\ 'use' : "use strict\nuse warnings\n\n",
\ 'warn' : "warn \"|\";",
\ }
\ }
\}
So what you need to do is add <link/>
to snippet html:5
add the following to your file ~/.vimrc
:
let g:user_emmet_settings = {
\ 'html' : {
\ 'snippets' : {
\ 'html:5': "<!DOCTYPE html>\n"
\ ."<html lang=\"${lang}\">\n"
\ ."<head>\n"
\ ."\t<meta charset=\"${charset}\">\n"
\ ."\t<title></title>\n"
\ ."\t<link href=\"\">"
\ ."</head>\n"
\ ."<body>\n\t${child}|\n</body>\n"
\ ."</html>"
\ }
\ }
\}
now when you restart vim and type html:5 <c-y>,
, it will create what you want:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<link href="">
</head>
<body>
Alternatively, install the Vim WebAPI plugin and load your own with it snippets.json
, for example:
~/.vimrc
let g:user_emmet_settings = webapi#json#decode(join(readfile(expand('~/snippets.json')), "\n"))
~/snippets.json
{
"html" : {
"snippets": {
"html:5": "<!DOCTYPE html>\n <html lang=\"${lang}\">\n<head>\n \t<meta charset=\"${charset}\">\n \t<title></title>\n \t<link href=\"\"> </head>\n <body>\n\t${child}|\n</body>\n </html>"
}
}
}
source to share