Export to GitHub

zen-coding - issue #16

Vim support?


Posted on Sep 27, 2009 by Swift Bear

Vim support of this would be quite cool :)

Comment #1

Posted on Oct 7, 2009 by Quick Dog

I miss this feature too

Comment #2

Posted on Oct 7, 2009 by Happy Hippo

OK, see what I can do. Can someone point me to the good resource about extending vim with Python for newbies? I never worked with vim.

Comment #3

Posted on Oct 7, 2009 by Happy Hippo

(No comment was entered for this change.)

Comment #4

Posted on Oct 7, 2009 by Swift Bear

there isn't really very many tutorials on this. This was the best tutorial that I could find: http://www.builderau.com.au/program/python/soa/Extending-Vim-with-Python/0,2000064084,339283181,00.htm

I also wrote my own short vim script for python block commenting and I think it's a simple example of how this would work in vim: http://andre.smoenux.webfactional.com/blog/2009/sep/13/block-comenting-python-code-vim/

Before you start, I found a snippets vim script that basically does what your script already does, and also supports various other really cool features. It's called snipmate. Looks like it may be tough competition to beat that one, since it's already quite feature full. Snipmate for vim can be found here: http://www.vim.org/scripts/script.php?script_id=2540

hope this helps.

Comment #5

Posted on Oct 14, 2009 by Happy Hippo

There's a similar project called Sparkup with extended syntax: http://github.com/rstacruz/sparkup Vim support included

Comment #6

Posted on Oct 14, 2009 by Quick Dog

i'll have a try. can we create a wiki page for the vim support? thanks

Comment #7

Posted on Oct 14, 2009 by Happy Hippo

I plan to refactor documentation in the near future. Maybe at that moment ZC will have Vim support

Comment #8

Posted on Nov 22, 2009 by Helpful Dog

Came here to ask for the same thing, though sparkup looks pretty good. Maybe combine forces or something?

Comment #9

Posted on Nov 23, 2009 by Quick Kangaroo

It looks like it'd probably be pretty easy to write a vim plugin for this.. You can control the cursor and buffer directly using python. Look at http://vimdoc.sourceforge.net/htmldoc/if_pyth.html. I've also attached the (hacked together) beginnings of a plugin to do it, since you said you've not worked with vim. It doesn't move the cursor or anything at the moment though.

Attachments

Comment #10

Posted on Dec 1, 2009 by Massive Horse

I made and attached a VIM script to expand abbreviation. Modified from TextMate the plugin.

It registers a shortcut Ctrl+L and only works in insert mode. When pressed, will expand the abbreviation and move the cursor to the first insertion point.

I hope that this script could be helpful.

Attachments

Comment #11

Posted on Dec 1, 2009 by Quick Dog

Hi org.yi.dttvb,

I tried your script together with the most recent trunk of zencoding, but I had to rename the call expand_abbr to expand_abbreviation and after that it did not throw any error, but does nothing more than remove the last word from the current line. Which version of zencoding do you use?

Comment #12

Posted on Dec 1, 2009 by Massive Horse

boyerchen,

I used zencoding library that comes with the TextMate plugin v0.3.1. It can be downloaded from the front page. The filename is "Zen Coding for TextMate v0.3.1.zip".

I will try it with the most recent trunk and upload a modified script later.

Comment #13

Posted on Dec 1, 2009 by Massive Horse

Here is the script updated to work with the trunk.

Attachments

Comment #14

Posted on Dec 1, 2009 by Quick Dog

Awesome, this works for me, too. Thanks a lot!

Comment #15

Posted on Dec 1, 2009 by Swift Camel

Comment deleted

Comment #16

Posted on Dec 2, 2009 by Happy Panda

Hey, org.yi.dttvb.

Is this fully functional vim zen-coding plugin? If so, awesome. If not, what there is and what there is not?

Comment #17

Posted on Dec 2, 2009 by Happy Panda

Comment deleted

Comment #18

Posted on Dec 2, 2009 by Happy Panda

as I understand the source of this file should be pasted in .vimrc ,but where do I place "zen coding for textmate" files?

Comment #19

Posted on Dec 2, 2009 by Grumpy Rabbit

Comment deleted

Comment #20

Posted on Dec 2, 2009 by Grumpy Rabbit

Comment deleted

Comment #21

Posted on Dec 2, 2009 by Quick Dog

svn checkout http://zen-coding.googlecode.com/svn/trunk/ zen-coding-read-only

then go to the zen-coding-read-only/python folder, just copy the "zen-coding" folder to the path as .vimrc's

Comment #22

Posted on Dec 2, 2009 by Quick Dog

as now on, sparkup has more features than zen-coding's vim plugin I use sparkup instead

Comment #23

Posted on Dec 2, 2009 by Grumpy Rabbit

as of first lookup it seems that evething is ok. Can somebody provide some test cases?

Comment #24

Posted on Dec 2, 2009 by Happy Monkey

To Comment 13 by org.yi.dttvb

Are there any special requirements for script to work? After installing and trying to expand anything I get such output:

Error detected while processing function ZenCodingExpandAbbr: line 2: E319: Sorry, the command is not available in this version: ^Ipython << EOF line 4: E492: Not an editor command: import vim, os, sys, re line 6: E492: Not an editor command: sys.path.append (vim.eval('s:sfile')) line 8: E492: Not an editor command: from zencoding import zen_core line 10: E492: Not an editor command: cur_line = vim.current.line line 11: E492: Not an editor command: cur_index = vim.current.window.cursor[1] line 12: E492: Not an editor command: cur_line_num = vim.current.window.cursor[0] - 1 line 14: E492: Not an editor command: already_placed = 0 line 15: E492: Not an editor command: def get_insertion_point(text): E486: Pattern not found: lre line 17: E121: Undefined variable: not E15: Invalid expression: not already_placed: line 48: E171: Missing :endif

