Code Monkey home page Code Monkey logo

vim-markdown's Introduction

Vim Markdown

Vint Vader

Syntax highlighting, matching rules and mappings for the original Markdown and extensions.

  1. Installation
  2. Basic usage
  3. Options
  4. Mappings
  5. Commands
  6. Credits
  7. License

Installation

If you use Vundle, add the following lines to your ~/.vimrc:

Plugin 'godlygeek/tabular'
Plugin 'preservim/vim-markdown'

The tabular plugin must come before vim-markdown.

Then run inside Vim:

:so ~/.vimrc
:PluginInstall

If you use Pathogen, do this:

cd ~/.vim/bundle
git clone https://github.com/preservim/vim-markdown.git

To install without Pathogen using the Debian vim-addon-manager, do this:

git clone https://github.com/preservim/vim-markdown.git
cd vim-markdown
sudo make install
vim-addon-manager install markdown

If you are using a package manager with semver support (like lazy.nvim) make sure you are following the master branch (see #616).

If you are not using any package manager, download the tarball and do this:

cd ~/.vim
tar --strip=1 -zxf vim-markdown-master.tar.gz

Basic usage

Folding

Folding is enabled for headers by default.

The following commands are useful to open and close folds:

  • zr: reduces fold level throughout the buffer
  • zR: opens all folds
  • zm: increases fold level throughout the buffer
  • zM: folds everything all the way
  • za: toggle a fold your cursor is on
  • zA: toggle a fold your cursor is on recursively
  • zo: open a fold your cursor is on
  • zO: open a fold your cursor is on recursively
  • zc: close a fold your cursor is on
  • zC: close a fold your cursor is on recursively

Options are available to disable folding or change folding style.

Try :help fold-expr and :help fold-commands for details.

Concealing

Concealing is set for some syntax such as bold, italic, code block and link.

Concealing lets you conceal text with other text. The actual source text is not modified. If you put your cursor on the concealed line, the conceal goes away.

Options are available to disable or change concealing.

Try :help concealcursor and :help conceallevel for details.

Options

Disable Folding

  • g:vim_markdown_folding_disabled

    Add the following line to your .vimrc to disable the folding configuration:

    let g:vim_markdown_folding_disabled = 1
    

    This option only controls Vim Markdown specific folding configuration.

    To enable/disable folding use Vim's standard folding configuration.

    set [no]foldenable
    

Change fold style

  • g:vim_markdown_folding_style_pythonic

    To fold in a style like python-mode, add the following to your .vimrc:

    let g:vim_markdown_folding_style_pythonic = 1
    

    g:vim_markdown_folding_level setting (default 1) is set to foldlevel. Thus level 1 heading which is served as a document title is expanded by default.

  • g:vim_markdown_override_foldtext

    To prevent foldtext from being set add the following to your .vimrc:

    let g:vim_markdown_override_foldtext = 0
    

Set header folding level

  • g:vim_markdown_folding_level

    Folding level is a number between 1 and 6. By default, if not specified, it is set to 1.

    let g:vim_markdown_folding_level = 6
    

    Tip: it can be changed on the fly with:

    :let g:vim_markdown_folding_level = 1
    :edit
    

Disable Default Key Mappings

  • g:vim_markdown_no_default_key_mappings

    Add the following line to your .vimrc to disable default key mappings:

    let g:vim_markdown_no_default_key_mappings = 1
    

    You can also map them by yourself with <Plug> mappings.

Enable TOC window auto-fit

  • g:vim_markdown_toc_autofit

    Allow for the TOC window to auto-fit when it's possible for it to shrink. It never increases its default size (half screen), it only shrinks.

    let g:vim_markdown_toc_autofit = 1
    

Text emphasis restriction to single-lines

  • g:vim_markdown_emphasis_multiline

    By default text emphasis works across multiple lines until a closing token is found. However, it's possible to restrict text emphasis to a single line (i.e., for it to be applied a closing token must be found on the same line). To do so:

    let g:vim_markdown_emphasis_multiline = 0
    

Syntax Concealing

  • g:vim_markdown_conceal

    Concealing is set for some syntax.

    For example, conceal [link text](link url) as just link text. Also, _italic_ and *italic* will conceal to just italic. Similarly __bold__, **bold**, ___italic bold___, and ***italic bold*** will conceal to just bold, bold, italic bold, and italic bold respectively.

    To enable conceal use Vim's standard conceal configuration.

    set conceallevel=2
    

    To disable conceal regardless of conceallevel setting, add the following to your .vimrc:

    let g:vim_markdown_conceal = 0
    

    To disable math conceal with LaTeX math syntax enabled, add the following to your .vimrc:

    let g:tex_conceal = ""
    let g:vim_markdown_math = 1
    
  • g:vim_markdown_conceal_code_blocks

    Disabling conceal for code fences requires an additional setting:

    let g:vim_markdown_conceal_code_blocks = 0
    

Fenced code block languages

  • g:vim_markdown_fenced_languages

    You can use filetype name as fenced code block languages for syntax highlighting. If you want to use different name from filetype, you can add it in your .vimrc like so:

    let g:vim_markdown_fenced_languages = ['csharp=cs']
    

    This will cause the following to be highlighted using the cs filetype syntax.

    ```csharp
    ...
    ```
    

    Default is ['c++=cpp', 'viml=vim', 'bash=sh', 'ini=dosini'].

Follow named anchors

  • g:vim_markdown_follow_anchor

    This feature allows the ge command to follow named anchors in links of the form file#anchor or just #anchor, where file may omit the .md extension as usual. Two variables control its operation:

    let g:vim_markdown_follow_anchor = 1
    

    This tells vim-markdown whether to attempt to follow a named anchor in a link or not. When it is 1, and only if a link can be split in two parts by the pattern '#', then the first part is interpreted as the file and the second one as the named anchor. This also includes urls of the form #anchor, for which the first part is considered empty, meaning that the target file is the current one. After the file is opened, the anchor will be searched.

    Default is 0.

  • g:vim_markdown_anchorexpr

    let g:vim_markdown_anchorexpr = "'<<'.v:anchor.'>>'"
    

    This expression will be evaluated substituting v:anchor with a quoted string that contains the anchor to visit. The result of the evaluation will become the real anchor to search in the target file. This is useful in order to convert anchors of the form, say, my-section-title to searches of the form My Section Title or <<my-section-title>>.

    Default is ''.

Syntax extensions

The following options control which syntax extensions will be turned on. They are off by default.

LaTeX math

  • g:vim_markdown_math

    Used as $x^2$, $$x^2$$, escapable as \$x\$ and \$\$x\$\$.

    let g:vim_markdown_math = 1
    

YAML Front Matter

  • g:vim_markdown_frontmatter

    Highlight YAML front matter as used by Jekyll or Hugo.

    let g:vim_markdown_frontmatter = 1
    

TOML Front Matter

  • g:vim_markdown_toml_frontmatter

    Highlight TOML front matter as used by Hugo.

    let g:vim_markdown_toml_frontmatter = 1
    

JSON Front Matter

  • g:vim_markdown_json_frontmatter

    Highlight JSON front matter as used by Hugo.

    let g:vim_markdown_json_frontmatter = 1
    

Strikethrough

  • g:vim_markdown_strikethrough

    Strikethrough uses two tildes. ~~Scratch this.~~

    let g:vim_markdown_strikethrough = 1
    

Adjust new list item indent

  • g:vim_markdown_new_list_item_indent

    You can adjust a new list indent. For example, you insert a single line like below:

    * item1
    

    Then if you type o to insert new line in vim and type * item2, the result will be:

    * item1
        * item2
    

    vim-markdown automatically insert the indent. By default, the number of spaces of indent is 4. If you'd like to change the number as 2, just write:

    let g:vim_markdown_new_list_item_indent = 2
    

Do not require .md extensions for Markdown links

  • g:vim_markdown_no_extensions_in_markdown

    If you want to have a link like this [link text](link-url) and follow it for editing in vim using the ge command, but have it open the file "link-url.md" instead of the file "link-url", then use this option:

    let g:vim_markdown_no_extensions_in_markdown = 1
    

    This is super useful for GitLab and GitHub wiki repositories.

    Normal behaviour would be that vim-markup required you to do this [link text](link-url.md), but this is not how the Gitlab and GitHub wiki repositories work. So this option adds some consistency between the two.

Auto-write when following link

  • g:vim_markdown_autowrite

    If you follow a link like this [link text](link-url) using the ge shortcut, this option will automatically save any edits you made before moving you:

    let g:vim_markdown_autowrite = 1
    

Change default file extension

  • g:vim_markdown_auto_extension_ext

    If you would like to use a file extension other than .md you may do so using the vim_markdown_auto_extension_ext variable:

    let g:vim_markdown_auto_extension_ext = 'txt'
    

Do not automatically insert bulletpoints

  • g:vim_markdown_auto_insert_bullets

    Automatically inserting bulletpoints can lead to problems when wrapping text (see issue #232 for details), so it can be disabled:

    let g:vim_markdown_auto_insert_bullets = 0
    

    In that case, you probably also want to set the new list item indent to 0 as well, or you will have to remove an indent each time you add a new list item:

    let g:vim_markdown_new_list_item_indent = 0
    

Change how to open new files

  • g:vim_markdown_edit_url_in

    By default when following a link the target file will be opened in your current buffer. This behavior can change if you prefer using splits or tabs by using the vim_markdown_edit_url_in variable. Possible values are tab, vsplit, hsplit, current opening in a new tab, vertical split, horizontal split, and current buffer respectively. Defaults to current buffer if not set:

    let g:vim_markdown_edit_url_in = 'tab'
    

Borderless tables

  • g:vim_markdown_borderless_table

    Add support for borderless tables, such as:

    header 1|header 2
    --|--
    data 1|data 2
    

    if set to 1:

    let g:vim_markdown_borderless_table = 1
    

    the table would be formatted as usual:

    | header 1 | header 2 |
    |----------|----------|
    | data 1   | data 2   |
    

Mappings

The following work on normal and visual modes:

  • gx: open the link under the cursor in the same browser as the standard gx command. <Plug>Markdown_OpenUrlUnderCursor

    The standard gx is extended by allowing you to put your cursor anywhere inside a link.

    For example, all the following cursor positions will work:

    [Example](http://example.com)
    ^  ^    ^^   ^       ^
    1  2    34   5       6
    
    <http://example.com>
    ^  ^               ^
    1  2               3
    

    Known limitation: does not work for links that span multiple lines.

  • ge: open the link under the cursor in Vim for editing. Useful for relative markdown links. Falls back to gf with force editing, if not on a markdown link. <Plug>Markdown_EditUrlUnderCursor

    The rules for the cursor position are the same as the gx command.

  • ]]: go to next header. <Plug>Markdown_MoveToNextHeader

  • [[: go to previous header. Contrast with ]h. <Plug>Markdown_MoveToPreviousHeader

  • ][: go to next sibling header if any. <Plug>Markdown_MoveToNextSiblingHeader

  • []: go to previous sibling header if any. <Plug>Markdown_MoveToPreviousSiblingHeader

  • ]h: go to Current header. <Plug>Markdown_MoveToCurHeader

  • ]u: go to parent header (Up). <Plug>Markdown_MoveToParentHeader

