Code Monkey home page Code Monkey logo

ultisnips's Introduction

Build Status Gitter

UltiSnips

UltiSnips is the ultimate solution for snippets in Vim. It has many features, speed being one of them.

GIF Demo

In this demo I am editing a python file. I first expand the #! snippet, then the class snippet. The completion menu comes from YouCompleteMe, UltiSnips also integrates with deoplete, vim-easycomplete and more. I can jump through placeholders and add text while the snippet inserts text in other places automatically: when I add Animal as a base class, __init__ gets updated to call the base class constructor. When I add arguments to the constructor, they automatically get assigned to instance variables. I then insert my personal snippet for print debugging. Note that I left insert mode, inserted another snippet and went back to add an additional argument to __init__ and the class snippet was still active and added another instance variable.

The official home of UltiSnips is at https://github.com/sirver/ultisnips. Please add pull requests and issues there.

UltiSnips was started in Jun 2009 by @SirVer. In Dec 2015, maintenance was handed over to @seletskiy who ran out of time in early 2017. Since Jun 2019, @SirVer is maintaining UltiSnips again on a very constraint time budget. If you can help triaging issues it would be greatly appreciated.

Quick Start

This assumes you are using Vundle. Adapt for your plugin manager of choice. Put this into your .vimrc.

" Track the engine.
Plugin 'SirVer/ultisnips'

" Snippets are separated from the engine. Add this if you want them:
Plugin 'honza/vim-snippets'

" Trigger configuration. You need to change this to something other than <tab> if you use one of the following:
" - https://github.com/Valloric/YouCompleteMe
" - https://github.com/nvim-lua/completion-nvim
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"

" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"

UltiSnips comes with comprehensive documentation. As there are more options and tons of features I suggest you at least skim it.

There are example uses for some power user features here:

Screencasts

From a gentle introduction to really advanced in a few minutes: The blog posts of the screencasts contain more advanced examples of the things discussed in the videos.

Also the excellent Vimcasts dedicated three episodes to UltiSnips:

ultisnips's People

Contributors

aschrab avatar blueyed avatar ces42 avatar chemzqm avatar cwahbong avatar dnitro avatar gordin avatar gvalkov avatar hikerpig avatar ianoxley avatar jszakmeister avatar kovetskiy avatar lacygoill avatar lencioni avatar lfdm avatar lilyball avatar memand avatar mgedmin avatar mmontu avatar neoascetic avatar osse avatar phillipberndt avatar pjfoley avatar rgiot avatar rudfol avatar seletskiy avatar sirver avatar skeept avatar tafryn avatar vitalk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ultisnips's Issues

Saving visual selection gets stuck when selecting big texts

First of all, I'd like to say a big THANKS for this plugin that I discovered yesterday. It's really easy to use, documentation is precise and quite exhaustive, and the plugin itself is very powerful. Great job !

Well, my problem is that when selecting a quite big amount of text and pressing to reuse it in a snippet, vim gets stuck in the UltiSnips_SaveLastVisualSelection() function for a while. I don't exactly know what the _visual_content.conserve() function is doing, but an optimization would be welcomed :-).

My use-case is the following very simple C snippet, wrapping the selected text into a vim fold:

snippet fold "Add a new vim fold" !b
/*{{{ ${1:topic} */

${0:${VISUAL}}

/*}}} */
endsnippet

When working on a big C file (> 5k lines) without folds, and that I want to add some with this snippet... well I just can't :-D.

Launchpad Details: #LP1178643 LpZ_squall - 2013-05-10 13:46:39 +0200

Saving visual selection gets stuck when selecting big texts

First of all, I'd like to say a big THANKS for this plugin that I discovered yesterday. It's really easy to use, documentation is precise and quite exhaustive, and the plugin itself is very powerful. Great job !

Well, my problem is that when selecting a quite big amount of text and pressing to reuse it in a snippet, vim gets stuck in the UltiSnips_SaveLastVisualSelection() function for a while. I don't exactly know what the _visual_content.conserve() function is doing, but an optimization would be welcomed :-).

My use-case is the following very simple C snippet, wrapping the selected text into a vim fold:

snippet fold "Add a new vim fold" !b
/*{{{ ${1:topic} */

${0:${VISUAL}}

/*}}} */
endsnippet

When working on a big C file (> 5k lines) without folds, and that I want to add some with this snippet... well I just can't :-D.

Launchpad Details: #LP1178643 LpZ_squall - 2013-05-10 13:46:39 +0200

Scoping is weird with python3 in python interpolation and crashes.

I tried list comprehensions inside python interpolated snippets and it seems not to work. When trying to access local variables (say for example the 're' module) it throws NameError and that the variable is not global (in the following case I defined arg = t[4] before the list comprehension).

An error occured. This is either a bug in UltiSnips or a bug in a
snippet definition. If you think this is a bug, please report it to
https://bugs.launchpad.net/ultisnips/+filebug.

Following is the full stack trace:
Traceback (most recent call last):
File "/home/razvan/.vim/bundle/ultisnips/plugin/UltiSnips/init.py", line 23, in wrapper
return f(self, _args, *_kwds)
File "/home/razvan/.vim/bundle/ultisnips/plugin/UltiSnips/init.py", line 602, in expand_or_jump
rv = self._try_expand()
File "/home/razvan/.vim/bundle/ultisnips/plugin/UltiSnips/init.py", line 934, in _try_expand
self._do_snippet(snippet, before, after)
File "/home/razvan/.vim/bundle/ultisnips/plugin/UltiSnips/init.py", line 908, in _do_snippet
si = snippet.launch(text_before, self._visual_content, None, start, end)
File "/home/razvan/.vim/bundle/ultisnips/plugin/UltiSnips/init.py", line 420, in launch
last_re = self._last_re, globals = self._globals)
File "/home/razvan/.vim/bundle/ultisnips/plugin/UltiSnips/text_objects/_snippet_instance.py", line 34, in init
self.update_textobjects()
File "/home/razvan/.vim/bundle/ultisnips/plugin/UltiSnips/text_objects/_snippet_instance.py", line 70, in update_textobjects
if obj._update(done, not_done):
File "/home/razvan/.vim/bundle/ultisnips/plugin/UltiSnips/text_objects/_python_code.py", line 216, in _update
compatible_exec(self._code, self._globals, local_d)
File "", line 9, in
File "", line 9, in
NameError: global name 'arg' is not defined

:py3 import sys; print(sys.version):
3.3.2+ (default, Oct 9 2013, 14:53:41)
[GCC 4.8.1]

Launchpad Details: #LP1259349 Răzvan-Cosmin Rădulescu - 2013-12-10 01:02:18 +0100

Adhere to snippet options when listing snippets

Hi Holger,

atm it isn't possible to invoke the list of the available snippets directly after leaving the last snippet (reaching it's final jump mark) without adding an additional tab or space character.

