From 47a4b6baf61b4935728f412746274c5342f72b29 Mon Sep 17 00:00:00 2001 From: Wang Shidong Date: Sun, 4 Aug 2019 20:40:45 +0800 Subject: [PATCH] Comment code block in markdown (#2988) close #2987 --- config/plugins/nerdcommenter.vim | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/config/plugins/nerdcommenter.vim b/config/plugins/nerdcommenter.vim index 8507aeb81..5349c2e8e 100644 --- a/config/plugins/nerdcommenter.vim +++ b/config/plugins/nerdcommenter.vim @@ -30,3 +30,19 @@ let g:NERDTrimTrailingWhitespace = 1 " Always use alternative delimiter let g:NERD_c_alt_style = 1 let g:NERDCustomDelimiters = {'c': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }} +let g:ft = '' +fu! NERDCommenter_before() + if &ft == 'markdown' + let g:ft = 'markdown' + let cf = context_filetype#get() + if cf.filetype !=# 'markdown' + exe 'setf ' . cf.filetype + endif + endif +endfu +fu! NERDCommenter_after() + if g:ft == 'markdown' + setf markdown + let g:ft = '' + endif +endfu