This plugin follows the recommended Vim plugin mapping interface, so to change the map ]u to asdf, add to your .vimrc:

map asdf <Plug>Markdown_MoveToParentHeader

To disable a map use:

map <Plug> <Plug>Markdown_MoveToParentHeader

Commands

The following requires :filetype plugin on.

  • :HeaderDecrease:

    Decrease level of all headers in buffer: h2 to h1, h3 to h2, etc.

    If range is given, only operate in the range.

    If an h1 would be decreased, abort.

    For simplicity of implementation, Setex headers are converted to Atx.

  • :HeaderIncrease: Analogous to :HeaderDecrease, but increase levels instead.

  • :SetexToAtx:

    Convert all Setex style headers in buffer to Atx.

    If a range is given, e.g. hit : from visual mode, only operate on the range.

  • :TableFormat: Format the table under the cursor like this.

    Requires Tabular.

    The input table must already have a separator line as the second line of the table. That line only needs to contain the correct pipes |, nothing else is required.

  • :Toc: create a quickfix vertical window navigable table of contents with the headers.

    Hit <Enter> on a line to jump to the corresponding line of the markdown file.

  • :Toch: Same as :Toc but in an horizontal window.

  • :Toct: Same as :Toc but in a new tab.

  • :Tocv: Same as :Toc for symmetry with :Toch and :Tocv.

  • :InsertToc: Insert table of contents at the current line.

    An optional argument can be used to specify how many levels of headers to display in the table of content, e.g., to display up to and including h3, use :InsertToc 3.

  • :InsertNToc: Same as :InsertToc, but the format of h2 headers in the table of contents is a numbered list, rather than a bulleted list.