It would be nice if we could configure the popup list in the same way like snippets, e.g. through:

let g:UltiSnipsPopupOption = "b|i|w"

b = only at the beginning of a line
i = inword expansion (that's what I like to use because I don't have to provide the extra space / tab before I can get the list of snippets again)
w = word boundary

If the variable is left empty, the default could be used which is probably "w" atm.

Tia,
Ulf

Launchpad Details: #LP931372 Ulf Kohlmorgen - 2012-02-13 12:17:44 +0100

Placeholder start/end columns break when using noexpandtab and indented

Using noexpandtabs: When I trigger a placeholder snippet while indented X levels, the selected portion of the placeholder is off. Some examples (in these examples, I'm using # to represent a hard tab, and [selection] to show the resulting selection).

snippet pd "padding"
padding: ${1:0}px;
endsnippet

pd

Expands to --> ###paddin[g: ]px;

The trouble seems directly related to the number of preceding tabs. If there are zero tabs, the issue doesn't appear. Example:

snippet pa "position: absolute"
position: ${1:absolute};
endsnippet

pa

--> ###position: [absol]ute;

pa

--> ##position: [absolu]te;

pa

--> #position: [absolut]e;

pa
--> position: [absolute];

This bug doesn't affect tabstops, which work perfectly for me:

snippet pts "padding with tabstop"
padding: $1px;
endsnippet

pts

--> padding: []px;

MISC

Indentation settings:

set tabstop=2
set shiftwidth=2
set noexpandtab

Sys.version:

2.7.1 (r271:86832, Jul 31 2011, 19:30:53)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)]

Possibly related plugins:

Bundle 'sickill/vim-pasta'
Bundle 'nathanaelkane/vim-indent-guides'

Launchpad Details: #LP985220 Doug Avery - 2012-04-18 22:50:21 +0200

snippet ending with whitespace is not expanded

I want to add a snippet ending with whitespace:

snippet "# "
expanded snippet
endsnippet

But this snippet is not expanded. I use as a keystroke.

python version 2.7.3 (default, Apr 14 2012, 08:58:41) [GCC]

Launchpad Details: #LP1204508 Rinat Shigapov - 2013-07-24 15:04:38 +0200

Extra whitespace when a marker includes a new line

Using this snippet definition, there's an extra space after "name":

snippet defn "defn" b
(defn ${1:name} ${2:
  "${3:doc-string}"
  }[${4:arg-list}]
  $0)
endsnippet

Moreover, when you type a name (for instance, foobar) and hit tab, another space appears at the end of the line when selecting the newline plus the doc-string.

To make it more clear, immediately after snippet expansion I see this:

(defn |name_
  "doc-string"
  [arg-list]
  )

where '|' is the cursor location, and _ is the trailing whitespace being inserted. If I give the function the name foobar, I see this:

(defn foobar__  
  "doc-string|"
  [arg-list]
  )

Only one of trailing whitespaces is highlighted in the selection.

My expectation is for no extra whitespace. This is with a fairly recent version of UltiSnips (from August 5th, 2013).

Launchpad Details: #LP1219973 John Szakmeister - 2013-09-02 22:23:51 +0200

Modifying autocomplete to handle values which haven't been specified

This is the snippet that I have

snippet '^#?inc' "#include <>" !r
#include <$1!p snip.rv = complete(t[1], ['cassert', 'cstdio', 'cstdlib', 'cstring', 'fstream', 'iostream', 'sstream'])>
endsnippet

and the global complete function

global !p
def complete(t, opts):
if t:
opts = [ m[len(t):] for m in opts if m.startswith(t) ]
if len(opts) == 1:
return opts[0]
elif len(opts) > 1:
return "(" + "|".join(opts) + ")"
else:
return ""
endglobal

which I'm trying to modify to return an empty string when there's no match.

But the problem is when I try to input something which hasn't been specified ( for eg. 'vector' ), the cursor jumps from the tabstop to the start of the line.

Launchpad Details: #LP1073816 KS - 2012-11-01 07:28:10 +0100

Crash when expanding a rails snippet+undo

When I open a ruby-rails file such as a model, then go into insert mode, type cla to expand a class snippet and immediately after execute the undo command I recieve the following error:

An error occured. This is either a bug in UltiSnips or a bug in a
snippet definition. If you think this is a bug, please report it to
https://bugs.launchpad.net/ultisnips/+filebug.

Following is the full stack trace:
Traceback (most recent call last):
File "/Users/ianparkinson/.yadr/vim/bundle/vim-scripts-UltiSnips/plugin/UltiSnips/init.py", line 23, in wrapper
return f(self, _args, *_kwds)
File "/Users/ianparkinson/.yadr/vim/bundle/vim-scripts-UltiSnips/plugin/UltiSnips/init.py", line 678, in cursor_moved
self._csnippets[0].replay_user_edits(es)
File "/Users/ianparkinson/.yadr/vim/bundle/vim-scripts-UltiSnips/plugin/UltiSnips/text_objects/_snippet_instance.py", line 50, in replay_user_edits
self._do_edit(cmd)
File "/Users/ianparkinson/.yadr/vim/bundle/vim-scripts-UltiSnips/plugin/UltiSnips/text_objects/_base.py", line 181, in _do_edit
self._del_child(c)
File "/Users/ianparkinson/.yadr/vim/bundle/vim-scripts-UltiSnips/plugin/UltiSnips/text_objects/_base.py", line 301, in _del_child
del self._tabstops[c.no]
KeyError: 2

Launchpad Details: #LP1028411 ian parkinson - 2012-07-24 14:07:02 +0200

Adhere to snippet options when listing snippets

Hi Holger,

atm it isn't possible to invoke the list of the available snippets directly after leaving the last snippet (reaching it's final jump mark) without adding an additional tab or space character.

It would be nice if we could configure the popup list in the same way like snippets, e.g. through:

let g:UltiSnipsPopupOption = "b|i|w"

b = only at the beginning of a line
i = inword expansion (that's what I like to use because I don't have to provide the extra space / tab before I can get the list of snippets again)
w = word boundary

If the variable is left empty, the default could be used which is probably "w" atm.

Tia,
Ulf

Launchpad Details: #LP931372 Ulf Kohlmorgen - 2012-02-13 12:17:44 +0100

filetype detection not working

Just installed UltiSnips from the tarball, on vimscripts version 2.2. It works but I only get the "all" snippets in files which are otherwise correctly identified by the filetype plugin as Perl and BASH files (filetype is correctly showing up in the status line and syntax highlighting and indentation work as before).
Manually adding the filetype with, e.g.
:UltiSnipsAddFiletypes perl

loads the perl snippets and all works correctly.

I have installed UltiSnips as suggested by extracting the tarball into a directory which I then added to the path in my .vimrc

I have seen the same error reported in conjunction with Vundle but I'm not using Vundle, so not sure what the problem could be or how to investigate this further. Thanks for your help!

