Vim snipMate tab jump - vim

Vim snipMate doesn't work correctly
finf[Tab] generate
find(:first<+, :conditions => ['<+<+field+> = ?+>', <+true+>]+>)
but cursor set to end of the line and dont jump by placeholders with [Tab]
Update:
I try it with html - all works fine, maybe this doesn't work in *.rb files with Rails snipmates

I think there's something wrong with your snippet. I use snipMate for Python and all the placeholders looks like ${Number[:description]}. Take a look at ~/.vim/snippets/ for examples. Belows there is a simple example for a if statement in ruby :
snippet if
if ${1:condition}
${2}

Related

Disable Vim SnipMate brackets replacement

In Vim, after I installed vim-snipmates, I want to use this snippet to auto complete brackets.
snippet (
(${1})${2}
But, I encountered a problem, if I input things like this:
The last bracket is completed by the snippet when I input the first ( and tab, and this time when I press tab, I want to add another ) to the end and make things like this:
But, it turns out the Vim thinks I want to input a ) to finish everything, so it replaces the last ), and there is still one ) at the end of the line.
I want to know which plugin did this replacement and how can I disable it.
.vimrc
Bundle "MarcWeber/vim-addon-mw-utils"
Bundle "tomtom/tlib_vim"
Bundle "garbas/vim-snipmate"
Bundle "honza/vim-snippets"
I feel it's very hard to describe it.
Rather than using a snippet plugin, say Snipmate, Neosnippet or Ultisnips, the job of auto close parens, brackets or quotes )}]"' is better suited for an autoclose plugin, such as Delimitmate or autopairs.
The second < tab > didn't work like define but jump to the ${2}

How can I get vim find to ignore whitespace?

I have XML entries that span two or more lines sometimes, and so I can look for something like this:
something on one line
But if I try the vim command /something on one line and the line is like this:
something on one
line
then it doesn't find it, because the second text block is actually seen as
something on one^J line
Which might have something to do with the fact that I'm using a DOS formatted file.
How can I get vim search to ignore whitespace and newlines?
In vim search, _s means a new line, a space or a tab. So you can try something such as:
/something on one\_s*line
to match the example string you used as example.
Replacing the spaces with \_s\+ manually is cumbersome. The Search for visually selected text topic on the Vim Tips Wiki has a mapping that does this for you for the current visual selection. You can use it like the built-in * mapping, to search (ignoring spaces) for the current selection. Very handy!
While I like the existing answers, I was looking for a way to do the substitution of spaces to \_s* "automagically" for every search that I type.
Luckily, such a solution is possible, as explained in this reddit post. I ended up using the following command:
cnoremap <expr><space> '/?' =~ getcmdtype() ? '\_s*' : ' '
This makes it so that whenever you type a space in a search command (either / or ?), all spaces that you type are automatically replaced by \_s*.
In fact, I only wanted this behavior for LaTeX files, so I added the following to my .vimrc:
autocmd FileType tex cnoremap <expr><space> '/?' =~ getcmdtype() ? '\_s*' : ' '

How do I get Vim to highlight YAML mapping key when it contains a space?

I'm using Vim 7.3 on Ubuntu linux.
When I'm editing a YAML file
This:
fnordy fnord: fnord
fnords: super fnord
"fnords" would be colorized, but "fnordy fnords" would not be.
How can I fix this? I'm looking at my /usr/share/vim/vim73/syntax/yaml.vim file, but I don't understand it enough to fix this.
UPDATE
:color
slate
:echo &ft
yaml
On fnord: fnordy (at the beginning of the line): yamlBlockMappingKey
On fnordy fnord: fnord (at the beginning of the line): yamlPlainScalar
As a result of steffen's help, I compared both of the parsing commands.
The current script looks like this:
execute 'syn match yamlBlockMappingKey /^\s*\zs'.s:ns_plain_out.'\ze\s*:\%(\s\|$\)/ '.
\'nextgroup=yamlKeyValueDelimiter'
The problem, specifically, is the s:ns_plain_out, which is a non-space pattern
So I changed the pattern to simply match on any character:
execute 'syn match yamlBlockMappingKey /^\s*\zs.*\ze\s*:\%(\s\|$\)/ '.
Which fixes this particular issue.
According to the YAML specification, spaces are valid characters in keys of mappings. Have a look at 3.2.1.1 in the specification and at this example.
I'd say that the highlighting is correct. You have an unmeant linebreak in your first value using quotes (like in this example).
Building on the accepted answer, here's what I put in my .vimrc to get this fix without editing any core vim files:
autocmd FileType yaml execute
\'syn match yamlBlockMappingKey /^\s*\zs.*\ze\s*:\%(\s\|$\)/'

Vim tagslist plugin not detecting custom language (racket)