Credits

The main contributors of vim-markdown are:

  • Ben Williams (A.K.A. @plasticboy). The original developer of vim-markdown. Homepage.

If you feel that your name should be on this list, please make a pull request listing your contributions.

License

The MIT License (MIT)

Copyright (c) 2012 Benjamin D. Williams

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

vim-markdown's People

Contributors

alerque avatar alexconst avatar artumi-richard avatar aseom avatar blueyed avatar bwilliamsgryphon avatar cdelledonne avatar cirosantilli avatar citizenmatt avatar codybuell avatar colinsullivan avatar farmckon avatar fmoralesc avatar haya14busa avatar ilikepi avatar jhoepken avatar jrwrigh avatar lggruspe avatar memeplex avatar michaelpotter avatar plasticboy avatar rhdunn avatar sersorrel avatar shirosaki avatar tobinjt avatar todesking avatar tomtomjhj avatar xiaket avatar y0t4 avatar yous avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vim-markdown's Issues

Support for GFM code blocks

Github flavored markdown has codeblocks denoted by backticks. Unfortunately this isn't supported which means that the syntax highlighting can get pretty screwy (for example if there is an underscore in a code block. Any chance this functionality could be added?

Code inside headers.

Doesn't even need to render differently: the only thing I need is to add @NoSpell, otherwise all my titles made of programming terms become spell errors:

# ActiveRecord

I want:

# `ActiveRecord`

Problem with :Toc

When try to get a :Toc I have this error

Error detected while processing function 37_Markdown_Toc:
line 25:
E486: Pattern not found: \v^([^|]*|){2,2} #

Anyway after it displays correctly the headers.

consider changing file layout to support Pathogen

Pathogen allows one to put plugins in ~/.vim/bundle and they get added to the load path... the upshot is that they can stay isolated from each other, rather than having to copy files into your ~/.vim/syntax directories (for instance).

In order to use vim-markdown with Pathogen, the syntax file needs to move into a syntax/ directory. I've done that in bleything/vim-markdown@e49b51edc64ac78e85aa5475ba88fc8a33c74a4d

Installation using vundle

Edit: please close issue.

Turns out this was NOT related to vim-markdown at all.

I'm new to using a plug-in/package manager for vim and vundle was recommended to me.

I just tried using vundle to install vim-markdown and have been met with a python stack trace of errors (gist).

I'm not asking for help diagnosing my particular install issues, but I thought it would be worth reporting so easier vundle installation could be supported in the future.

Perhaps this is actually a vundle issue and if so, please close and I'll put this remark over there.

Thank you!

Why filetype.vim instead of ftdetect/mkd.vim?

As far as I understand vim, the typical way to add file detection is by putting a .vim file to be sourced in ~/.vim/ftdetect/ instead of making ~/.vim/filetype.vim. Does filetype.vim have any advantages over ftdetect? If not, then I propose updating the instruction page accordingly.