my vim version
VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Apr 16 2010 12:40:58)

:py import sys; print sys.version
2.6.5 (r265:79063, Oct 1 2012, 22:19:00)
[GCC 4.4.3]

Launchpad Details: #LP1067416 Frank Schwach - 2012-10-16 18:15:45 +0200

Saving visual selection gets stuck when selecting big texts

First of all, I'd like to say a big THANKS for this plugin that I discovered yesterday. It's really easy to use, documentation is precise and quite exhaustive, and the plugin itself is very powerful. Great job !

Well, my problem is that when selecting a quite big amount of text and pressing to reuse it in a snippet, vim gets stuck in the UltiSnips_SaveLastVisualSelection() function for a while. I don't exactly know what the _visual_content.conserve() function is doing, but an optimization would be welcomed :-).

My use-case is the following very simple C snippet, wrapping the selected text into a vim fold:

snippet fold "Add a new vim fold" !b
/*{{{ ${1:topic} */

${0:${VISUAL}}

/*}}} */
endsnippet

When working on a big C file (> 5k lines) without folds, and that I want to add some with this snippet... well I just can't :-D.

Launchpad Details: #LP1178643 LpZ_squall - 2013-05-10 13:46:39 +0200

Ultisnips crashes when tabstop is beyond textwidth

UltiSnips will crash if a tabstop is pushed beyond textwidth and not wrapped before anything is put into the field. Below is a snippet and sample data to reproduce.

---- Sample data to cause crash ----

requires :set tw=80

$1 - Bivens v. Six Unknown Named Agents
$2 - 403 U.S. 388
$3 - 1971
$4 - 440

Crashes on input of $4.

---- Sample Snippet ----

snippet mybrief "outline for a case brief" b
\begin{center}
\underline{\sc ${1:case name}}
\end{center}

\paragraph{Citation:}
{\underline{$1}}, ${2:citation} (${3:year}) (Casebook: ${4:page})

\paragraph{Parties:}
\begin{list}{}{\setlength{\topsep}{3pt}\setlength{\listparindent}{0pt}\setlength{\leftmargin}{1in}\setlength{\parsep}{0pt}\setlength{\parskip}{0pt}\setlength{\itemsep}{3pt}}
\item [\bf{${5:Plaintiff}:}]
\item [\bf{${6:Defendant}:}]
\end{list}

\paragraph{Procedural Posture:} ${7}

\paragraph{Relevant Facts:} ${8}

$0

endsnippet

---- Stack Trace ----

An error occured. This is either a bug in UltiSnips or a bug in a
snippet definition. If you think this is a bug, please report it to
https://bugs.launchpad.net/ultisnips/+filebug.

Following is the full stack trace:
Traceback (most recent call last):
File "/Users/kylechristensen/.vim/plugin/UltiSnips/init.py", line 23, in wrapper
return f(self, _args, *_kwds)
File "/Users/kylechristensen/.vim/plugin/UltiSnips/init.py", line 669, in cursor_moved
rv, es = guess_edit(initial_line, lt, ct, self._vstate)
File "/Users/kylechristensen/.vim/plugin/UltiSnips/_diff.py", line 54, in guess_edit
es.append(("D", sv.line, sv.col, lt[sv.line - initial_line][sv.col:ev.col+1]))
IndexError: list index out of range

---- Work Around ----

Because the work I am doing is in Latex and can include arbitrary single-line carriage returns at this point, the crash can be avoided by separating the variables in the snippet. However, I suspect that there may be other instances of this occurring and may be worth the attention.

---- sys.version ----
2.7.2 (default, Jun 20 2012, 16:23:33)
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)]

Launchpad Details: #LP1095048 Kyle Christensen - 2013-01-01 15:09:27 +0100

Variables in the status bar

Hi Holger,

I'd like to have the option to insert one or more variables into the status bar to let the user know at which position (jump mark) he currently is. Eventually with the current snippet name inside.

E.g.: Field: of:

It would be nice to clear the whole string when the last jump mark is reached so we only have this visual "guide" when we are inside a current snippet.

All variables should be optional, e.g. if somebody doesn't want to see the name of the snippet he just omits that variable.

Regards,
Ulf

Launchpad Details: #LP931366 Ulf Kohlmorgen - 2012-02-13 12:06:00 +0100

Is it possible to replace the text in tabstop?

using the complete() function from the screencast as an example.

def complete(t, opts):
if t:
opts = [m[len(t):] for m in opts if m.startswith(t)]
if len(opts) == 1:
return opts[0]
return '|'.join(opts[:7])

What if the opts are all similar and start with same letters? for example, ['this_is_a', 'this_not_b']. This can be filtered using fuzzy match. But how can it return the result and simply replace the text in tabstop like t[1] = opts[0]?

Launchpad Details: #LP1182251 Zhao Cai - 2013-05-21 00:33:13 +0200

Immediately pressing <Esc>O screws up some snippets

Steps to reproduce:

  1. Open vim with blank .py file
  2. Enter insert mode and type "class"
  3. Press <Esc><Shift-O>

Some extra triple-quotes and some other garbage appears as soon as you type "".

There are similar problems with rwprop and slotclass.

Launchpad Details: #LP1083094 David Barnett - 2012-11-26 10:37:06 +0100

filetype detection not working

Just installed UltiSnips from the tarball, on vimscripts version 2.2. It works but I only get the "all" snippets in files which are otherwise correctly identified by the filetype plugin as Perl and BASH files (filetype is correctly showing up in the status line and syntax highlighting and indentation work as before).
Manually adding the filetype with, e.g.
:UltiSnipsAddFiletypes perl

loads the perl snippets and all works correctly.

I have installed UltiSnips as suggested by extracting the tarball into a directory which I then added to the path in my .vimrc

I have seen the same error reported in conjunction with Vundle but I'm not using Vundle, so not sure what the problem could be or how to investigate this further. Thanks for your help!

my vim version
VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Apr 16 2010 12:40:58)

:py import sys; print sys.version
2.6.5 (r265:79063, Oct 1 2012, 22:19:00)
[GCC 4.4.3]

Launchpad Details: #LP1067416 Frank Schwach - 2012-10-16 18:15:45 +0200

Completion problem inside some snippets when popup menu is disabled

First of all, thank you very much for sharing this great plugin!

I'm switching from snipmate; reading about the merging with UltiSnips I really liked the statement: "A rock solid plugin is more important than fancy features which break from time to time".

I don't like using the popup menu, so I use "set cot=". I've just found that this setting affect some plugin functionality. This problem was reproduced on a clean installation of gVim with no other plugin:

  1. :new

  2. on insert mode insert the following three lines:

    temp1
    temp2
    temp3

  3. On new a line, in insert mode typing bbox<tab>te<c-p><c-p><esc> leads to

