diff options
| author | jdhao <jdhao@hotmail.com> | 2019-12-18 21:07:59 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-12-18 21:07:59 +0800 |
| commit | d5392b105406a7060aa9bf7a8b0e053ed517e730 (patch) | |
| tree | dbfed720d1847687e7d2b4ae9672d09a9c396210 /my_snippets/markdown.snippets | |
| parent | 6313d05fc44c7cb9be1b2720157947162e4c46e5 (diff) | |
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.
Diffstat (limited to 'my_snippets/markdown.snippets')
| -rw-r--r-- | my_snippets/markdown.snippets | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/my_snippets/markdown.snippets b/my_snippets/markdown.snippets index 94b408e..a4d0c64 100644 --- a/my_snippets/markdown.snippets +++ b/my_snippets/markdown.snippets @@ -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" <kbd>${1:KEY}</kbd>$0 endsnippet @@ -26,3 +39,8 @@ endsnippet snippet link "Markdown links" [$1]($2)$0 endsnippet + +post_jump "gen_header(snip)" +snippet "h([1-6])" "Markdown header" br +`!p snip.rv = match.group(1)` +endsnippet |