Comment #25

Posted on Dec 2, 2009 by Massive Horse

smmurf,

Your vim does not support Python interface. See:

http://vimdoc.sourceforge.net/htmldoc/if_pyth.html#python

Comment #26

Posted on Dec 3, 2009 by Massive Horse

I updated it a bit. I moved the Python code to a separate Python module, and added a "wrap" functionality.

Put zencoding folder and zencoding_vim.py to the same directory as the VIM script. (if you use ~/.vimrc, you should put these files and folders in your home directory. If you put the script somewhere else and :source it, put these in the same directory as the script)

I changed the key mapping a bit:

Ctrl+L on Insert Mode: Prompts for an abbreviation and insert it. Ctrl+L on Visual Mode: Prompts for an abbreviation and then wrap with abbreviation Ctrl+E on Insert Mode: Expand abbreviation (was ctrl+l on previous version, like TextMate which uses Command-E) Tab on Insert Mode: Same as Ctrl+E, except that it inserts a tab if no abbreviation is found.

Of course you can customize the key mapping or even disable some. The key mapping codes are in the top of the file, followed by the main code.

2 attachments.

Attachments

Comment #27

Posted on Dec 10, 2009 by Happy Panda

well, which one should be used? sparkup or zencoding.vim with python? (the problem with the python vim script is that it requires vim to be compiled with python support, and that isn't common on windows systems)

and if I understand right zencoding.vim uses textmates zen-coding files, which means that it works with the official zencoding release, right?

Comment #28

Posted on Jan 12, 2010 by Massive Hippo

I manage to run my vim with zen-coding (thanks org.yi.dttvb). It was pretty simple on Ubuntu. I just had to figure out path to zencoding for svn, final command is:

svn co http://zen-coding.googlecode.com/svn/trunk/python/zencoding

I haven't tested it enough yet, but I think that wrapping abbreviation is not correct. When I watched screencast from Coda, it should wrap somthing like this:

home contact about

with this: ul>li into this:

  • home
  • contact
  • about

But it is possible that I didn't do it correctly.

Comment #29

Posted on Jan 12, 2010 by Massive Horse

Use: ul>li*

Comment #30

Posted on Jan 16, 2010 by Massive Rhino

Could anybody please compile some instructions on a wiki page?

I dont really understand what frederik.zou means here: http://code.google.com/p/zen-coding/issues/detail?id=16#c21

Maybe other people are asking the same questions themselves...

Thanks

Comment #31

Posted on Jan 26, 2010 by Grumpy Panda

Sparkup is really nice, and seems very smart when using the "<" operator. IMHO you should really join your plugins together. For the moment I will use Sparkup to work with MacVim, I will also wait for the official release of Zen Coding for Vim. Thanks a lot for these wonderful plugins.

Comment #32

Posted on Feb 2, 2010 by Happy Hippo

Could you please pack it as a vim tarball? If so, it will be more convenient for us. Currently it's a little confusing about how to organize these dirs and files.

Comment #33

Posted on Feb 15, 2010 by Happy Hippo

Issue 73 has been merged into this issue.

Comment #34

Posted on Feb 21, 2010 by Quick Hippo

I'm new to vim . I really wonder how this script work ?

Comment #35

Posted on Apr 11, 2010 by Swift Rhino

It looks like Matz started writing one about a month ago: http://github.com/mattn/zencoding-vim

Comment #36

Posted on Dec 21, 2010 by Grumpy Wombat

Hey Sergey, there is some good info on the IBM site about writing plugins for vi/m. The url is huge (4 lines in this text field), so I used a shortener; http://bit.ly/gmgFvG will take you to the IBM search results page of 8 documents containing lots of good info. While they specifically use perl script examples, they explain how it can be done the same way with other scripting languages including python.

I really hope that you can transform your original plugin to work with vim, as I really miss it's elegance while working on headless cli-only servers!

Thank you again for this extremely useful plugin! I use it with Komodo and Textmate and can't wait to use it with vim! :)

Jeff Hales (AKA QBass) <-- so you recognize me supporting your project in other places on the web. :))

Comment #37

Posted on Dec 29, 2010 by Happy Rabbit

So how is the support for Vim going? I mean officially. All the third party scripts I've found either lack features, buggy or outdated and not working at all. The most updated one is the one by the Japanese dev, it has lots of bugs and the html output is very inconsistent.

Comment #38

Posted on Dec 29, 2010 by Happy Hippo

No progress right now, because I never worked with vim so I don't even know how to do basic stuff in this editor :) But I can see how big vim community is, so at least I'll try when I'm done with v0.7 of Zen Coding

Comment #39

Posted on Feb 1, 2011 by Happy Camel

Oh, btw, if you'd want to know how to do basic stuff, there is a great link for you :) http://www.derekwyatt.org/vim/vim-tutorial-videos/vim-novice-tutorial-videos/

Just awesome screencasts.

I don't use vim often, but after watching these videos I'd try to dig in, and an absence of zen-coding is somewhat a stopper for me.

Comment #40

Posted on Feb 1, 2011 by Happy Hippo

(No comment was entered for this change.)

Comment #41

Posted on May 17, 2011 by Helpful Ox

Что насчет Vim? Очень нужно! https://github.com/bingaman/vim-sparkup - неплохо, но очень уступает по функциональности. Сергеи, пожалуиста, если будет время. Заранее спасибо

Comment #42

Posted on May 17, 2011 by Happy Hippo

Есть ещё http://www.vim.org/scripts/script.php?script_id=2981 Я сам с vim никогда не работал, поэтому мне сложно будет даже привыкнуть к нему сначала

Status: Accepted

Labels:
Type-EditorSupport Priority-Medium