Improve TODO and NOTE snippets when in comments

This commit is contained in:
Kenneth Benzie 2016-05-21 00:55:43 +01:00
parent 02de482df9
commit b03ff98e4d

View File

@ -4,8 +4,17 @@ endsnippet
global !p global !p
comment=vim.current.buffer.options['commentstring'].strip() comment=vim.current.buffer.options['commentstring'].strip()
def commentbefore(): 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(): def commentafter():
after=comment[comment.find('%s')+2:].strip() after=comment[comment.find('%s')+2:].strip()
if 0 < len(after): if 0 < len(after):