latex-suite resolves unfortunately {{ - vim

latex-suite always resolves a {{ immediately to \left\{ \right\}<++>
What is to do about this behaviour, ie. keep the {{ as {{?
Thanks,
Stefan

Related

Vim Search Replace Regexp If this, not that, and not that

I have a page and I'm trying to fix abunch of links to it with regexps.
For example. Somethings were already replaced, and they are in there like href="/websites/site..", so those I'm leaving alone. However, some were replaced from absolute to relative but the script I got that did it thought the files I was changing were at the web root directory they were.. so when i get a match like href="/file" I want to match. Anywho. Here's the regexp I'm working
%s#\v(href\="/)&((href\="/websites)#!|(href\="//)#!)#href="/websites/site/#g
However, it will change a set of entries like this
<a href="/websites/site/websites/site/dog.html">
<a href="/websites/site//">
<a href="doghouse.html">
<a href="/websites/site/doghouse.html">
to this
<a href="/websites/site/href="/websites/site/websites/site/dog.html">
<a href="/websites/site/href="/websites/site//">
<a href="doghouse.html">
<a href="/websites/site/href="/websites/site/doghouse.html">
Any help on getting this search/replace vim regexp right would be greatly appreciated.
Thanks
Okay, here goes!
:%s/\vhref\="\/(\/|websites)#!/href="\/websites\/site
Explanation:
All of the strings you are wanting to change begin with href="/, so including that as a literal seems like the right call.
Then, you want to make sure that neither the literal "websites" nor "/" are present, so that works with (\/|website)#!, then, you want to change it out with the new addition, so the rest is required.
You can do it with :help :global. From your explaination I'm not completely sure what you're trying to do, but you can use this command to exclude lines with "websites" like this: :g!'href="/websites/site/'s/LESS_COMPLICATED_REGEX/RESULT/
Here I use :g! to execute command on all lines that don't match the regex in '' (you can use / instead of ' as usual). The command to execute is the ususal :s but here you can not worry that it will run on the lines that have "websites" string.

VIM - Automatically closing jinja statements

I wonder how to automatically close jinja statements, like html tags.
For example when I type {% for foo in bar %}, {% endfor %} is automatically added two lines below and the cursor in the middle.
I checked how it's done with HTML tags, but I'm not good enough at vim script to adapt this to my problem.
vim endwise can help here, though you may need to do some work to set it up for jinja.
EDIT from reading the plugin code it should work automatically if the filetype is htmljinja or jinja.html

Vim zencoding - Tagging visual lines

Very simple I guess but I cannot get what I perceive to be the correct behavior out of zencoding in vim.
So what I am doing is.
1) selecting using visual a who line.
2) Using <C-e> (rebound) to use zencoding.
3) supply the tags to apply and enter.
What happens is saying using h2 occurs with all.
<h2>
My text
</h2>
However I want it like.
<h2>My Text</h2>
How can I get it like that?
Answer if selecting a line in vim with V (shift+v) zencoding completes a block encoding so "some text" becomes:
<h1>
some text
</h1>
where as using the singular v and then manually selecting text using h,j,k,l the result is inline:
<h1>some text</h1>
If anyone has any other neat tricks let me know.

VIM: Shortcut to insert empty liquid tags?

I'm migrating my blog to Jekyll and using MacVim to write my posts. I notice that I'm writing tags that look like this a lot:
{% highlight bash %}
chmod -R g+w test
{% endhighlight %}
or even...
{{ content }}
Is there a shortcut to insert the {{ }} or {% %} tags?
Note: I'm fairly new to Vim so any help is appreciated. I have Tim Pope's Liquid plugin installed as well as the surround plugin.
You may want to take a look at ragtag by Tim Pope. It provides mappings like <c-x>= for {{ foo }} and <c-x>- for {% foo %}.
If you do not want ragtag and since you have surround installed you may want to create your own mappings. I suggest you create a ~/.vim/after/ftplugin/liquid.vim and put in the following:
let b:surround_45 = "{% \r %}"
let b:surround_61 = "{{ \r }}"
This will create surround mappings for <c-s>= and <c-s>- just like ragtag.
You can always use keyboard maps, like
:imap I{ {{}}<esc>hhi
With it if you type I{ in insert mode it will insert {{}} then switches back to normal mode moves the cursor back to the 1st } then goes to insert mode back.
HTH

help me create a vim snippet (snipmate)

Let's say I have the following snippet:
snippet divt
<div id="${1:div_id}">
${2:'some text'}
</div>
So when I type divt and hit tab twice "'some text'" should be selected, and when I hit tab once more I would like "some text" to be selected (witoutht single quotes). How can I do it?
Edit 1: Thanks for your answers. Probably this example makes more sense:
snippet divt
<div ${1:id="${2:div_id}"}>
</div>
Sometimes I want a div without an id, so i need to be able to delete the id="div_id" altogether. Sometimes i'd like to have an id, so that i can change div_id part only.
I am currently on a promoting trip for UltiSnips which I am maintaning. The snippet that does precisely that looks like this for UltiSnips:
snippet divt "div" b
<div ${1:id="${2:div_id}"}>
</div>
endsnippet
UltiSnips also comes with a converter script for snipMate snippets, so switching should be painless.
SnipMate unfortunately doesn't support nested placeholders but, as per #Benoit's advice, you could use another snippet while editing the second placeholder. Be sure to bring a spinning top with you, though.
I'm not sure what you want to achieve with some text vs 'some text' — both being treated exactly the same way in this context by every html parser on earth — but I would achieve that with a simple
snippet div
<div id="${1:div_id}">
${2}
</div>
and simply typing either
some text
or
'
which would be expanded to (| is the caret)
'|'
thanks to delimitMate or any other similar plugin then
'some text'
Or maybe use surround to change
some text|
into
'some text'
by typing
<Esc>v2bS'
With Surround you can also start with
some text
select it with
v2e
or something similar and type
S'
to add the quotes then select the line with
V
and type
S<div id="div_id">
to obtain
<div id="div_id">
'some text'
</div>
or do it the other way or... someone has to write a blog post with ALL the possible ways to achieve a given task in Vim.

Resources