I've recently started using racket, and one of the first things I've done has been to try and get the vim TagList plugin to work with it. However, it doesn't work in the slightest. I can open racket files and the TagList window will be as blank as if I had opened a text file.
According to the extending page* I have added the following to my ~/.vimrc file:
let Tlist_Ctags_Cmd = 'ctags --langdef=racket --langmap=racket:.rkt --regex-racket=/^\(def[a-zA-Z0-9\-_\?\/\\]+[ \t]+([a-zA-Z0-9\-_\/\\\?]+)/\1/d,definition/'
let Tlist_racket_settings = 'racket;d:Definition'
The extra ctags stuff is also in my ~/.ctags file, but TList was spitting out errors about my setting line not being any good. I did original try to use ctags existing scheme functionality, but I had the same nothing results. To use the existing scheme functionality, i tried the following in my ~/.vimrc
let Tlist_Ctags_Cmd = 'ctags --langmap=scheme:.rkt'
let Tlist_racket_settings = 'racket;f:Functions'
If anyone else has any ideas on how to get it working, then I would be extremely grateful.
Thanks,
I'd post a link to the ctags one page as well, but it wont let me (new user). A link to it can be found on the extending taglist page.
EDIT
ctags from the command line
I can use ctags from the command line. Testing with the ctags line on the TagList FAQ page I get the following:
$ cat ~/.ctags
--langdef=racket
--langmap=racket:.rkt
--regex-racket=/^\(def[a-zA-Z0-9\-_\?\/\\]+[ \t]+([a-zA-Z0-9\-_\/\\\?]+)/\1/d,definition/
--regex-racket=/^\(define\-syntax(\-rule)?[ \t]+([a-zA-Z0-9\-_\/\\\?]+)/\2/m,macro/
--regex-racket=/^\(define?[ \t]+(([a-zA-Z0-9\-_\/\\\?]+)[ \t]+\(lambda|\(([a-zA-Z0-9\-_\/\\\?]+))/\2\3/f,function/
$ ctags -f - --format=2 --excmd=pattern --fields=nks XMMSClient.rkt
defenum XMMSClient.rkt /^(define-syntax defenum$/;" m line:11
defxmmsc XMMSClient.rkt /^(define-syntax defxmmsc$/;" m line:20
libxmmsclient XMMSClient.rkt /^(define libxmmsclient (ffi-lib "libxmmsclient"))$/;" d line:5
Output is the same if I force the language definition with switches, or if I change the language to scheme.
About TagBar
I had not seen TagBar before people had suggested it. Interestingly enough, it just worked with the changes to my .ctags file. Unfortunately, I've not found a setting for showing the tags from all loaded buffers the way TagList does, so I would prefer to use TagList.
I'd post comparison images, but I don't think its going to let me, as a new member. As per romainl's suggestion, I can set the vim filetype to scheme, and it does work. This however only seems like an 80% solution, when the documentation according to the extending pages seems to suggest that what I have should work. Perhaps I should be looking at filing a bug report.
Thanks again,
Here is a small racket snippet I lifted from the official documentation and saved as tt.rkt:
(define (checker p1 p2)
(let ([p12 (hc-append p1 p2)]
[p21 (hc-append p2 p1)])
(vc-append p12 p21)))
Without racket-specific syntax/indent files nothing is shown whether ft is set to racket (of course) or nothing (the default). If I :set ft=scheme, both TagList and TagBar list checker as "function".
From left to right: the file, TagBar, TagList.
From what I understand, "Racket" is a rebranding of some Scheme derivative. If it doesn't deviate too much from the norm, adding this line in your ~/.vimrc may help:
autocmd BufRead,BufNewFile *.rkt set filetype=scheme
I've been struggling with the same issue, though for xslt files... My solution was found by poking around in taglist.vim, whereby I added a line for
let s:tlist_def_xslt_settings = 'xslt;f:function:v:variable'
try doing a search for the s:tlist_def_ parts of the Vim code and put in something which looks sensible. There's a similar mechanism within Tagbar. I've not read the code through in detail, so I don't know why it would need this and not use the output from cta

Inserting $1 in a snippet with snipMate

How can I insert a literal $1 in a snippet, using snipMate? I could not find that information in the manual…
Results in nothing (tries to find a placeholder):
snippet s
$1
Result in $ only:
snippet s
$$1
I found a workaround. Use $${0:1}. SnipMate doesn't interpret ${0}, but seems to insert the default text instead.
Basically, you can't. The closest workaround is using default text:
snippet s
$${1:1}
This requires you to hit tab once.
This is a listed issue with snipMate -- and has been for two years, so I wouldn't hold my breath waiting for it to get fixed.
I am currently on a promoting tour for UltiSnips on StackOverflow. UltiSnips support escaping chars, the corresponding snippet looks like this:
snippet s
\$1
endsnippet
A conversion script for snipMate snippets is shipped with UltiSnips, so switching is easy.

Resources