A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/garbas/vim-snipmate/issues/143 below:

Placeholders are incorrectly replaced with noexpandtab when on indented lines · Issue #143 · garbas/vim-snipmate · GitHub

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:

However, if I then start typing "d" to replace "env" I get the following:

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)


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4