Text

Twig is a PHP implementation of Jinja2, a python templating engine. Unfortunately there's no specific syntax highlighting support for .twig files in Vim. But that's no real problem as you can use the htmljinja syntax file provided here: http://www.vim.org/scripts/script.php?script_id=1856

To map it to twig, edit vimrc and add:

au BufRead,BufNewFile *.twig set filetype=htmljinja
  
Tags: php twig vim jinja
Text

If you have a string, for example

"The quick brown fox", "The quicker brown fox".

If you try and use the VIM substitute regexp s/"The quick brown."// you'll end up nuking the whole line up to the terminating period mark. This is because the regular expression is acting greedily, and matching up to the second and final " character.

In PERL compatible regexps you would simply modify the expanding part of the regexp to be .? which makes the expression match as little as possible.

In VIM the syntax is slightly different. To do a non-greedy expansion, you use .{-}. For example:

s/"The quick brown.{-}"//

This will leave you with

, "The quicker brown fox".

Tags: vim editors regex