Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: There's a level in Hell reserved for ________

by jonadab (Parson)
on Mar 01, 2003 at 23:20 UTC ( #239792=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: There's a level in Hell reserved for ________
in thread There's a level in Hell reserved for ________

Is it scriptable, really? I've never seen anyone claim that vim was fully scriptable before. I know about the Perl embedding (which is indeed cool, since there are (a small handful of) things Perl makes significantly easier than elisp), but maybe we're stumbling over the definition of scriptable.

When I say scriptable, I mean that every action is scriptable. I'm not talking about giving the user the ability to create scripts and then call them at will (that's more like what I call macro facility), but the ability to completely rewrite the editor's behavior in arbitrary circumstances. So, for example, in a truly scriptable editor, I can create a mode just for quizzing questions, and I can set that mode up so that when I type a question in and finish up with a question mark that causes my function (quizques-electric-question-mark or somesuch) to be called, which can do whatever it likes (insert some additional stuff, move the cursor around, save the file, refactor the indentation, whatever). Similarly, given an arbitrary computer language (a new one, say), someone could create a mode that does not just syntax highlighting and indentation but also actively helps the author write -- something like cperl-mode. Every keypress has to be fully scriptable.

If I'm mistaken, and vim is indeed scriptable to that degree, then I've been putting off learning it for too long. (Not that I can really switch, given the amount of custom elisp I have that I'd have to translate, but if it's as flexible as you say I'd like to learn it as a second editor.) But though I've seen a lot of vim advocacy, that's a claim I've never seen before. Can you point me in the direction of some documentation that explains how to do it, the vim equivalent of the Gnu Emacs Lisp Reference Manual? If this is really true, it excites me considerably, and I would stop putting it off and learn vim this spring.

But I suspect that you misunderstood me, because if vim could really do that stuff I'd think some of the people who are really into vim would have written command shells and spreadsheets and mail/news clients and web browsers and z-machine emulators whatnot for it, like the Emacs people have done.


for(unpack("C*",'GGGG?GGGG?O__\?WccW?{GCw?Wcc{?Wcc~?Wcc{?~cc' .'W?')){$j=$_-63;++$a;for$p(0..7){$h[$p][$a]=$j%2;$j/=2}}for$ p(0..7){for$a(1..45){$_=($h[$p-1][$a])?'#':' ';print}print$/}


Comment on Re: There's a level in Hell reserved for ________
Download Code
Re: Re: There's a level in Hell reserved for ________
by zengargoyle (Deacon) on Mar 02, 2003 at 00:04 UTC

    i'm still not a vim power user by any means, but i've noticed that when i

    'vim a_directory'
    it pops up in a dired like mode.

    " <enter> : open file or directory " o : open new window for file/directory " O : open file in previously visited window " p : preview the file " i : toggle size/date listing " s : select sort field r : reverse sort " - : go up one level c : cd to this dir " R : rename file D : delete file " :help file-explorer for detailed help " Sorted by name (.bak,~,.o,.h,.info,.swp,.obj at end of list) "= /home/me/omatic/ ../ fri/ friday/ fridaytwo/ pres/ sat/ saturday/ sun/ sunday/ thursday/ tue/ tuesday/ :call <SNR>2_ToggleHelp() 12,1 + Top

    and i remember back in decades past that there were macros that could create and solve a maze. i simply assume that vim is Turing Complete and if you liked you could make it do whatever you wanted. but it might be like programming in brainf*ck.

    it also does syntax-highlighting on the fly as i type so it could probably do any other work on the fly as well.

    my whole take on the emacs thing is you don't have an editor with a scripting language, you have a scripting language with an editor module as the default interface. the web-browser is written in lisp and uses the editor module for input/output. =P

      i'm still not a vim power user by any means, but i've noticed that when i 'vim a_directory' it pops up in a dired like mode.

      That's not what I asked. I had a DOS-based editor that did that fifteen years ago, and it didn't even have macro facilities, much less was scriptable.

      and i remember back in decades past that there were macros that could create and solve a maze. i simply assume that vim is Turing Complete

      That's not what I asked, either. In fact, I think I specifically said that a macro facility, however advanced, is not the same thing as being fully scriptable. If I have to stop my editing and do something else special in order to invoke the macros... my keyboard can do (a limited amount of) that on its own, irrespective of what editor I am using. But that's not enough for serious use. I need the editor itself to be scriptable, meaning that I can script arbitrary things to happen as a natural part of the editing process. Have you ever seen cperl-mode in action, for example? I type while <FOO and get the following:

      while (<FOO>) { }

      More usefully, I have my own custom stuff for editing CGI scripts. It uses cperl-mode but does some extra things on its own, such as automatically inserting close tags when I put in open tags (in strings), to ensure wellformed XHTML. (It also has a lot of very site-specific stuff in it too.)

      it also does syntax-highlighting on the fly

      A lot of editors do syntax highlighting without being anything that resembles scriptable.

      my whole take on the emacs thing is you don't have an editor with a scripting language, you have a scripting language with an editor module as the default interface.

      I suppose that's a fair enough description of it. It's an approach that creates a lot of flexibility and power.


      for(unpack("C*",'GGGG?GGGG?O__\?WccW?{GCw?Wcc{?Wcc~?Wcc{?~cc' .'W?')){$j=$_-63;++$a;for$p(0..7){$h[$p][$a]=$j%2;$j/=2}}for$ p(0..7){for$a(1..45){$_=($h[$p-1][$a])?'#':' ';print}print$/}

        actually, i went looking last night, vim is definately scriptable to your hearts content. i found the totally-rockin 'taglist.vim' which provides sweet navigation through your files. i also saw scripts that changed the behavior of TAB depending on whether it was the first key pressed on a new line (indent), otherwise (word-complete), shift-TAB being (word-complete-backwards).

        the scripts look something like:

        " Tlist_Cleanup() " Cleanup all the taglist window variables. function! s:Tlist_Cleanup() if has('syntax') silent! syntax clear TagListTitle endif match none if exists('b:tlist_ftype') && b:tlist_ftype != '' let count_var_name = 's:tlist_' . b:tlist_ftype . '_count' if exists(count_var_name) let old_ftype = b:tlist_ftype let i = 1 while i <= s:tlist_{old_ftype}_count let ttype = s:tlist_{old_ftype}_{i}_name let j = 1 let var_name = 'b:tlist_' . old_ftype . '_' . ttype . +'_count' if exists(var_name) let cnt = b:tlist_{old_ftype}_{ttype}_count else let cnt = 0 endif while j <= cnt unlet! b:tlist_{old_ftype}_{ttype}_{j} let j = j + 1 endwhile unlet! b:tlist_{old_ftype}_{ttype}_count unlet! b:tlist_{old_ftype}_{ttype}_start let i = i + 1 endwhile endif endif " Clean up all the variables containing the tags output if exists('b:tlist_tag_count') while b:tlist_tag_count > 0 unlet! b:tlist_tag_{b:tlist_tag_count} let b:tlist_tag_count = b:tlist_tag_count - 1 endwhile endif unlet! b:tlist_bufnum unlet! b:tlist_bufname unlet! b:tlist_ftype endfunction

        the deal with the syntax-highlighting is that if it knows what color to make something as soon as i type it (and knows when to change the color back to normal) then it has the brains to do further modifications like putting 'sub X {}' when you type sub (with cursor left on X), hit right-arrow or space and 'X' dissapears and cursor goes inside '{}' for anonymous sub, or type a subname and 'space' will take you to inside '{}'. i believe having highlighting (the way vim seems to do it) implies being able to smart-complete.

        i hope cperl-mode is smart enough that if that were:

        do { something(); } while <FOO # wouldn't get you do { something(); } while (<FOO>) {}

        and now that i actually know vim has auto-complete (Ctrl-N and Ctrl-P in insert mode) i might be able to break myself of my love for short variable names...

        i suggest anybody who uses vim go check out the Tips section on http://www.vim.org. there's even...

        ASCII ART! +----------+ | | ******* | +----------+ **.......** | | | | **...........** +----|-----+ | *..*********..* | | *** *** +----------+ **++** **++** -------|> *++++++*******++++++* / *+++++++++++++++++++* / -----------\ *+++++++++++++++++++* / \ **+++++++++++++++** / \ ***+++++++++*** / \ ********* / \ / \ / ---------------------/

        but i think we've gone way OT.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://239792]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2014-07-29 01:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (211 votes), past polls