temp2

  1. Issuing set cot= and repeating step 3 leads to

tetemp2

The output of :py import sys; print sys.version:
2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)]

Launchpad Details: #LP1229334 mMontu - 2013-09-23 20:04:09 +0200

JumpForward does not happen in certain cases when line is indented

Hi,

I have been using UltiSnips for a very long while with no problems, however recently I came across a strange behavior. Here is a minimal snippet that reproduces the problem:

snippet test "Test snippet" !b
${2:#2} [$1] ${1:#1};$0
endsnippet

The expected behavior is following. You enter some text in the first tabstop (it automatically gets copied over inside the square brackets due to $1 mirror), then you press Tab and enter some text in the second tabstop. Finally, you press Tab once again and jump to the end of the line.

The actual behavior is that after entering the text for the second tabstop and pressing Tab the jump to the end of the line does not happen.

I suspect it is somehow related with the [$1] thing. My experiments show that if you do not modify the default text of the first tabstop (consequently the mirrored text inside the square brackets is not modified), then the jump happens as expected. Also, if you put the [$1] thing before the second tabstop, the behavior will be as expected. To summarize, there seems to be a problem with JumpForward when a tabstop is followed by a mirror of another tabstop (which gets entered earlier).

The output of :py import sys; print sys.version:
2.7.3 (default, Sep 26 2013, 16:38:06)
[GCC 4.7.2]

Regards,
Sergey

Launchpad Details: #LP1251994 Sergey Alexandrov - 2013-11-17 13:15:18 +0100

line out of range on recursed, chained, python snippets

Python:

2.7.2 (default, Jun 20 2012, 16:23:33)
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)]

Snippet definitions:

snippet f "f"
{ ${1} }
endsnippet

snippet jxj "blah" w
k!p if not snip.c: snip.rv = 'x' print "k %r %r" % (snip.c, snip.rv) k
endsnippet

snippet kxk "blah blah" w
m!p if not snip.c: snip.rv = 'x' print "k %r %r" % (snip.c, snip.rv) m
endsnippet

Input:

fjxj

Output:

An error occured. This is either a bug in UltiSnips or a bug in a
snippet definition. If you think this is a bug, please report it to
https://bugs.launchpad.net/ultisnips/+filebug.

Following is the full stack trace:
Traceback (most recent call last):
File "/Users/grayrest/Repositories/vim-ultisnips/plugin/UltiSnips/init.py", line 23, in wrapper
return f(self, _args, *_kwds)
File "/Users/grayrest/Repositories/vim-ultisnips/plugin/UltiSnips/init.py", line 693, in cursor_moved
self._csnippets[0].update_textobjects()
File "/Users/grayrest/Repositories/vim-ultisnips/plugin/UltiSnips/text_objects/_snippet_instance.py", line 70, in update_textobjects
if obj._update(done, not_done):
File "/Users/grayrest/Repositories/vim-ultisnips/plugin/UltiSnips/text_objects/_python_code.py", line 203, in _update
ct = self.current_text
File "/Users/grayrest/Repositories/vim-ultisnips/plugin/UltiSnips/text_objects/_base.py", line 80, in current_text
return _vim.buf[self._start.line][self._start.col:self._end.col]
File "/Users/grayrest/Repositories/vim-ultisnips/plugin/UltiSnips/_vim.py", line 20, in getitem
rv = vim.current.buffer[idx]
IndexError: line number out of range

Interfering Plugins:

disabled delimitMate which is all I believe would interfere, no difference

Remarks:

This is a reduced test case. The bug does not seem to occur when not in another snippet. Does not occur when the snippets aren't Python interpolated. I've included the print for verification that the snippets are only running once but the problem occurs without it as well.

I initially hit this bug in a fairly complicated snippet setup and producing the test case was difficult because it won't always reproduce in larger cases, so be aware if you're trying to reproduce not following the exact sequence. In one case it seemed like I could reproduce it depending on how quickly I hit the expand key. I mention all this in case you can't reproduce. I have expand set to ; and jump forward set to (to eliminate the possibility that for both is causing the problem). I reproduce 100% with the above steps given.

Since I don't know of another channel, I'd like to thank you for making this plugin. I've been messing with snippet-like stuff for years, going through snippets.vim and snipMate in addition to ST2 and the regexp+python snippets allow me to (finally) get the set of snippets I actually want. An example: I write a lot of javascript and property access is fragmented: foo.bar --expand--> foo['bar'] --expand--> foo.get('bar') --expand--> foo.bar makes me happy along with foo.get('bar')s --expand--> foo.set('bar', |).

Launchpad Details: #LP1102284 Karl Guertin - 2013-01-21 07:38:33 +0100

Separate snippets from the engine

UltiSnips is a great engine and I'm really pleased to use it.
But there is this annoyance that it comes with a lot of predefined snippets,
which not everyone might agree to fulfill their needs. For example, I often
use braces in-lined with "if" statements in my project.

I'm filling this bug report so UltiSnips split into two packages: one for the
engine itself, and another for snippets definitions.

Thanks,
Ian L. Rodrigues.

Launchpad Details: #LP1162951 Ian Liu Rodrigues - 2013-04-01 20:50:43 +0200

UltiSnips causes tab characters to not be played back in macros

To reproduce:

  1. Record a macro containing tab characters, e.g.:
    qq i hello [tab] world [esc] q
    The macro will be recorded as 'ihello^Iworld^['.
  2. Play back the macro (@q).

The expected output:
hello world

(a tab character between the words)

The actual output (with UltiSnips enabled):
helloworld

Disabling UltiSnips fixes this issue.


More information:

UltiSnips 2.2 installed using Vundle.

Reproducible in both Vim and GVim 7.3.

The output of :py import sys; print sys.version:
2.7.3 (default, Apr 24 2012, 00:00:54)
[GCC 4.7.0 20120414 (prerelease)]

For what it's worth, SuperTab, which also uses the tab key, doesn't cause this issue.

Launchpad Details: #LP1060289 Hans Chen - 2012-10-02 18:08:54 +0200

selections=old breaks UltiSnips

This is for python 2.7 on windows 7. VIM version 7.3.

In a TeX file (using tex.snippets), the problem is that completing

b

yields

\begin{something}

\end{something}

as expected. But the initial cursor position is right on top of the closing brace on the \begin line. The problem with this is that
when you start typing, it does not fill out the fields properly. You have to move the cursor over one character and THEN begin typing to get the snippet to complete properly.

Any help appreciated!

Launchpad Details: #LP1132315 reckoner - 2013-02-24 03:05:27 +0100

Vim LaTeX Suite interferes with UltiSnips <C-j> <C-k> bindings

