Closed
Description
I noticed this issue with the following latex snippet:
snippet begin
\begin{${1:env}}
${0}
\end{$1}
When I use this on an indented line containing just "begin", while using noexpandtab and a tabstop of 4, I get the following, as expected:
\begin{env}
\end{env}
However, if I then start typing "d" to replace "env" I get the following:
\begin{d}
\end{envd
And typing more continues to add things to the end of the last line. This is definitely a problem with indentation as changing the value of tabstop
changes where the substitution happens: in particular if tabstop
is 1 then it is correct. Hence somewhere in snipmate, columns are being stored/calculated as screen columns, instead of character columns. I think the following fixes the issue:
diff --git a/autoload/snipMate.vim b/autoload/snipMate.vim
index 1930499..35928d4 100644
--- a/autoload/snipMate.vim
+++ b/autoload/snipMate.vim
@@ -79,7 +79,7 @@ fun! snipMate#expandSnip(snip, col)
endif
" Insert snippet with proper indentation
- let indent = indent(lnum) + 1
+ let indent = match(line, '\S\|$') + 1
call setline(lnum, line . snipLines[0])
call append(lnum, map(snipLines[1:], "empty(v:val) ? v:val : '" . strpart(line, 0, indent - 1) . "' . v:val"))
(The issue being that indent() returns the indentation of the current line in screen columns)
Metadata
Metadata
Assignees
Labels
No labels