All folds open initially

I like the folding feature, but when I open a file I don't want to every time have to open the folds initially. I want them all open for me.

Love the plugin!

[patch] 0001-Support-Markdown-in-openssl.vim.patch

Cloning your repo for this seems to be overkill.

From ca4fe2efff68e71098c8ecf4c59e7326bf452b85 Mon Sep 17 00:00:00 2001
From: Richard Hartmann [email protected]
Date: Sat, 7 May 2011 21:13:02 +0200
Subject: [PATCH] Support Markdown in openssl.vim

openssl.vim allows you to transparently encrypt files using openssl.

With this change, you can have mdwn.bfa etc be detected as Markdown while still using openssl.vim's encryption.

ftdetect/mkd.vim | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/ftdetect/mkd.vim b/ftdetect/mkd.vim
index ab36f5c..44f6f0e 100644
--- a/ftdetect/mkd.vim
+++ b/ftdetect/mkd.vim
@@ -1,3 +1,4 @@
" markdown filetype file
-au BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn} set filetype=mkd
+au BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn} set filetype=mkd
+au BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn}.{des3,des,bf,bfa,aes,idea,cast,rc2,rc4,rc5,desx} set filetype=mkd

1.7.4.4

Error with Vim version 7.4.273

There is a problem with version 7.4.273 which should be related to the recent 7.4.260 patch.

Error detected while processing /Users/user/.vim/bundle/vim-markdown/ftplugin/mkd.vim:
line 72:
E128: Function name must start with a capital or "s:": b:Markdown_GetHeaderLineNum(...)
[...]

Patch 7.4.260

updated for version 7.4.260
Problem: It is possible to define a function with a colon in the name. It
is possible to define a function with a lower case character if a
"#" appears after the name.
Solution: Disallow using a colon other than with "s:". Ignore "#" after the
name.

Works if I manually type "set filetype=mkd" after opening .md files, but not otherwise.

I extracted the zip file into ~/.vim

My .vim now looks like:

chris@chris-linux-desktop:~/.vim$ tree .
.
|-- doc
| |-- NERD_tree.txt
| -- tags |-- ftdetect |-- mkd.vim
|-- nerdtree_plugin
| |-- exec_menuitem.vim
| -- fs_menu.vim |-- plugin |-- NERD_tree.vim
-- syntax -- mkd.vim

5 directories, 7 files

Is there something else I need to do?

Thanks,

Chris.

P.S.

chris@chris-linux-desktop:/.vim$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=10.10
DISTRIB_CODENAME=maverick
DISTRIB_DESCRIPTION="Ubuntu 10.10"
chris@chris-linux-desktop:
/.vim$ uname -a
Linux chris-linux-desktop 2.6.35-31-generic #63-Ubuntu SMP Mon Nov 28 19:29:10 UTC 2011 x86_64 GNU/Linux
chris@chris-linux-desktop:~/.vim$ vim --version
VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Sep 28 2010 11:02:36)

code block is slow

the code block :

syn match  mkdCode      /^\s*\n\(\(\s\{4,}[^ ]\|\t\+[^\t]\).*\n\)\+/

is too slow ;

I use this instead:

+syn region mkdCode start='^$\n^\s{4,}' end='^$'

  •  "\ contains=@NoSpell
    

Highlighting multiline heading

vim-markdown highlights only single-line headings now. In my humble opinion it is better to highlight all the lines of a header up to an empty line.

Now:
plain: First line of a very long
highlighted: two-line heading
highlighted: =========