Vim LaTeX suite (vim-latex) (http://vim-latex.sourceforge.net/) provides handy utilities for working with LaTeX documents. Unfortunately when it is installed as a plugin along with UltiSnips, it completely ruins the mappings of (Control + J) and (Control + K) such that the user can no longer jump forward and backward in a snippet. Curiously, this happens for all file types, not just .tex files. I have no idea why this happens but I'm hoping someone familiar with UltiSnips internals would be able to test this and have some idea.

Steps to reproduce:

  1. Install UltiSnips and vim-latex plugins using a plugin manager, such as vim-addon-manager or Vundle
  2. Open a file of prefered type in Vim (e.g., "vim foo.py")
  3. Start using a snippet with placeholders (e.g., type "def")
  4. Try to jump to the next placeholder with ; observe the cursor does not advance

Launchpad Details: #LP944215 Chris Lasher - 2012-03-01 19:24:21 +0100

shellcode permission denied

I'm on a shared host, which does not allow for /tmp to have executable scripts.

When I run a snippet with a shellcode in it, I get Permission denied written on screen.

I've modied:
plugin/UltiSnips/text_objects/_shell_code.py
20c20

< handle, path = tempfile.mkstemp(text=True)

    handle, path = tempfile.mkstemp(text=True,dir="/path/to/user/tmp")

Which works fine.

So maybe not a bug, but would it make since to have the shellcode tmp folder configurable or test that /tmp is executable by the user?

:py import sys; print sys.version:
2.7.3 (default, Apr 4 2013, 18:29:03)
[GCC 4.3.2]

Launchpad Details: #LP1164968 Keith Welch - 2013-04-05 14:42:27 +0200

Adhere to snippet options when listing snippets

Hi Holger,

atm it isn't possible to invoke the list of the available snippets directly after leaving the last snippet (reaching it's final jump mark) without adding an additional tab or space character.

It would be nice if we could configure the popup list in the same way like snippets, e.g. through:

let g:UltiSnipsPopupOption = "b|i|w"

b = only at the beginning of a line
i = inword expansion (that's what I like to use because I don't have to provide the extra space / tab before I can get the list of snippets again)
w = word boundary

If the variable is left empty, the default could be used which is probably "w" atm.

Tia,
Ulf

Launchpad Details: #LP931372 Ulf Kohlmorgen - 2012-02-13 12:17:44 +0100

Certain snippets break delimitMate auto-closing tags

It doesn't appear that delimitMate and UltiSnips play well together. DelimitMate can be found here: https://github.com/Raimondi/delimitMate

For example, in the assertEqual snippet (ae):

 ae

becomes

self.assertEqual(|first, second)

where | is the cursor. If I type "asdf('", I expect delimitMate to automatically close the ( and ', giving "asdf('|')". It does not (until pressing Escape).

Strangely, this is not a problem with certain fields of other snippets (like the body part of the 'def' snippet).

DelimitMate works in select mode, so I wonder if this is a problem with UltiSnips.

Launchpad Details: #LP937301 Timothy Mellor - 2012-02-21 00:03:03 +0100

Crash when expanding a rails snippet+undo

When I open a ruby-rails file such as a model, then go into insert mode, type cla to expand a class snippet and immediately after execute the undo command I recieve the following error:

An error occured. This is either a bug in UltiSnips or a bug in a
snippet definition. If you think this is a bug, please report it to
https://bugs.launchpad.net/ultisnips/+filebug.

Following is the full stack trace:
Traceback (most recent call last):
File "/Users/ianparkinson/.yadr/vim/bundle/vim-scripts-UltiSnips/plugin/UltiSnips/init.py", line 23, in wrapper
return f(self, _args, *_kwds)
File "/Users/ianparkinson/.yadr/vim/bundle/vim-scripts-UltiSnips/plugin/UltiSnips/init.py", line 678, in cursor_moved
self._csnippets[0].replay_user_edits(es)
File "/Users/ianparkinson/.yadr/vim/bundle/vim-scripts-UltiSnips/plugin/UltiSnips/text_objects/_snippet_instance.py", line 50, in replay_user_edits
self._do_edit(cmd)
File "/Users/ianparkinson/.yadr/vim/bundle/vim-scripts-UltiSnips/plugin/UltiSnips/text_objects/_base.py", line 181, in _do_edit
self._del_child(c)
File "/Users/ianparkinson/.yadr/vim/bundle/vim-scripts-UltiSnips/plugin/UltiSnips/text_objects/_base.py", line 301, in _del_child
del self._tabstops[c.no]
KeyError: 2

Launchpad Details: #LP1028411 ian parkinson - 2012-07-24 14:07:02 +0200

Adjacent variables merged into the first

Python version:
2.7.2+ (default, Oct 4 2011, 20:41:12)
[GCC 4.6.1]

The following snippet causes a problem:

snippet test "Bug that happens on ${adjacent}${vars}" b
[one=<!p snip.rv = t[1]>, two=<!p snip.rv=t[2]> <${1}${2}>]
endsnippet

When I type "TEXT1TEXT2", t[1] becomes "TEXT1TEXT2", while t[2] remains "". A second "" sends me to $0, as expected.

I expected t[1]="TEXT1" and t[2]="TEXT2".

Launchpad Details: #LP1007629 Silvio Ricardo Cordeiro - 2012-06-02 00:13:10 +0200

Placeholder start/end columns break when using noexpandtab and indented

Using noexpandtabs: When I trigger a placeholder snippet while indented X levels, the selected portion of the placeholder is off. Some examples (in these examples, I'm using # to represent a hard tab, and [selection] to show the resulting selection).

snippet pd "padding"
padding: ${1:0}px;
endsnippet

pd

Expands to --> ###paddin[g: ]px;

The trouble seems directly related to the number of preceding tabs. If there are zero tabs, the issue doesn't appear. Example:

snippet pa "position: absolute"
position: ${1:absolute};
endsnippet

pa

--> ###position: [absol]ute;

pa

--> ##position: [absolu]te;

pa

--> #position: [absolut]e;

pa
--> position: [absolute];

This bug doesn't affect tabstops, which work perfectly for me:

snippet pts "padding with tabstop"
padding: $1px;
endsnippet

pts

--> padding: []px;

MISC

Indentation settings:

set tabstop=2
set shiftwidth=2
set noexpandtab

Sys.version:

2.7.1 (r271:86832, Jul 31 2011, 19:30:53)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)]

Possibly related plugins:

Bundle 'sickill/vim-pasta'
Bundle 'nathanaelkane/vim-indent-guides'

Launchpad Details: #LP985220 Doug Avery - 2012-04-18 22:50:21 +0200

Scoping is weird with python3 in python interpolation and crashes.

I tried list comprehensions inside python interpolated snippets and it seems not to work. When trying to access local variables (say for example the 're' module) it throws NameError and that the variable is not global (in the following case I defined arg = t[4] before the list comprehension).

An error occured. This is either a bug in UltiSnips or a bug in a
snippet definition. If you think this is a bug, please report it to
https://bugs.launchpad.net/ultisnips/+filebug.

