diff --git a/UltiSnips/all.snippets b/UltiSnips/all.snippets index 273b631..fb3b8ee 100644 --- a/UltiSnips/all.snippets +++ b/UltiSnips/all.snippets @@ -4,8 +4,17 @@ endsnippet global !p comment=vim.current.buffer.options['commentstring'].strip() + def commentbefore(): - return comment[0:comment.find('%s')].strip() + ' ' + commentbefore = comment[0:comment.find('%s')].strip() + row, col = vim.current.window.cursor + row -= 1 + col -= 1 + line = vim.current.buffer[row] + if (col - 1) >= 0 and commentbefore == line[col - 1:len(commentbefore)]: + return '' + return commentbefore + ' ' + def commentafter(): after=comment[comment.find('%s')+2:].strip() if 0 < len(after):