Should be:
highlighted: First line of a very long
highlighted: two-line heading
highlighted: =========

Escaping Link '[' marker

When trying to escape a link marker, vim-markdown still seems to highlight it as if it was a link. For example:

\[test]

I think should just produce [test], not underlined like a link. To accomplish this, you can change:

syn region mkdLink matchgroup=mkdDelimiter start="\!\?\[" end="\]\ze\s*[[(]" contains=@Spell nextgroup=mkdURL,mkdID skipwhite

to:

syn region mkdLink matchgroup=mkdDelimiter start="\!\?\(\\\)\@<!\[" end="\]\ze\s*[[(]" contains=@Spell nextgroup=mkdURL,mkdID skipwhite

In the syntax file.

LaTeX math blocks syntax highlight extension.

Possible syntaxes:

  • $ x^2 $. Not supported in many Md engines because of conflict with dollar sign, even if $$ is supported.
  • $$ x^2 $$
  • \(\)
  • \[\]

We would have to decide which to support.

Highlight headers

Would be nice if # ... headers in markdown files were syntax highlighted like function names in source code files.

Lots of warnings with vim 7.4.273

Error detected while processing /Users/languitar/.vim/bundle/vim-markdown/ftplugin/mkd.vim:
line   72:
E128: Function name must start with a capital or "s:": b:Markdown_GetHeaderLineNum(...)
line   73:
E121: Undefined variable: a:0
E15: Invalid expression: a:0 == 0
line   78:
E121: Undefined variable: l:l
E15: Invalid expression: (l:l > 0)
line   80:
E133: :return not inside a function
line   84:
E133: :return not inside a function
line   85:
E193: :endfunction not inside a function
line   94:
E128: Function name must start with a capital or "s:": b:Markdown_MoveToCurHeader()
line   95:
E117: Unknown function: b:Markdown_GetHeaderLineNum
E15: Invalid expression: b:Markdown_GetHeaderLineNum()
line   96:
E121: Undefined variable: l:lineNum
E15: Invalid expression: l:lineNum != 0
line  102:
E133: :return not inside a function
line  103:
E193: :endfunction not inside a function
line  109:
E128: Function name must start with a capital or "s:": b:Markdown_MoveToNextHeader()
line  114:
E193: :endfunction not inside a function
line  120:
E128: Function name must start with a capital or "s:": b:Markdown_MoveToPreviousHeader()
line  121:
E117: Unknown function: b:Markdown_GetHeaderLineNum
E15: Invalid expression: b:Markdown_GetHeaderLineNum()
line  122:
E461: Illegal variable name: l:noPreviousHeader
line  123:
E121: Undefined variable: l:curHeaderLineNumber
E15: Invalid expression: l:curHeaderLineNumber <= 1
line  133:
E121: Undefined variable: l:noPreviousHeader
E15: Invalid expression: l:noPreviousHeader
line  136:
E193: :endfunction not inside a function

and many more.

Markdown syntax bug

I find some bugs when vim highlight markdown files. Please see the
screen capture video (focus on the top left terminal, in which I
highlighted "t", notice the bottom incorrectly highlighted paragraph).
Would you please take a look and see if you can fix this bug? Thanks!

https://rapidshare.com/files/1086391016/mkd_bug.mov

See the content of mkd file below.

WINNOWER

constructs a graph whose vertices correspond
to all l-mers present in the t input sequences, with an edge connecting two vertices if and only if the
corresponding l-mers differ in at most 2d positions and do not both come from the same sequence.
WINNOWER then looks for a clique of size t in this graph.

SP-STAR

A local search method that starts in turn from each individual l-mer x in the input, chooses the
closest match to x from every other input sequence, and uses a sum-of-pairs score and iterative refinement
to converge on a good motif.

code block for jekyll markdown