Following is the full stack trace:
Traceback (most recent call last):
File "/home/razvan/.vim/bundle/ultisnips/plugin/UltiSnips/init.py", line 23, in wrapper
return f(self, _args, *_kwds)
File "/home/razvan/.vim/bundle/ultisnips/plugin/UltiSnips/init.py", line 602, in expand_or_jump
rv = self._try_expand()
File "/home/razvan/.vim/bundle/ultisnips/plugin/UltiSnips/init.py", line 934, in _try_expand
self._do_snippet(snippet, before, after)
File "/home/razvan/.vim/bundle/ultisnips/plugin/UltiSnips/init.py", line 908, in _do_snippet
si = snippet.launch(text_before, self._visual_content, None, start, end)
File "/home/razvan/.vim/bundle/ultisnips/plugin/UltiSnips/init.py", line 420, in launch
last_re = self._last_re, globals = self._globals)
File "/home/razvan/.vim/bundle/ultisnips/plugin/UltiSnips/text_objects/_snippet_instance.py", line 34, in init
self.update_textobjects()
File "/home/razvan/.vim/bundle/ultisnips/plugin/UltiSnips/text_objects/_snippet_instance.py", line 70, in update_textobjects
if obj._update(done, not_done):
File "/home/razvan/.vim/bundle/ultisnips/plugin/UltiSnips/text_objects/_python_code.py", line 216, in _update
compatible_exec(self._code, self._globals, local_d)
File "", line 9, in
File "", line 9, in
NameError: global name 'arg' is not defined

:py3 import sys; print(sys.version):
3.3.2+ (default, Oct 9 2013, 14:53:41)
[GCC 4.8.1]

Launchpad Details: #LP1259349 Răzvan-Cosmin Rădulescu - 2013-12-10 01:02:18 +0100

python3.2.5

i install python3.2.5 in my xp

my UltiSnips setting is:

let g:UltiSnipsExpandTrigger=""
let g:UltiSnipsListSnippets =""
let g:UltiSnipsJumpForwardTrigge=""
let g:UltiSnipsJumpBackwardTrigge=""
let g:UltiSnipsSnippetDirectories=["bundle/snippets"]

let g:UltiSnipsSnippetsDir=$VIM."/vimfiles/bundle/snippets"

open a c source file with gvim
input for
press ctrl-j
nothing happen
press c-tab
it will list snippets
than press ctrl-j or press ctrl-k are not work

after i install pythonn2.7

the problem above is solved

Launchpad Details: #LP1202684 tracyone - 2013-07-18 15:46:53 +0200

Expanding a snippet in normal mode

Hi,

I am trying to create a source to integrate ultisnips with the plugin unite.vim.
I have an initial version here:
https://github.com/skeept/dotvim/blob/master/bundle/UltiSnips/autoload/unite/sources/ultisnips.vim

In there I use a function to expand a given snippet in normal mode:

function! Expand_snippetUltiUnite(snippet)
exe "normal a" . a:snippet . " "
call UltiSnips_ExpandSnippet()
return ''
endfunction

what this does is literally write the snippet into the file add an additional space and expand the snippet. If I don't add the additional space then I cannot expand the snippet.
Is there a way of making this work, that is expanding a snippet in normal mode?

I know it is asking for a lot but ideally we could have to different ways of calling UltiSnips_ExpandSnippet, the first way is the way is just the way it works now. In the second way we would call this function explicitly with a given snippet like
UltiSnips_ExpandSnippet(a:snippet)
and that would simply expand that corresponding snippet without modifing the previous text in the buffer.

Thanks,
Jorge

Launchpad Details: #LP1206540 Jorge - 2013-07-30 16:37:28 +0200

Ultisnips crashes in new file with text containing 0x80 char

The output of :py import sys; print sys.version:
2.7.3

Snippet definition that makes problems:

Your input (keystroke for keystroke):

The expected output:

The actual output:

Additional vim plugins that might interfere:

Remarks:

I opened a new file (using :new ) and pasted a macro from a register into the buffer. Ultisnips immediately crashed with the following stack trace:

Following is the full stack trace:
Traceback (most recent call last):
File "/users/akondratskiy/.vim/bundle/ultisnips/plugin/UltiSnips/init.py", line 23, in wrapper
return f(self, _args, *_kwds)
File "/users/akondratskiy/.vim/bundle/ultisnips/plugin/UltiSnips/init.py", line 630, in cursor_moved
self._vstate.remember_position()
File "/users/akondratskiy/.vim/bundle/ultisnips/plugin/UltiSnips/init.py", line 485, in remember_position
self._poss.append(_VimPosition())
File "/users/akondratskiy/.vim/bundle/ultisnips/plugin/UltiSnips/init.py", line 462, in init
pos = _vim.buf.cursor
File "/users/akondratskiy/.vim/bundle/ultisnips/plugin/UltiSnips/_vim.py", line 55, in fget
col = byte2col(line, nbyte)
File "/users/akondratskiy/.vim/bundle/ultisnips/plugin/UltiSnips/compatibility.py", line 67, in byte2col
return len(line[:nbyte].decode(vim.eval("&encoding")))
File "/projects/video/software/tools/Python-2.7.3/lib/python2.7/encodings/utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x80 in position 25: invalid start byte

The crash would consistently happen if I moved into the buffer. It seems that there was a <80> char in the macro because I used backspace when recording it. As soon as I removed that character, the problem dissapeared.

Thank you.

Launchpad Details: #LP1015134 Alexander Kondratskiy - 2012-06-19 16:07:29 +0200

Wrong tabstop position with non-latin characters

I have the following snippet:

snippet se "" b
,{
  'AUTHOR': '${1:Williams}',
  'TEXT': '${VISUAL}$2',
}
endsnippet

When I skip first tabstop without changing default text, the second tabstop shows itself beyond single quotes as if we would have ...'$2,... instead of ...$2',... But when default text in the first tabstop is changed the second tabstop appears in the right place.

Launchpad Details: #LP1256451 Andrei - 2013-11-30 00:11:05 +0100

Provide an option to delete/keep around leading whitespace

Given the following snippet:

snippet desc "spec context" !b
context "${1:desc}" do
  ${2:before do
    $3
  end}

  $0
end
endsnippet

This snippet works perfectly as expected, except when I use it in an indented area, such as:

describe MyClass do
  context "description" do
    before do
      # setup code
    end
..
    # context code
end
end

The two dots ("..") are trailing whitespace left by the snippet. It's trying to match the indent level where I began the snippet, but there's no reason for this on a blank line, which should just be left blank.

Launchpad Details: #LP992694 Chris - 2012-05-01 18:23:54 +0200

Crash when expanding a rails snippet+undo

When I open a ruby-rails file such as a model, then go into insert mode, type cla to expand a class snippet and immediately after execute the undo command I recieve the following error:

An error occured. This is either a bug in UltiSnips or a bug in a
snippet definition. If you think this is a bug, please report it to
https://bugs.launchpad.net/ultisnips/+filebug.

Following is the full stack trace:
Traceback (most recent call last):
File "/Users/ianparkinson/.yadr/vim/bundle/vim-scripts-UltiSnips/plugin/UltiSnips/init.py", line 23, in wrapper
return f(self, _args, *_kwds)
File "/Users/ianparkinson/.yadr/vim/bundle/vim-scripts-UltiSnips/plugin/UltiSnips/init.py", line 678, in cursor_moved
self._csnippets[0].replay_user_edits(es)
File "/Users/ianparkinson/.yadr/vim/bundle/vim-scripts-UltiSnips/plugin/UltiSnips/text_objects/_snippet_instance.py", line 50, in replay_user_edits
self._do_edit(cmd)
File "/Users/ianparkinson/.yadr/vim/bundle/vim-scripts-UltiSnips/plugin/UltiSnips/text_objects/_base.py", line 181, in _do_edit
self._del_child(c)
File "/Users/ianparkinson/.yadr/vim/bundle/vim-scripts-UltiSnips/plugin/UltiSnips/text_objects/_base.py", line 301, in _del_child
del self._tabstops[c.no]
KeyError: 2

Launchpad Details: #LP1028411 ian parkinson - 2012-07-24 14:07:02 +0200

Scoping is weird with python3 in python interpolation and crashes.

I tried list comprehensions inside python interpolated snippets and it seems not to work. When trying to access local variables (say for example the 're' module) it throws NameError and that the variable is not global (in the following case I defined arg = t[4] before the list comprehension).

An error occured. This is either a bug in UltiSnips or a bug in a
snippet definition. If you think this is a bug, please report it to
https://bugs.launchpad.net/ultisnips/+filebug.

Following is the full stack trace:
Traceback (most recent call last):
File "/home/razvan/.vim/bundle/ultisnips/plugin/UltiSnips/init.py", line 23, in wrapper
return f(self, _args, *_kwds)
File "/home/razvan/.vim/bundle/ultisnips/plugin/UltiSnips/init.py", line 602, in expand_or_jump
rv = self._try_expand()
File "/home/razvan/.vim/bundle/ultisnips/plugin/UltiSnips/init.py", line 934, in _try_expand
self._do_snippet(snippet, before, after)
File "/home/razvan/.vim/bundle/ultisnips/plugin/UltiSnips/init.py", line 908, in _do_snippet
si = snippet.launch(text_before, self._visual_content, None, start, end)
File "/home/razvan/.vim/bundle/ultisnips/plugin/UltiSnips/init.py", line 420, in launch
last_re = self._last_re, globals = self._globals)
File "/home/razvan/.vim/bundle/ultisnips/plugin/UltiSnips/text_objects/_snippet_instance.py", line 34, in init
self.update_textobjects()
File "/home/razvan/.vim/bundle/ultisnips/plugin/UltiSnips/text_objects/_snippet_instance.py", line 70, in update_textobjects
if obj._update(done, not_done):
File "/home/razvan/.vim/bundle/ultisnips/plugin/UltiSnips/text_objects/_python_code.py", line 216, in _update
compatible_exec(self._code, self._globals, local_d)
File "", line 9, in
File "", line 9, in
NameError: global name 'arg' is not defined

:py3 import sys; print(sys.version):
3.3.2+ (default, Oct 9 2013, 14:53:41)
[GCC 4.8.1]

Launchpad Details: #LP1259349 Răzvan-Cosmin Rădulescu - 2013-12-10 01:02:18 +0100

error on list of snippets for LaTeX

I am using UltiSnips on Kubuntu 12.04. When I call UltiSnips_ListSnippets(), the line that should be 20 reads 'ef{}"r) "'. Looking at the snippets file, it is the snippet for 'chapter'. I can't see anything wrong on the snippets.
This happens every time I open the snippet list.

2.7.3 (default, Aug 1 2012, 05:25:23)
[GCC 4.6.3]

Launchpad Details: #LP1170868 Rene Vergara - 2013-04-20 04:14:52 +0200

Use a completion dialog for multiple matches

This started in bug #714119, the ideas are summarized here.

The idea is to use the standard vim completion window when more than one completion matches the typed text. This seems like a much cleaner way of handling this case, rather than using the menu UltiSnips uses now.

You can force a completion menu using the complete() function. I don't think you can find out exactly which thing the user picks though. I was thinking that maybe we could trigger the completion window, and if it matched multiple snippets with the same trigger, then we could append a number (or similar) to the end to make them unique. We can add the number to the "word" part of the completion-item and not the "abbr" part which is shown in the menu (see complete-items). If we did this, then we would need to temporarily add the new triggers to the snippet as well.

For the regular expressions, we may be able to temporarily do something to make them unique, then if it's picked, put the original text back in and force that snippet to expand so that the match information is generated properly

Launchpad Details: #LP715955 Ryan Wooden - 2011-02-09 19:22:59 +0100

supr should act like backspace when deleting

Suppose this snippet:

snippet el_notify_user "tools" !b
el_notify_user ${2:$}"$1" ${4:$}"$3"$0
endsnippet

Where when its triggered, you first edit the first parameter which is a message, the second parameter is by default the value $ which is prefixed to the "message" (in bash it means that the message will be translated), so sometimes we need it and sometimes not, in short i wrote it on that way for be able to delete or maintain this char, but there comes the problem:

If you press backspace, the $ char is deleted and you can forward to the third entry, but if you use Supr instead of Backspace, the snippet "stops" on this step (not sure how to call it)

Thanks
Thanatermesis

Launchpad Details: #LP1054112 Thanatermesis - 2012-09-21 17:01:19 +0200

Placeholder start/end columns break when using noexpandtab and indented

Using noexpandtabs: When I trigger a placeholder snippet while indented X levels, the selected portion of the placeholder is off. Some examples (in these examples, I'm using # to represent a hard tab, and [selection] to show the resulting selection).

snippet pd "padding"
padding: ${1:0}px;
endsnippet

pd

Expands to --> ###paddin[g: ]px;

The trouble seems directly related to the number of preceding tabs. If there are zero tabs, the issue doesn't appear. Example:

snippet pa "position: absolute"
position: ${1:absolute};
endsnippet

pa

--> ###position: [absol]ute;

pa

--> ##position: [absolu]te;

pa

--> #position: [absolut]e;

pa
--> position: [absolute];

This bug doesn't affect tabstops, which work perfectly for me:

snippet pts "padding with tabstop"
padding: $1px;
endsnippet

pts

--> padding: []px;

MISC

Indentation settings:

set tabstop=2
set shiftwidth=2
set noexpandtab

Sys.version:

2.7.1 (r271:86832, Jul 31 2011, 19:30:53)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)]

Possibly related plugins:

Bundle 'sickill/vim-pasta'
Bundle 'nathanaelkane/vim-indent-guides'

Launchpad Details: #LP985220 Doug Avery - 2012-04-18 22:50:21 +0200

Adhere to snippet options when listing snippets

Hi Holger,

atm it isn't possible to invoke the list of the available snippets directly after leaving the last snippet (reaching it's final jump mark) without adding an additional tab or space character.

It would be nice if we could configure the popup list in the same way like snippets, e.g. through:

let g:UltiSnipsPopupOption = "b|i|w"

b = only at the beginning of a line
i = inword expansion (that's what I like to use because I don't have to provide the extra space / tab before I can get the list of snippets again)
w = word boundary

If the variable is left empty, the default could be used which is probably "w" atm.

Tia,
Ulf

Launchpad Details: #LP931372 Ulf Kohlmorgen - 2012-02-13 12:17:44 +0100

Feature request: show where same triggers comes from.

I use command :UltiSnipsAddFiletypes vim.python.
Then I have same trigger "try" in both snippets/vim/vim.snippets and snippets/python/python.snippets.
I do not want to add comment in every tigger like this:
snippet try "try .. except .. (from python)" b
...
endsnippet.

I hope UltiSnips will auto append this info.
Like this:
when I type "try", then UltiSnips find same trigger,
then shows:
1: (try) "try .. catch* .. endtry -- exception" (python/python)
2: (try) "try .. finally .. endtry -- exception" (python/oop)
3: (try) "try .. except .." (vim/vim)

The format "(python/python)" is from file structure snippets/python/python/snippets.

Launchpad Details: #LP1048433 stardiviner - 2012-09-10 03:12:19 +0200

Adjacent variables merged into the first

Python version:
2.7.2+ (default, Oct 4 2011, 20:41:12)
[GCC 4.6.1]

The following snippet causes a problem:

snippet test "Bug that happens on ${adjacent}${vars}" b
[one=<!p snip.rv = t[1]>, two=<!p snip.rv=t[2]> <${1}${2}>]
endsnippet

When I type "TEXT1TEXT2", t[1] becomes "TEXT1TEXT2", while t[2] remains "". A second "" sends me to $0, as expected.

I expected t[1]="TEXT1" and t[2]="TEXT2".

Launchpad Details: #LP1007629 Silvio Ricardo Cordeiro - 2012-06-02 00:13:10 +0200

list_snippets does not show potential regex defined snippet

For example, if I have the following snippet. type u and hit <C-tab> will not show the following snippet as possible match.

global !p
def upper_right(inp):
return (75 - 2 * len(inp))*' ' + inp.upper()
endglobal

snippet /upper_right|ur/ "text ... TEXT" r
${1:Text}!p snip.rv = upper_right(t[1])
$0
endsnippet

Launchpad Details: #LP1171276 Zhao Cai - 2013-04-22 03:33:23 +0200

autocompletion function generating spurious text

The output of :py import sys; print sys.version:
2.7.3 (default, Sep 26 2012, 21:53:55)
[GCC 4.7.2]

I'm working with a Rails function that takes an argument and two distinct sets of options. The second set is delimited by curly braces. I use three snippets to (1) expand the function, (2) autocomplete among the first set of options, (3) autocomplete among the second set of options. I'm using the autocomplete idea you described in your video:

def complete(t, opts):
if t:
opts = [ q[len(t):] for q in opts if q.startswith(t) ]
if len(opts) == 0:
return ''
if len(opts) == 1:
return opts[0]
return "(" + '|'.join(opts) + ')'

def remaining_options(string, opts):
return [opt for opt in opts if opt not in string]

def autocomplete_options(t, string, attr=None):
if attr is None:
attr = []
return complete(t[1], remaining_options(string, attr))

and the snippets are

snippet ff "form_for" w
form_for ${1:record}${0:, options = {}} do |${2:f}|
endsnippet

snippet /form_for(?!.{.$)(.*,)/ "form_for options" rw!
!p auto = autocomplete_options(t, match.group(1), attr=["url: ", "namespace: ", "html: {"]) snip.rv = "form_for" + match.group(1) + " "$1!p if (snip.c != auto) : snip.rv=auto
endsnippet

snippet /form_for(.){([^|])/ "form_for html options" rw!
!p auto = autocomplete_options(t, match.group(2), attr=["id: ", "class: ", "title: "]) snip.rv = "form_for" + match.group(1) + "{"$1!p if (snip.c != auto) : snip.rv=auto
endsnippet

I can get in position for the second snippet by typing

ff@useru,

which generates

form_for @user, do |u|

as I expect; then typing

nsome_namespace,h

gets to the entry point for the third snippet

form_for @user, namespace: some_namespace, html: { do |u|

provides the html options from the third snippet

form_for @user, namespace: some_namespace, html: {(id: |class: |title: ) do |u|

then i doesn't autocomplete 'id: ' like I expect, instead it replaces the text two lines above the current line with
form_for @user, namespace: some_namespace, html: {

This happens with all other plugins deactivated (except for vundle).

I really like this plugin. It's immensely helpful. Thanks for writing it.

Launchpad Details: #LP1191617 Brian Gates - 2013-06-17 04:18:02 +0200

filetype detection not working

Just installed UltiSnips from the tarball, on vimscripts version 2.2. It works but I only get the "all" snippets in files which are otherwise correctly identified by the filetype plugin as Perl and BASH files (filetype is correctly showing up in the status line and syntax highlighting and indentation work as before).
Manually adding the filetype with, e.g.
:UltiSnipsAddFiletypes perl

loads the perl snippets and all works correctly.

I have installed UltiSnips as suggested by extracting the tarball into a directory which I then added to the path in my .vimrc

I have seen the same error reported in conjunction with Vundle but I'm not using Vundle, so not sure what the problem could be or how to investigate this further. Thanks for your help!

my vim version
VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Apr 16 2010 12:40:58)

:py import sys; print sys.version
2.6.5 (r265:79063, Oct 1 2012, 22:19:00)
[GCC 4.4.3]

Launchpad Details: #LP1067416 Frank Schwach - 2012-10-16 18:15:45 +0200

Adjacent variables merged into the first

Python version:
2.7.2+ (default, Oct 4 2011, 20:41:12)
[GCC 4.6.1]

The following snippet causes a problem:

snippet test "Bug that happens on ${adjacent}${vars}" b
[one=<!p snip.rv = t[1]>, two=<!p snip.rv=t[2]> <${1}${2}>]
endsnippet

When I type "TEXT1TEXT2", t[1] becomes "TEXT1TEXT2", while t[2] remains "". A second "" sends me to $0, as expected.

I expected t[1]="TEXT1" and t[2]="TEXT2".

Launchpad Details: #LP1007629 Silvio Ricardo Cordeiro - 2012-06-02 00:13:10 +0200

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.