mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
Add markdown header snippets
Now we can type h1, h2, ..., h6 and press <Tab> to generate header of corresponding level. It is more intuitive than vim-snippets's default snippets for headers, i.e., sec, ssec, and so on.
This commit is contained in:
parent
6313d05fc4
commit
d5392b1054
@ -1,3 +1,16 @@
|
|||||||
|
global !p
|
||||||
|
def gen_header(snip):
|
||||||
|
placeholders_string = snip.buffer[snip.line].strip()
|
||||||
|
level = int(placeholders_string[0])
|
||||||
|
|
||||||
|
# erase current line
|
||||||
|
snip.buffer[snip.line] = ""
|
||||||
|
line_content = "#"*level + " ${1:Section Name} " + "#"*level
|
||||||
|
line_content += '\n$0'
|
||||||
|
|
||||||
|
snip.expand_anon(line_content)
|
||||||
|
endglobal
|
||||||
|
|
||||||
snippet kbd "HTML kbd tag"
|
snippet kbd "HTML kbd tag"
|
||||||
<kbd>${1:KEY}</kbd>$0
|
<kbd>${1:KEY}</kbd>$0
|
||||||
endsnippet
|
endsnippet
|
||||||
@ -26,3 +39,8 @@ endsnippet
|
|||||||
snippet link "Markdown links"
|
snippet link "Markdown links"
|
||||||
[$1]($2)$0
|
[$1]($2)$0
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
post_jump "gen_header(snip)"
|
||||||
|
snippet "h([1-6])" "Markdown header" br
|
||||||
|
`!p snip.rv = match.group(1)`
|
||||||
|
endsnippet
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user