diff --git a/.vim/syntax/mkd.vim b/.vim/syntax/mkd.vim
index c4ceec4..8bfaa5a 100644
--- a/.vim/syntax/mkd.vim
+++ b/.vim/syntax/mkd.vim
@@ -66,7 +66,7 @@ syn match  mkdLineBreak    /  \+$/
 syn region mkdBlockquote   start=/^\s*>/                   end=/$/ contains=mkdLineBreak,mkdLineContinue,@Spell
 syn region mkdCode         start=/\(\([^\\]\|^\)\\\)\@<!`/ end=/\(\([^\\]\|^\)\\\)\@<!`/
 syn region mkdCode         start=/\s*``[^`]*/              end=/[^`]*``\s*/
-syn region mkdCode         start=/^```\s*[0-9A-Za-z_-]*\s*$/          end=/^```\s*$/
+syn region mkdCode         start=/^\s*```\s*[0-9A-Za-z_-]*\s*$/          end=/^\s*```\s*$/
 syn region mkdCode         start="<pre[^>]*>"              end="</pre>"
 syn region mkdCode         start="<code[^>]*>"             end="</code>"
 syn region mkdFootnote     start="\[^"                     end="\]"

automatically set filetype

saves you from having to set it manually. I've created a patch in bleything@0426e3464b850ba6639a003fe50eb2f0c05ae917, which sorta depends on the patch I submitted in #7.

Support Kramdown footnote definitions and links.

The following are incorrectly syntax highlighted:

[^test]: This is a test.
[^ME]:   [Middle English](https://en.wikipedia.org/wiki/Middle_English). Wikipedia.

The footnote is correctly highlighted, but:

  1. only the first word of the text is highlighted (e.g. This in This is a test.);
  2. the links are not highlighted as links.

I think the:

[name]: url

style markup should not be applied if the name starts with a ^. This would then keep the definition in normal text colour and allow links and other markup to be correctly highlighted.

Missing code block syntax

The markdown specs say that a line begining with four or more spaces
(and/or a tab) will create a <pre><code> block. Useful for copy/pasted
code. This adds the syntax highlighting for this case.

I have a patch but GutHub buggers it all to hell when you paste it into this window. (how does GitHub not handle git based patches?!!!!!)

I'll email it to you.

No spell checking in paragraph text.

With :syntax on setting, paragraphs/running text are not spell checked by vim spell. On the other hand spell checking for e.g. lists (starting with *, - , etc.) works fine.

parenthesis get highlighted as a link

Given:

this is a (link-like) test

The (link-like) text gets highlighted as a link part of a markdown link even though it does not have the form [name](url).

I don't see the line break

I put two white spaces to end of line, but I don't see this with TODO hi.

And if I make

 :syn list mkdLineBreak 

I see a correct colorized hi

  mkdLineBreak   xxx match /  \+$/
                    links to Todo

Regards

Go to next header seems to skip H1 defined with "==="

Just installed, great plugin, thanks.

I am navigating my file, which has H1s defined by underlining using the = character. When I attempt to navigate around the file with [[ or ]] the H1s are skipped. This is curious because they are correctly recognized and highlighted.

My particular file has H1s and H3 (defined with ###).

Thanks.

Cannot escape "\[...\]"

I'm trying to write regular expressions in git wiki, but I found that "[...]" will always convert to math fomula.
I've tried "\[", "\[" and a lot but none worked.

(And I found that "\[" works here but not in git wiki)

Astricks is italicizing even when it shouldn't

I haven't had a chance to dig into the code, but wanted to make an issue now. I might try to fix this later.

When you add an astricks within a paragraph it wants to start italicizing. I personally user underscore for italicizing so it might be nice to make that an option. But the bug I noticed is when it is in an inline code block like this: data-*. In this case it would italics the rest of the document until another astricks.

Multiple paragraphs in list items

List items in Markdown may have multiple paragraphs, and each subsequent paragraph in a list item is intended by either 4 spaces or one tab. However, vim-markdown treats all subsequent paragraphs
as code blocks. Code blocks actually must be intended by 8 spaces or two tabs in a list item.

See an example in http://daringfireball.net/projects/markdown/index.text:

1.  Copy the "Markdown.pl" file to appropriate filters folder in your
    "BBEdit Support" folder. On Mac OS X, this should be:

        BBEdit Support/Unix Support/Unix Filters/

    See the BBEdit documentation for more details on the location of
    these folders.

The output is:

  1. Copy the "Markdown.pl" file to appropriate filters folder in your
    "BBEdit Support" folder. On Mac OS X, this should be:
   BBEdit Support/Unix Support/Unix Filters/
  See the BBEdit documentation for more details on the location of
  these folders.

And here is the screenshot of how vim-markdown highlights the code: http://imgur.com/2i5Xy.png

The second paragraph is a code block, while the third paragraph is a normal paragraph, which should not be highlighted.

erroneous link detection

Markdown mode highlights everything following square brackets as a link, even if there are no parentheses with a URI.

For example, this is an issue with GitHub wiki links ([[my page]]) or manual footnotes, like so:

lorem ipsum[1]
...
dolor sit[2] amet
...


[1] cf. http://example.org
[2] consectetur adipisicing elit

In this example, everything from the first square bracket is erroneously regarded as a (single) link.

Add skip= pattern to italic syntax definition

So it doesn't regard \* as closing tag and doesn't mess everything up when you need to place a star into italic text. Probably the same stuff for \_ and other variants won't hurt too.

I'm newbie in vimscript world, but this does the thing for me:

syn region htmlItalic start="\\\@<!\*\S\@=" skip="\\\*" end="\S\@<=\\\@<!\*" keepend oneline

(Probably it's good to propose this patch to the vim team for fixing official distribution, but I dunno what the process is.)

disable folding not working

I have let g:vim_markdown_folding_disabled=1 in my .vimrc, but when I open a markdown file for the first time, everything is folded.

Highlighting of nested links.

the problem

![description [with a nested](link) doesn't highlight correctly](image.png)

the patch:

syn region mkdLink matchgroup=mkdDelimiter      start="\\\@<!\[" end="\]\ze\s*[[(]" contains=@Spell containedin=mkdLink nextgroup=mkdURL,mkdID skipwhite oneline

it just adds "containedin=mkdLink" to the original mkdLink region.

not sure if that's correct, i don't have any experience with vim syntax files, but it works for me so far.

Use "markdown" filetype instead of "mkd" (or both)?!

The default Vim distribution uses markdown for markdown files (setup via filetype.vim).

Is there a specific reason why this plugin uses mkd instead?

One workaround might be to use a symlink and provide both variants of specific files (syntax, ...) - still the filetype setup would have to use a specific value, or maybe markdown.mkd to match both?!

Highlighting breaks with $<$

Although inline LaTeX is not part of the official Markdown specification, the following causes the syntax highlighting to break:

# =)

- Hello.
- $<$.
- Hello.

# =(

Here's an image of the problem:

bad

As far as I know, inline LaTeX is not supported by the plugin. But since it is commonly used in Markdown, I thought you might want to be alerted to the problem.

Add support for @tags

It would be nice if @someone tags would be highlighted.

Even nicer would be autocompletion for existing @tags...

What is the proper way for disabling distribution's markdown files

I've installed vim-markdown with Vundle and its files are sourced when opening md file but syntax definitions and everything gets messed up because of conflicts with distribution's syntax/ftplugin stuff. What is the proper way of disabling the latter so only vim-markdown is used for markdown files?

(Sorry if it's a lame question, I'm newbie in the vimscript world.)

autoindent problem inside GFM fenced code block

Hi, I don't know if you intend to support Git Flavoured Markdown or not. If so I've noticed a problem inside fenced code blocks.
For example, enter the following:

```
- item 1
- item 2

Then press o to add a line below the last line and it will try to autoindent.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.