honza / vim-snippets Goto Github PK
View Code? Open in Web Editor NEWvim-snipmate default snippets (Previously snipmate-snippets)
License: MIT License
vim-snipmate default snippets (Previously snipmate-snippets)
License: MIT License
Hey,
This is not really an issue, but maybe you can help me anyway.
I want to write an import guard for C++. So far it looks something like this:
snippet guard
#ifndef ${1:`substitute(expand('%:t'), '\.', '_', 'g')`}
#define $1
#endif /* $1 */
What I get:
#ifndef filename_h
#define filename_h
#endif /* filename_h */
But what I want:
#ifndef FILENAME_H
#define FILENAME_H
#endif /* FILENAME_H */
So how can I capitalize the filename?
Would it be possible to separate C from C++ snippets? I'd like, as an example, to have for (i = 0 ...) in C code, and (with the same snippet name) for (int i = 0...) in C++.
I would be able to commit my own c++ snippets, but I couldn't figure out where the filetype checking happens.
There are shitty trailing spaces in snippets defindex
, defcreate
etc.
I have already tired clear it. What we can do with this? Delete this crazy blank line in snippet?
if I use snippet from new line without spaces everything ok. But when i use it from 2spaces indentation there are trailing spaces. As usual we use this snippets with 2 space indentation, and it is very annoying
example ok
def create
@model_class_name = ModelClassName.new(params[:model_class_name])
respond_to do |format|
if @model_class_name.save
flash[:notice] = 'ModelClassName was successfully created.'
format.html { redirect_to(@model_class_name) }
format.xml { render :xml => @model_class_name, :status => :created, :location => @model_class_name }
else
format.html { render :action => "new" }
format.xml { render :xml => @model_class_name.errors, :status => :unprocessable_entity }
end
end
end
example when spaces
class ApplicationController < ActionController::Base
def create
@model_class_name = ModelClassName.new(params[:model_class_name])
~~ <- this is 2 trailing spaces
respond_to do |format|
if @model_class_name.save
flash[:notice] = 'ModelClassName was successfully created.'
format.html { redirect_to(@model_class_name) }
format.xml { render :xml => @model_class_name, :status => :created, :location => @model_class_name }
else
format.html { render :action => "new" }
format.xml { render :xml => @model_class_name.errors, :status => :unprocessable_entity }
end
end
end
end
Nevermind.
When I use
div.
I get
divclass=""
.
snippet is "overwrite" div
. snippet, any idea to solved this issue? both snippets are usefull
After I install vim-snippets in the vundle way and start vim, vim reports the following errors:
Errors occur when processing the FileType command "*":
E121:Undefined variable: snippets_dir
E116:Invalid arguments for function GetSnippets.
How can I remove these errors and make vim-snippets work?
snippet asd
assert_difference "${1:Model}.${2:count}", $1 do
${3}
end
usually, the snippet may like this
assert_difference "Model.count", 1, do
# bla bla
end
So I think it should be
snippet asd
assert_difference "${1:Model}.${2:count}", ${3:1} do
${4}
end
I'd like to volunteer as the maintainer of the Falcon snippets. I wrote the original set currently in the repo. I'm also technically a falcon developer (I have commit access, but I don't use it much ๐) and I maintain the vim files for falcon as well. So hopefully that makes me qualified for the job.
This repository now contains UltiSnips and snipMate snippets - I think it should be renamed to either Ultisnips (as all of them are supported by ultisnips and not all by snipmate) or simply snippets.
Hi, would be nice if you contact tomorris to merge his scala snippets: https://github.com/tommorris/scala-vim-snippets
nice work!
Hello,
I imagine a lot of other python users have the following problem:
The dot "." snippet conflicts with tab completion functionality. I see this as a problem only because I use a "self." statement much less frequently than I use a not-self "." statement, and I imagine that a lot of python users would feel the same.
For example:
current:
.<<TAB>> ---> self.
import os.<<TAB>> ---> import osself.
desired:
import os.<<TAB>> ---> import os.<<shows the tab completion menu>>
On a grander level, really nice functionality might be for SnipMate to allow us to disable just one snippet. But to my knowledge, that's not currently an option.
Currently, it does take a bit of leg work to remove this snippet manually. Do you think it might be possible to remove or rename that snippet from the python snippets file in this repo?
Youcompleteme and UltiSnips has been integrated. Snippets are listed in completepopup.
But only alphabetic letters can trigger completepopup in youcompleteme.
ycm-core/YouCompleteMe#298
ycm-core/YouCompleteMe#236
'javascript_jsdoc.snippets' cantains non alphabetic snippet titles like '/*', '@au' etc.
I noticed the name of this has gone from snipmate-snippets to vim-snippets, and I've changed my vim config appropriately. I just came across this though;
http://www.vim.org/scripts/script.php?script_id=3633
Which has the old name, and hence a broken link. You may want to update that.
Thanks!
I am using UltiSnips with YouCompleteMe and I like the description of the snippets very much. Many of the default UltiSnips snippets in this repository do not have a description. It is desirable to add these and send pull requests? Are there any guidelines to contributing?
I don't know if this is the right approach, but on my local machine I duplicated the css snippet file and renamed it less
, now it works like a charm in my less files
Should I fork and change it with a pull request? or should I do this another way?
Again, use post-processing snippets to provide extra snippets having everything "joined"?
eg "If" instead of "if" ? We could add tags to snippets to find out which snippets to provide "joined lines" versions of.
In the python.snippets file, there is a '.' snippet that causes me a lot of frustration.
snippet .
self.
However, I find that, instead of it being helpful with writing code more quickly, it tends to only show up when I don't want it to. (for example, when trying to access a submodule and use a different tab completion program, etc).
Plus, because it's a punctuation mark, it's harder to realize the reason 'self' has just popped on to the screen is because of this snippet.
Expected behavior:
bs4.
press , get a set of completion suggestions for functions within beautifulsoup
Actual behavior:
bs4.
press -> bs4self.
I suggest a simple replacement:
snippet s.
self.
(after this I'll submit a small patch to this effect).
And if you want the original behavior back, anyone can make a python.snippets file in their own snippet folder with the original back in. For the new users (and old users), this will enable them to actually use a number of tab completion scripts in vim, etc. Especially those who find out about snipmate through sontek's dotfiles.
Now all python snippets has 'code..' in place, where you need to write code. 'code...' is not valid python code so tools such as pyflakes complains about it. It is much better to user 'pass' instead or at leas turn 'code...' to a comment, like this: '# code...'.
Is it really ok to have multiple 'bt' snippets in ruby.snippets
?
snippet bt
belongs_to :${1:association}
snippet bt
be_true
snippet bf
before_filter :${1:method}
snippet bf
be_false
I'm getting this error when I use spf13:
Warning: /meh/.vim/bundle/snipmate-snippets/snippets/ruby.snippets:939 is overriding `bt` from /meh/.vim/bundle/snipmate-snippets/snippets/ruby.snippet
s:582
The CoffeeScript snippets don't seem to be working.
I've tried renaming the file to .js.coffee
and .coffee
, and setting the filetype to both coffee
and coffeescript
.
The JavaScript snippets work as expected (with a .js
extension)
Add snippet for new fields types:
Warning: $HOME/.vim/bundle/vim-snippets/snippets/python.snippets:172 is overriding ld
from $HOME/.vim/bundle/vim-snippets/snippets/python.snippets:82
Press ENTER or type command to continue
https://github.com/akitaonrails/snipmate-snippets
its jquery snippets is awesome :)
Warning: $HOME/.vim/bundle/vim-snippets/snippets/python.snippets:172 is overriding ld
from $HOME/.vim/bundle/vim-snippets/snippets/python.snippets:82
Hi,
I'm always running into compile error due to the issue with a snippet here:
https://github.com/honza/vim-snippets/blob/master/snippets/go.snippets (line 172)
What is the point of ${0}
? It seems to serve no purpose, and if one forgets to remove it, it causes compile error.
Also, sidenote: Could make a clone of main
for init
as well.
I use MarcWeber/ultisnips, but just can not use snippets in the snippets directory, while snippets in the UltiSnips directory is ok. Could you tell me what should I config?
I freshly installed this plugin, together with garbas/vim-snipmate. I opened a PHP file and checked by typing
:set filetype=<TAB>
that it would autocomplete to php
, so I assume vim recognized the filetype correctly.
But when I try using a snipped, for instance with
for<TAB>
I need to choose between php default
and javascript default
. Why? Did I forget anything to setup?
In model snippet, the save method must be
save(self, _args, *_kwargs):
instead
save(self, force_insert=False, force_update=False):
Perhaps something like this could be added?
snippet fut
from __future__ import ${1}
In python.snippets there is a snippet for gpl. Since this is not python related, it should propably be moved to a global snippets file. Moreover, it would be very convenient, if all the major open source licenses could be added.
Historically UltiSnips (depending on Vim with Python) introduced UltiSnippets and Snipmate introduced "snippets" files. Today UltiSnips can read both, but snipmate cannot. UltiSnips has "advanced" features which are useful in some cases such as "nested snippets" and special triggers - Marc Weber never felt need for special triggers in snipmate because it historically had snippet completion while triggering - and passing arguments to snippets by trigger can be emulated by input() which requires hitting one additional time. Thus which features are worth having or not depends heavily on the judgment of the user.
The big question now is: How should vim-snippets cope with it? Nice habits to keep in mind:
The most simple strategy could be:
This is Marc Weber's favorite solution for now. One example following this is "html_minimal" example.
Please use this issue to discuss alternative solutions emphasizing on why they are better/worse than what I'm proposing above (which is already documented in the README).
If you're fine with the proposal only reply if it looks like the thread comes to a different solution. I'd suggest waiting for about 4 weeks for people to put their opinions.
There is no hurry.
I commented here that I added those comments to the README:
#355
The first PR following this suggestion appeared shortly after:
#362
There is an additional issue: Snippet engines support multiple files anyway: Should there be a simple command which allows finding the file defining a snippet? A simple grep all snippet files being used would be enough probably (eg using grepadd or such). That would be trivial to implement.
Hi,
I've got warnings when I opened a ruby file.
Warning messages are following.
Warning: /Users/xxxx/.vim/bundle/snipmate-snippets/snippets/ruby.snippets:
904: duplicated snippet name `mac`
Please delete this snippet name before.
Warning: /Users/xxxx/.vim/bundle/snipmate-snippets/snippets/ruby.snippets:
906: duplicated snippet name `mrc`
Please delete this snippet name before.
Regards,
Incorrect highlighting (visual-mode selecting) after autocompletion with C-N or C-P. To reproduce the issue, do the following:
foreach
and hit the Tab
variable
will be highlighted, type foo
and press C-P
. foobar
will be substituted.Tab
s $va
instead of value
)I just forward my mail with Honza to HERE
Hi, Honza
I'm one of snippets contributors, Meng Zhuo, I had change my snippet engine into UltiSnip and using vim-snippets in the same time.
However, I found there is a snippets repos in UltiSnip, too.
I'm confused about what if I want to contribute some snippets which repo should I pull to.
Or, Which one of you guys is upstream of these snippets?
Best Regards,
Meng Zhuo
Is it my setup or is there something amiss when you try to name, say, a function starting with the letter 'm'?
For example:
def -> def fname():....
press 'm' (cursor on fname) and you get the admonishment:
E481: No range allowed
any other letter seems to work ok (though I admit I haven't tried them all.)
Hi there!
For those writing a lot of markdown documentation, the original codeblock takes a lot of time to write...
For snipmate, there is a good snippet doing that:
snippet bt-codeblock-short
```
${0:code_snippet}
```
But there is not alternative for Ultisnips. I tried to write my own but I'm having some issues on how to escape the "```"... It seems like the backslash isn't helping.
I tried the following:
\``` # not working but did not expect it to work
\`\`\` # not working either...
With the second one, I get the following error:
SnippetSyntaxError: Invalid line '\\`\\`\\`' in snippets/pandoc.snippets:3
I might be doing something wrong...
I don't want to fork it because of such a minor thing:
ruby.snippets:
...
snippet cfor
<% content_for :${1:head} do %>
${2}
<% end %>
>>>>>>> d46588cad4f48f1fe6f0e80c06b87f9b78792422
Thanks,
Frank
Maybe this is intended behaviour, but I've noticed that when using the { context variable snippet a newline is inserted after the completed tag. This is particularly annoying when using the snippet inside an inline tag, like:
<h1>{</h1>
You end up with:
<h1>{{ }}
</h1>
Thanks.
I feel I'd like to add some custom snippets for certain filetypes, but I'd also like the keep snipmate-snippets as a submodule to my vim bundle. Anyway to extend and keep the custom snippets separate from the snipmate-snippets?
:(
The last line in the "with" snippet in Python should be removed.
snippet with
with ${1:expr} as ${2:var}:
${3:# code...}
${3:# code...}
When trying to use the "m" snippet for objc:
Error detected while processing function snipMate#TriggerSnippet:
line 45:
E486: Pattern not found: \VM%#
and then it looks like:
+ (id)method
{
return nil;
}m
Which is actually the "M" snippet, with an m on the end.
I installed the MarcWeber/ultisnips vim plugin and added this config to my vimrc
:
let g:UltiSnips = {}
"let g:UltiSnips.always_use_first_snippet = 1
let g:UltiSnips.snipmate_ft_filter = {
\ 'default' : {'filetypes': ["FILETYPE", "_"] },
\ 'html' : {'filetypes': ["html", "javascript", "_"] },
\ 'cpp' : {'filetypes': [] },
\ }
Of course the plugin honza/vim-snippets is also added.
Then if I type cla
for one of these ruby snippets, I get an error message and a scratch buffer opens with the following content:
Following is the full stack trace:
Traceback (most recent call last):
File "/home/dsiw/.dotfiles/vim.symlink/bundle/ultisnips/py-code/UltiSnips/__init__.py", line 26, in wrapper
return f(self, *args, **kwds)
File "/home/dsiw/.dotfiles/vim.symlink/bundle/ultisnips/py-code/UltiSnips/__init__.py", line 605, in expand
rv = self._try_expand()
File "/home/dsiw/.dotfiles/vim.symlink/bundle/ultisnips/py-code/UltiSnips/__init__.py", line 1010, in _try_expand
self._do_snippet(snippet, before, after)
File "/home/dsiw/.dotfiles/vim.symlink/bundle/ultisnips/py-code/UltiSnips/__init__.py", line 964, in _do_snippet
si = snippet.launch(text_before, self._visual_content, None, start, end)
File "/home/dsiw/.dotfiles/vim.symlink/bundle/ultisnips/py-code/UltiSnips/__init__.py", line 454, in launch
last_re = self._last_re, globals = self._globals)
File "/home/dsiw/.dotfiles/vim.symlink/bundle/ultisnips/py-code/UltiSnips/text_objects/_snippet_instance.py", line 34, in __init__
self.update_textobjects()
File "/home/dsiw/.dotfiles/vim.symlink/bundle/ultisnips/py-code/UltiSnips/text_objects/_snippet_instance.py", line 70, in update_textobjects
if obj._update(done, not_done):
File "/home/dsiw/.dotfiles/vim.symlink/bundle/ultisnips/py-code/UltiSnips/text_objects/_viml_code.py", line 15, in _update
self.overwrite(_vim.eval(self._code))
File "/home/dsiw/.dotfiles/vim.symlink/bundle/ultisnips/py-code/UltiSnips/_vim.py", line 107, in eval
rv = vim.eval(as_vimencoding(s))
vim.error: invalid expression
What can I do to fix this? Thank's!
Hi, I want to add an snippet for .editorconfig
like this:
snippet ec
; http://editorconfig.org
root = true
[*]
indent_style = ${1:space_or_tab}
indent_size = ${2:indent_size}
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
But I don't know how to add snippets for this type of file, as I put the snippet to a editorconfig.snippets
file just doesn't work. I can put to global \_.snippets
, but I'm not sure if it's suitable. Any suggestions?
Although HTML 5 doctype exist inside html.snippets file, Mac Vim (Terminal) doesn't display it under snippet list.
Screenshot: http://imageshack.us/photo/my-images/861/screenshot20120201at517.png/
I installed vim-snippets
via Vundle. At first everything worked fine. Then I forked the repo and replaced the snippets with my own and now it stopped working. I tried to revert back but it didn't do the trick. I think it's some kind of conflict with the SuperTab plugin, but I'm not sure..
There is a typo on repository description.
A lot of the snippets have // code
or /* code */
as part of their place holders. Every time you don't follow the tab order exactly you end up having an unnecessary comment you need to delete. I think it makes more sense to have place holders there which don't have any content. I.e. ${1}
instead of ${1:/* code */}
. I was wondering if other people think this makes sense too. I would volunteer to change this if people are interested.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.