GVIM Editor
[1/24] from: louisaturk:eudoramail at: 12-Mar-2002 2:26
Rebols,
Sorry to ask a non-rebol question, but I'm trying to learn vim to edit
rebol scripts. I'm in a situation in which I have to cut and paste data
from another program into a rebol script. It seems that vim can't do
this. Instead of inserting the text at the cursor position, it inserts it
a the top of the file.
Is there a way around this? or must I look for a different editor?
Louis
[2/24] from: martin:middleton:speechworks at: 12-Mar-2002 7:36
I use GVIM almost exclusively when I edit REBOL scripts. It sounds like you
need to position the cursor at the location at which you wish to insert the
code and make sure you're in "insert" mode. Also, be aware that the
shortcut keys for cut and paste are not the Windows standard CTRL-C,
CRTL-V. If you're trying to use these, this may be the cause of your problem.
At 03:26 AM 03/12/2002, you wrote:
>Rebols,
>Sorry to ask a non-rebol question, but I'm trying to learn vim to edit
<<quoted lines omitted: 7>>
>To unsubscribe from this list, please send an email to
>[rebol-request--rebol--com] with "unsubscribe" in the subject, without the quotes.
- martin
[3/24] from: chris:starforge:demon at: 12-Mar-2002 12:39
Dr. Louis A. Turk wrote:
> Sorry to ask a non-rebol question, but I'm trying to learn vim to edit
> rebol scripts. I'm in a situation in which I have to cut and paste data
> from another program into a rebol script. It seems that vim can't do
> this. Instead of inserting the text at the cursor position, it inserts
> it a the top of the file.
>
> Is there a way around this? or must I look for a different editor?
There probably is another way around it, probably involving a long
string of esoteric chracters ;) What OS are you using? You're posting
from Windows, in which case there are quite a few more sensible editors
on cnet IIRC.
But I'd recommend using emacs anyway, as there's a rebol mode for emacs
and emacs is much, much better than vi or vim! (/me pulls the asbestos
overalls out of the box labeled "For use in Holy War situations only")
Chris
--
.------{ http://www.starforge.co.uk }-----. .--------------------------.
=[ Explorer2260, Designer and Coder \=\ P: TexMaker, ROACH, site \
=[___You_will_obey_your_corporate_masters___]==[ Stack: EETmTmTRRSS------ ]
[4/24] from: joel:neely:fedex at: 12-Mar-2002 5:50
Hi, Louis,
Dr. Louis A. Turk
wrote:
> Sorry to ask a non-rebol question, but I'm trying to learn
> vim to edit rebol scripts. I'm in a situation in which I
> have to cut and paste data from another program into a
> rebol script. It seems that vim can't do this.
>
It can.
> Instead of inserting the text at the cursor position, it
> inserts it a the top of the file.
>
Which version of vim are you using? On what platform?
The reason I'm asking is that vim 6.0 and vim 5.x are
slightly different (one keystroke), and gvim lets you
also use a drop-down menu.
In vim 5.x you use
"*p
to insert after the current cursor position. In vim 6.0
"+p
(IIRC, I'm sitting in front of a box that has 5.5 on it).
If you run gvim instead (supported on X for Unix/Linux
and on w95/nt/2k... ) there is a past option in the
drop-down "Edit" window that does the same thing. Another
advantage of using gvim is that the dropdowns all show the
equivalent key commands, so it's a painless way to learn
them.
Of course, if you use
"*P
(or
"+P
in vim 6), you'll paste AFTER the current cursor position.
-jn-
--
; sub REBOL {}; sub head ($) {@_[0]}
REBOL []
# despam: func [e] [replace replace/all e ":" "." "#" "@"]
; sub despam {my ($e) = @_; $e =~ tr/:#/.@/; return "\n$e"}
print head reverse despam "moc:xedef#yleen:leoj" ;
[5/24] from: andreas:bolka:gmx at: 12-Mar-2002 18:32
Tuesday, March 12, 2002, 12:50:41 PM, Joel wrote:
> "Dr. Louis A. Turk" wrote:
>>
<<quoted lines omitted: 6>>
> to insert after the current cursor position. In vim 6.0
> "+p
[assuming you are using vim6.0]
as you are trying to learn vim, maybe you'd like to have that command
explained.
a) VIM has a system known as "registers" - you can think of it as
quick buffers. registers are named by a single character which can be
any of {a-zA-Z0-9.%#:-"}
registers are accessed by "x - x beeing a valid register name
(character)
b) copy/paste/delete [y, p, d] can be optionally used with explicit
source/destination register. you can yank a piece of test into
register a and another text into b and then paste one of those texts
whenever you want.
c) + is the register refering to the clipboard (and therefore is a
read-only register)
now "+p should be clear ;)
--
Best regards,
Andreas mailto:[andreas--bolka--gmx--net]
[6/24] from: tim:johnsons-web at: 12-Mar-2002 8:47
Hello All:
* Chris <[chris--starforge--demon--co--uk]> [020312 05:12]:
> Dr. Louis A. Turk wrote:
>
> There probably is another way around it, probably involving a long
>
> string of esoteric chracters ;) What OS are you using? You're posting
No string of esoteric characters is necessary! Dr. Turk needs simply to
be in insert mode, given the caveats provided from earlier emails, he
should then be informed of the implications of settings "inherited"
from his vimrc file.
> from Windows, in which case there are quite a few more sensible editors
> on cnet IIRC.
Sensible? See comments on trade-offs:
> But I'd recommend using emacs anyway, as there's a rebol mode for emacs
> and emacs is much, much better than vi or vim! (/me pulls the asbestos
> overalls out of the box labeled "For use in Holy War situations only")
Regardless of whether one uses vim or xemacs, it is a hard start. The
trade-off is in productivity. The learning curve can be steep with either.
The parallel is to rebol itself. It took time for me to learn rebol, but
the increased productivity was worthwhile. Gotta consider the trade-off.
The vim "community" offers a huge amount of resources for the user,
as does emacs. If Dr. Turk wants to use vim, it is recommended that
he subscribe to the vim mailing list, and I (and perhaps others here) would
be happy to help him out offlist.
(Note: I have "hacked" the rebol/vim syntax files a bit also, last I heard
Holger has using that.) Also have some shortcut stubs for rebol).
BTW: If Chris really wants to get into a Holy War, he could more likely
find one between the Emacs and Xemacs crowd.
Us vimmers are still trying to figure out things like :g/g^$/d
But then there are pull-downs :-)
MTCW
--
Tim Johnson <[tim--johnsons-web--com]>
http://www.alaska-internet-solutions.com
http://www.johnsons-web.com
[7/24] from: joel:neely:fedex at: 12-Mar-2002 14:09
Hi, Andreas, and all,
Andreas Bolka wrote:
>
> c) + is the register refering to the clipboard (and therefore is a
> read-only register)
>
It is not read-only.
"+yy
(for example) copies the current line into the clipboard, so that
you can paste it elsewhere (such as into the REBOL console ;-)
I routinely work with both a vim edit window and a REBOL console
window open, cutting and pasting back and forth, depending on
the need of the moment.
[8/24] from: louisaturk:eudoramail at: 12-Mar-2002 19:08
Martin,
At 07:36 AM 3/12/2002 -0500, you wrote:
>I use GVIM almost exclusively when I edit REBOL scripts. It sounds like
>you need to position the cursor at the location at which you wish to
>insert the code and make sure you're in "insert" mode. Also, be aware that
>the shortcut keys for cut and paste are not the Windows standard CTRL-C,
>CRTL-V. If you're trying to use these, this may be the cause of your problem.
In either mode I get the same wrong (text inserted at beginning of file
instead of after the cursor) results using the toolbar paste icon or right
clicking on the mouse and selecting paste. However, if I am in insert mode
typing "+p simply types "+p.
Do I perhaps have some setting set wrong?
Louis
[9/24] from: louisaturk:eudoramail at: 12-Mar-2002 18:59
Hi Joel,
Many thanks for helping. I'll answer your question:
At 05:50 AM 3/12/2002 -0600, you wrote:
>Which version of vim are you using? On what platform?
I'm using gVim 6.1a
>The reason I'm asking is that vim 6.0 and vim 5.x are
>slightly different (one keystroke), and gvim lets you
<<quoted lines omitted: 3>>
>to insert after the current cursor position. In vim 6.0
> "+p
This is what I've been trying, but it doesn't insert the text at the cursor
for some reason. Instead it inserts the text at the beginning of the file.
[10/24] from: louisaturk:eudoramail at: 12-Mar-2002 20:07
Andreas,
as you are trying to learn vim, maybe you'd like to have that command
>explained.
>a) VIM has a system known as "registers" - you can think of it as
<<quoted lines omitted: 9>>
>read-only register)
>now "+p should be clear ;)
Many thanks. That does help. But I still can't get my pastes into the
right spot.
Also, I just remembered that I also have Cygwin installed on this same
computer, and a unix version of vim running under Cygwin. Version
6.0.11. So I tried using it, and the result is different but still
wrong. The text is now placed after the rebol block I am trying to place
the text in. For example:
[{I want the text here}]but instead it is placed here.
Louis
[11/24] from: louisaturk:eudoramail at: 12-Mar-2002 19:48
Chris,
At 12:39 PM 3/12/2002 +0000, you wrote:
But I'd recommend using emacs anyway, as there's a rebol mode for emacs
>and emacs is much, much better than vi or vim! (/me pulls the asbestos
>overalls out of the box labeled "For use in Holy War situations only")
I believe that, generally speaking, each tool has its use, and is better
for certain purposes than any other tool. It is just that for some tools
the cost in dollars or "time to learn" is so high that one can only afford
one tool of its kind. Besides, you can't drive both Cadillac and Lincoln
at the same time, even if you can afford both. So, your get a Porshe
instead. :>) Or a Chevy! And it is the best by declaration.
Anyway, I've decided to go to either vim or emacs since they are both free
(and I'm in the non-profit sector on a tight budget), and they both seem to
have a multitude of professional programmers as users to potentially help
me in times of need (which for me is often). Also, I figure that with so
many pros choosing one of these two editors they both must be
exceptional. So I can't go wrong either way, provided they do what I need
to do (which right now is cut and paste between programs).
So, please explain: why do you think emacs is better than vim? and for
what uses would vim be better than emacs? Also, what version of emacs do
you recommend for use with Windows 2000?
Thanks,
Louis
ps What I would really like is a basic vim or emacs written in rebol (just
the basic commands), so that it would be small and fast, and so that I
could easily modify it myself to fit my own often unusual needs.
[12/24] from: joel:neely:fedex at: 12-Mar-2002 20:29
Hi, again, Louis
Dr. Louis A. Turk
wrote:
> Martin,
>
> At 07:36 AM 3/12/2002 -0500, you wrote:
> > I use GVIM almost exclusively when I edit REBOL scripts. It
> > sounds like you need to position the cursor at the location
> > at which you wish to insert the code and make sure you're in
> > "insert" mode...
Nononono!
You should be in command mode, not insert mode.
> In either mode I get the same wrong (text inserted at beginning
> of file instead of after the cursor) results using the toolbar
> paste icon or right clicking on the mouse and selecting paste.
>
Try the following, and let me know what happens:
- Create a multiple-line file (however you wish) named nlines.txt
containing something obviously in that file (e.g. start every
line with the same character or word).
- Create a single-line file (however you wish) named oneline.txt
containing something obviously different (e.g. different word
or leading character).
- Start up vim.
- Open nlines.txt (the handiest way may be to use the command
:browse e
which will pop up the standard "file open" dialog on your box,
allowing you to navigate to the file and open it.
- Open oneline.txt (as above).
- Enter the following
1G"+yy
(Go to line 1, select the + buffer, and yank a copy of the
current line into that buffer) then enter
:e#
and press return (which will take you to the other buffer,
containing nlines.txt). Then type
G"+p
(Go to the end of the file, select the + buffer, and Put
that buffer's contents after the current position.)
If that inserts the copied line somewhere else than the end
of the file, I suspect that your copy of vim may be damaged,
and would suggest that you go fetch a fresh copy from vim.org
and install it over the one you have.
> However, if I am in insert mode typing "+p simply types "+p.
>
As it should. Insert mode *means* that your keystrokes will be
inserted into the buffer.
-jn-
--
; sub REBOL {}; sub head ($) {@_[0]}
REBOL []
# despam: func [e] [replace replace/all e ":" "." "#" "@"]
; sub despam {my ($e) = @_; $e =~ tr/:#/.@/; return "\n$e"}
print head reverse despam "moc:xedef#yleen:leoj" ;
[13/24] from: louisaturk:eudoramail at: 12-Mar-2002 20:45
Tim,
At 08:47 AM 3/12/2002 -0900, you wrote:
> No string of esoteric characters is necessary! Dr. Turk needs simply to
> be in insert mode, given the caveats provided from earlier emails, he
> should then be informed of the implications of settings "inherited"
> from his vimrc file.
Thanks for the respect, but Louis is fine. I'm no Dr. of programming, but
just a struggling amateur. In this field you are the Dr. You are the pro.
I'm confused about insert mode. If I type i to enter insert mode, then
type "+p it just types in those three characters, as I would assume it
should. What am I missing here?
Also, could the vimrc file be causing my paste problem? If so, what do I
look for to correct it?
> > from Windows, in which case there are quite a few more sensible editors
> > on cnet IIRC.
<<quoted lines omitted: 6>>
> The parallel is to rebol itself. It took time for me to learn rebol, but
> the increased productivity was worthwhile. Gotta consider the trade-off.
Yes, this increased productivity is what I'm hoping for.
> The vim "community" offers a huge amount of resources for the user,
> as does emacs. If Dr. Turk wants to use vim, it is recommended that
> he subscribe to the vim mailing list, and I (and perhaps others here) would
> be happy to help him out offlist.
> (Note: I have "hacked" the rebol/vim syntax files a bit also, last I heard
> Holger has using that.) Also have some shortcut stubs for rebol).
May I please get a copy?
> BTW: If Chris really wants to get into a Holy War, he could more likely
> find one between the Emacs and Xemacs crowd.
<<quoted lines omitted: 6>>
> http://www.johnsons-web.com
>--
Except for the paste problem, there is only one thing about vim I have
found so far that I don't like: when long lines are wrapped vim skips the
wrapped part of the line completely when pressing j or k, and goes to the
next line. Is it possible to change this?
Thanks,
Louis
[14/24] from: louisaturk:eudoramail at: 12-Mar-2002 22:43
Joel,
I made the files you suggested, and did what you said, and it
worked. However, when I place the cursor in the middle of a line where I
actually want the text to be inserted, it still does not work. Instead
the text is inserted _above_ the line (in a previous post I said the test
was inserted at the beginning of the file, but that is probably because I
was trying to insert into the top line in the file). I am probably
overlooking something really basic. I learn best from printed
documentation. On-line documentation is often confusing for a person
trying to learn, and is generally best used mainly for reference in my
opinion.
By the way, I enjoy reading your posts, and I learn a lot from them (even
though I usually don't understand half of what you're talking about). It
is because of you that I am trying vim.
Louis
At 08:29 PM 3/12/2002 -0600, you wrote:
[15/24] from: tim:johnsons-web at: 12-Mar-2002 20:11
Hello Louis:
> Thanks for the respect, but Louis is fine. I'm no Dr. of programming, but
> just a struggling amateur. In this field you are the Dr. You are the pro.
Disclaimer-1: Been working in Vim for only a little over a year. That makes
me a relative newbie myself.
Disclaimer-2: Use vim mostly on Linux.
> I'm confused about insert mode. If I type i to enter insert mode, then
> type "+p it just types in those three characters, as I would assume it
> should. What am I missing here?
You should be doing that in 'normal' mode. If you have type 'i' to go
into insert mode, then (given proper setup), Ctrl-V should work with
the default windows configuration, I think.
(I use Ctrl_insert on both platforms)
Hint: at command line, type :h p and you will be lots of docs on 'p'
Hint: You might want to look at evim, which is a way of starting vim
in modeless editing style. But I don't use it.
Try :h evim for help on that.
> Also, could the vimrc file be causing my paste problem? If so, what do I
> look for to correct it?
In windows, I believe you want to look for _vimrc in "topmost" folder
of your installation. Also, you can use the :mapc command to clear
all mappings for normal mode and :imapc to clear all mappings in
insert mode.
> Yes, this increased productivity is what I'm hoping for.
To advocate for Chris here, I believe that emacs is an easier start
than vim. Now I've got a thought - perhaps it would be worthwhile
for vim users on this list to exchange resources. AND it might be
worthwhile for emacs users on this list to exchange resources too.
Sterling uses Emacs and has written some articles for the webzine
that I and friends publish......
I believe a tremendous rebol IDE could be "constructed" from either
vim or emacs. AND frankly most IDEs don't accomodate multiple languages
in the same session. (Like try loading a perl file into C++ Builder,
aargh!)
> May I please get a copy?
I am attaching filetype.vim and rebol.vim. I would suggest backing
up the originals...
> Except for the paste problem, there is only one thing about vim I have
> found so far that I don't like: when long lines are wrapped vim skips the
> wrapped part of the line completely when pressing j or k, and goes to the
> next line. Is it possible to change this?
:set nowrap
> Thanks,
> Louis
You're welcome.
--
Tim Johnson <[tim--johnsons-web--com]>
http://www.alaska-internet-solutions.com
http://www.johnsons-web.com
-- Attached file included as plaintext by Listar --
Vim support file to detect file types
Maintainer: Bram Moolenaar <[Bram--vim--org]>
Last change: 2001 Sep 21
Listen very carefully, I will say this only once
if exists(
did_load_filetypes")
finish
endif
let did_load_filetypes = 1
Line continuation is used here, remove 'C' from 'cpoptions'
let s:cpo_save = &cpo
set cpo&vim
augroup filetypedetect
Ignored extensions
au BufNewFile,BufRead *.orig,*.bak,*.old,*.new,*.rpmsave,*.rpmnew
\ exe "doau filetypedetect BufRead " . expand("<afile>:r")
au BufNewFile,BufRead *~
\ let s:name = expand("<afile>") |
\ let s:short = substitute(s:name, '\~$', '', '') |
\ if s:name != s:short && s:short != "" |
\ exe "doau filetypedetect BufRead " . s:short |
\ endif |
\ unlet s:name |
\ unlet s:short
au BufNewFile,BufRead *.in
\ if expand("<afile>:t") != "configure.in" |
\ exe "doau filetypedetect BufRead " . expand("<afile>:r") |
\ endif
Abaqus or Trasys
au BufNewFile,BufRead *.inp call FTCheck_inp()
fun! FTCheck_inp()
if getline(1) =~ '^\*'
setf abaqus
else
let n = 1
if line(
$") > 500
let nmax = 500
else
let nmax = line("$")
endif
while n <= nmax
if getline(n) =~? "^header surface data"
setf trasys
break
endif
let n = n + 1
endwhile
endif
endfun
ABC music notation
au BufNewFile,BufRead *.abc setf abc
ABEL
au BufNewFile,BufRead *.abl setf abel
ABEL
au BufNewFile,BufRead *.abl setf abel
AceDB
au BufNewFile,BufRead *.wrm setf acedb
Ada (83, 9X, 95)
au BufNewFile,BufRead *.adb,*.ads setf ada
AHDL
au BufNewFile,BufRead *.tdf setf ahdl
Apache style config file
au BufNewFile,BufRead proftpd.conf* setf apachestyle
Apache config file
au BufNewFile,BufRead httpd.conf*,srm.conf*,access.conf*,.htaccess,apache.conf* setf
apache
Applix ELF
au BufNewFile,BufRead *.am
\ if expand(
<afile>") !~? 'Makefile.am\>' | setf elf | endif
Arc Macro Language
au BufNewFile,BufRead *.aml setf aml
ASN.1
au BufNewFile,BufRead *.asn,*.asn1 setf asn
Active Server Pages (with Visual Basic Script)
au BufNewFile,BufRead *.asa
\ if exists(
g:filetype_asa") |
\ exe "setf " . g:filetype_asa |
\ else |
\ setf aspvbs |
\ endif
Active Server Pages (with Perl or Visual Basic Script)
au BufNewFile,BufRead *.asp
\ if exists(
g:filetype_asp") |
\ exe "setf " . g:filetype_asp |
\ elseif getline(1) . getline(2) . getline(3) =~? "perlscript" |
\ setf aspperl |
\ else |
\ setf aspvbs |
\ endif
Assembly (all kinds)
*.lst is not pure assembly, it has two extra columns (address, byte codes)
au BufNewFile,BufRead *.asm,*.[sS],*.[aA],*.mac,*.lst call <SID>FTasm()
This function checks for the kind of assembly that is wanted by the user, or
can be detected from the first five lines of the file.
fun! <SID>FTasm()
" make sure b:asmsyntax exists
if !exists("b:asmsyntax")
let b:asmsyntax = ""
endif
if b:asmsyntax == ""
call FTCheck_asmsyntax()
endif
" if b:asmsyntax still isn't set, default to asmsyntax or GNU
if b:asmsyntax == ""
if exists("g:asmsyntax")
let b:asmsyntax = g:asmsyntax
else
let b:asmsyntax = "asm"
endif
endif
exe "setf " . b:asmsyntax
endfun
fun! FTCheck_asmsyntax()
" see if file contains any asmsyntax=foo overrides. If so, change
" b:asmsyntax appropriately
let head = " ".getline(1)." ".getline(2)." ".getline(3)." ".getline(4).
\" ".getline(5)." "
if head =~ '\sasmsyntax=\S\+\s'
let b:asmsyntax = substitute(head, '.*\sasmsyntax=\(\S\+\)\s.*','\1', "")
endif
endfun
Atlas
au BufNewFile,BufRead *.atl,*.as setf atlas
Automake
au BufNewFile,BufRead [mM]akefile.am setf automake
Avenue
au BufNewFile,BufRead *.ave setf ave
Awk
au BufNewFile,BufRead *.awk setf awk
B
au BufNewFile,BufRead *.mch,*.ref,*.imp setf b
BASIC or Visual Basic
au BufNewFile,BufRead *.bas call <SID>FTVB("basic")
Check if one of the first five lines contains
VB_Name". In that case it is
probably a Visual Basic file. Otherwise it's assumed to be
alt" filetype.
fun! <SID>FTVB(alt)
if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'VB_Name'
setf vb
else
exe "setf " . a:alt
endif
endfun
Visual Basic Script (close to Visual Basic)
au BufNewFile,BufRead *.vbs,*.dsm setf vb
Batch file for MSDOS (*.cmd is close enough)
au BufNewFile,BufRead *.bat,*.cmd,*.sys setf dosbatch
Batch file for 4DOS
au BufNewFile,BufRead *.btm setf btm
BC calculator
au BufNewFile,BufRead *.bc setf bc
BDF font
au BufNewFile,BufRead *.bdf setf bdf
BibTeX bibliography database file
au BufNewFile,BufRead *.bib setf bib
BIND configuration
au BufNewFile,BufRead named.conf setf named
BIND zone
au BufNewFile,BufRead named.root setf bindzone
Blank
au BufNewFile,BufRead *.bl setf blank
C
au BufNewFile,BufRead *.c setf c
C#
au BufNewFile,BufRead *.cs setf cs
Cyn++
au BufNewFile,BufRead *.cyn setf cynpp
Cynlib
.cc and .cpp files can be C++ or Cynlib.
au BufNewFile,BufRead *.cc
\ if exists("cynlib_syntax_for_cc")|setf cynlib|else|setf cpp|endif
au BufNewFile,BufRead *.cpp
\ if exists("cynlib_syntax_for_cpp")|setf cynlib|else|setf cpp|endif
C++
if has(
fname_case")
au BufNewFile,BufRead *.cxx,*.c++,*.C,*.H,*.hh,*.hxx,*.hpp,*.moc,*.tcc,*.inl setf cpp
else
au BufNewFile,BufRead *.cxx,*.c++,*.hh,*.hxx,*.hpp,*.moc,*.tcc,*.inl setf cpp
endif
.h files can be C or C++, set c_syntax_for_h if you want C
au BufNewFile,BufRead *.h
\ if exists(
c_syntax_for_h") | setf c | else | setf cpp | endif
Cascading Style Sheets
au BufNewFile,BufRead *.css setf css
Century Term Command Scripts (*.cmd too)
au BufNewFile,BufRead *.con setf cterm
Changelog
au BufNewFile,BufRead changelog.Debian,changelog.dch setf debchangelog
au BufNewFile,BufRead [cC]hange[lL]og if getline(1) =~ '; urgency='
\| setf debchangelog | else | setf changelog | endif
CHILL
au BufNewFile,BufRead *..ch setf ch
Changes for WEB and CWEB or CHILL
au BufNewFile,BufRead *.ch call <SID>FTchange()
This function checks if one of the first ten lines start with a ['--']. In
that case it is probably a change file, otherwise CHILL is assumed.
fun! <SID>FTchange()
let lnum = 1
while lnum <= 10
if getline(lnum)[0] == ['--']
setf change
return
endif
let lnum = lnum + 1
endwhile
setf ch
endfun
Clean
au BufNewFile,BufRead *.dcl,*.icl setf clean
Clever
au BufNewFile,BufRead *.eni setf cl
Clever or dtd
au BufNewFile,BufRead *.ent call <SID>FTent()
fun! <SID>FTent()
" This function checks for valid cl syntax in the first five lines.
" Look for either an opening comment, '#', or a block start, '{".
" If not found, assume SGML.
let lnum = 1
while lnum < 6
let line = getline(lnum)
if line =~ '^\s*[#{]'
setf cl
return
elseif line !~ '^\s*$'
" Not a blank line, not a comment, and not a block start,
" so doesn't look like valid cl code.
break
endif
let lnum = lnum + 1
endw
setf dtd
endfun
Clipper (or FoxPro)
au BufNewFile,BufRead *.prg
\ if exists(
g:filetype_prg") |
\ exe "setf " . g:filetype_prg |
\ else |
\ setf clipper |
\ endif
Cobol
au BufNewFile,BufRead *.cbl,*.cob,*.cpy,*.lib setf cobol
Cold Fusion
au BufNewFile,BufRead *.cfm,*.cfi setf cf
Configure scripts
au BufNewFile,BufRead configure.in,configure.ac setf config
Enlightenment configuration files
au BufNewFile,BufRead *enlightenment/*.cfg setf c
Eterm
au BufNewFile,BufRead *Eterm/*.cfg setf eterm
Lynx config files
au BufNewFile,BufRead lynx.cfg setf lynx
Configure files
au BufNewFile,BufRead *.cfg setf cfg
Communicating Sequential Processes
au BufNewFile,BufRead *.csp,*.fdr setf csp
CUPL logic description and simulation
au BufNewFile,BufRead *.pld setf cupl
au BufNewFile,BufRead *.si setf cuplsim
Debian Control
au BufNewFile,BufRead */debian/control setf debcontrol
Diff files
au BufNewFile,BufRead *.diff,*.rej setf diff
Diva (with Skill) or InstallShield
au BufNewFile,BufRead *.rul
\ if getline(1).getline(2).getline(3).getline(4).getline(5).getline(6) =~? 'InstallShield'
|
\ setf ishd |
\ else |
\ setf diva |
\ endif
DCL (Digital Command Language - vms) or DNS zone file
au BufNewFile,BufRead *.com
\ if getline(1) =~ '\($ORIGIN\|$TTL\|IN\s*SOA\)'
\ || getline(2) =~ '\($ORIGIN\|$TTL\|IN\s*SOA\)'
\ || getline(1).getline(2).getline(3).getline(4) =~ 'BIND.*named'
\ | setf dns | else | setf dcl | endif
DOT
au BufNewFile,BufRead *.dot setf dot
Dylan - lid files
au BufNewFile,BufRead *.lid setf dylanlid
Dylan - intr files (melange)
au BufNewFile,BufRead *.intr setf dylanintr
Dylan
au BufNewFile,BufRead *.dylan setf dylan
Microsoft Module Definition
au BufNewFile,BufRead *.def setf def
Dracula
au BufNewFile,BufRead *.drac,*.drc,*lvs,*lpe setf dracula
dsl
au BufNewFile,BufRead *.dsl setf dsl
DTD (Document Type Definition for XML)
au BufNewFile,BufRead *.dtd setf dtd
Embedix Component Description
au BufNewFile,BufRead *.ecd setf ecd
Eiffel or Specman
au BufNewFile,BufRead *.e,*.E call FTCheck_e()
fun! FTCheck_e()
let n = 1
while n < 100 && n < line(
$")
if getline(n) =~ "^\\s*\\(<'\\|'>\\)\\s*$"
set ft=specman
return
endif
let n = n + 1
endwhile
setf eiffel
endfun
ERicsson LANGuage
au BufNewFile,BufRead *.erl setf erlang
Elm Filter Rules file
au BufNewFile,BufRead filter-rules setf elmfilt
ESQL-C
au BufNewFile,BufRead *.ec,*.EC setf esqlc
Essbase script
au BufNewFile,BufRead *.csc setf csc
Expect
au BufNewFile,BufRead *.exp setf expect
Exports
au BufNewFile,BufRead exports setf exports
Focus Executable
au BufNewFile,BufRead *.fex,*.focexec setf focexec
Focus Master file
au BufNewFile,BufRead *.mas,*.master setf master
Forth
au BufNewFile,BufRead *.fs,*.ft setf forth
Fortran
au BufNewFile,BufRead *.f,*.F,*.for,*.fpp,*.ftn,*.f77,*.f90,*.f95 setf fortran
GDB command files
au BufNewFile,BufRead .gdbinit setf gdb
GDMO
au BufNewFile,BufRead *.mo,*.gdmo setf gdmo
Gedcom
au BufNewFile,BufRead *.ged setf gedcom
GP scripts (2.0 and onward)
au BufNewFile,BufRead *.gp setf gp
Gnuplot scripts
au BufNewFile,BufRead *.gpi setf gnuplot
GNU Server Pages
au BufNewFile,BufRead *.gsp setf gsp
GTK RC
au BufNewFile,BufRead .gtkrc,gtkrc setf gtkrc
Haskell
au BufNewFile,BufRead *.hs setf haskell
au BufNewFile,BufRead *.lhs setf lhaskell
Hercules
au BufNewFile,BufRead *.vc,*.ev,*.rs,*.sum,*.errsum setf hercules
HEX (Intel)
au BufNewFile,BufRead *.hex,*.h32 setf hex
HTML (.shtml for server side)
au BufNewFile,BufRead *.html,*.htm,*.shtml setf html
HTML with M4
au BufNewFile,BufRead *.html.m4 setf htmlm4
Hyper Builder
au BufNewFile,BufRead *.hb setf hb
Icon
au BufNewFile,BufRead *.icn setf icon
IDL (Interface Description Language)
au BufNewFile,BufRead *.idl setf idl
Inform
au BufNewFile,BufRead .indent.pro setf indent
IDL (Interactive Data Language)
au BufNewFile,BufRead *.pro setf idlang
Inform
au BufNewFile,BufRead *.inf,*.INF setf inform
Informix 4GL (source - canonical, include file, I4GL+M4 preproc.)
au BufNewFile,BufRead *.4gl,*.4gh,*.m4gl setf fgl
.INI file for MSDOS
au BufNewFile,BufRead *.ini setf dosini
SysV Inittab
au BufNewFile,BufRead inittab setf inittab
Inno Setup
au BufNewFile,BufRead *.iss setf iss
Jam
au BufNewFile,BufRead *.jpl,*.jpr setf jam
Java
au BufNewFile,BufRead *.java,*.jav setf java
JavaCC
au BufNewFile,BufRead *.jj,*.jjt setf javacc
JavaScript
au BufNewFile,BufRead *.js,*.javascript setf javascript
Java Server Pages
au BufNewFile,BufRead *.jsp setf jsp
Java Properties resource file (note: doesn't catch font.properties.pl)
au BufNewFile,BufRead *.properties,*.properties_??,*.properties_??_??,*.properties_??_??_* setf
jproperties
Jess
au BufNewFile,BufRead *.clp setf jess
Jgraph
au BufNewFile,BufRead *.jgr setf jgraph
Kixtart
au BufNewFile,BufRead *.kix setf kix
Kimwitu[++]
au BufNewFile,BufRead *.k setf kwt
KDE script
au BufNewFile,BufRead *.ks setf kscript
Lace (ISE)
au BufNewFile,BufRead *.ace,*.ACE setf lace
Latte
au BufNewFile,BufRead *.latte,*.lte setf latte
LambdaProlog (*.mod too, see Modsim)
au BufNewFile,BufRead *.sig setf lprolog
Lex
au BufNewFile,BufRead *.lex,*.l setf lex
LFTP
au BufNewFile,BufRead lftp.conf,.lftprc,*lftp/rc setf lftp
Lilo: Linux loader
au BufNewFile,BufRead lilo.conf* setf lilo
Lisp (*.el = ELisp, *.cl = Common Lisp, *.jl = librep Lisp)
if has("fname_case")
au BufNewFile,BufRead *.lsp,*.lisp,*.el,*.cl,*.jl,*.L,.emacs setf lisp
else
au BufNewFile,BufRead *.lsp,*.lisp,*.el,*.cl,*.jl,.emacs setf lisp
endif
Lite
au BufNewFile,BufRead *.lite,*.lt setf lite
LOTOS
au BufNewFile,BufRead *.lot,*.lotos setf lotos
Lout (also: *.lt)
au BufNewFile,BufRead *.lou,*.lout setf lout
Lua
au BufNewFile,BufRead *.lua setf lua
Lynx style file
au BufNewFile,BufRead *.lss setf lss
M4
au BufNewFile,BufRead *.m4
\ if expand("<afile>") !~? 'html.m4$' | setf m4 | endif
MaGic Point
au BufNewFile,BufRead *.mgp setf mgp
Mail (for Elm, trn, mutt, rn, slrn)
au BufNewFile,BufRead snd.\d\+,.letter,.letter.\d\+,.followup,.article,.article.\d\+,pico.\d\+,mutt-*-\d\+,mutt\w\{6\},ae\d\+.txt,/tmp/SLRN[0-9A-Z.]\+,*.eml
setf mail
Makefile
au BufNewFile,BufRead [mM]akefile,GNUmakefile,*.mk,*.mak,*.dsp setf make
MakeIndex
au BufNewFile,BufRead *.ist,*.mst setf ist
Manpage
au BufNewFile,BufRead *.man setf man
Maple V
au BufNewFile,BufRead *
[16/24] from: louisaturk:eudoramail at: 13-Mar-2002 2:40
Tim,
Thanks for all the help and hints.
At 08:11 PM 3/12/2002 -0900, you wrote:
> To advocate for Chris here, I believe that emacs is an easier start
> than vim.
I'm very interested to hear why Chris likes emacs. I've not yet decided on
an editor.
> Now I've got a thought - perhaps it would be worthwhile
> for vim users on this list to exchange resources. AND it might be
> worthwhile for emacs users on this list to exchange resources too.
That is a great idea.
> Sterling uses Emacs and has written some articles for the webzine
> that I and friends publish......
Yes, I remember reading one of them. Sterling, are you out there? I would
also like to know why you use emacs? Would you share your rebol
programming macros and scripts or whatever you call them with us?
Does Carl use emacs also?
> I believe a tremendous rebol IDE could be "constructed" from either
> vim or emacs. AND frankly most IDEs don't accomodate multiple languages
> in the same session. (Like try loading a perl file into C++ Builder,
> aargh!)
Yes, a rebol IDE is what I need. But I would rather see it programmed
using rebol, so that I can add my own extensions without having to learn
yet another language. I just simply don't have time to learn another
language. I really don't have enough time to get real good at rebol. What
would be nice would be a rebol editor/IDE designed in a simple modular
fashion and clearly commented so that we could all easily share our
extensions to it. We could pick and choose only the extensions that we
need so that our personal copy of the editor remains small and fast.
One thing I really like about rebol is that it is so easy to install. And
to install a script you just copy it to your harddrive and use it. I don't
like being tied to any particular operating system.
That's what I would like, but meanwhile I still need an editor.
> > May I please get a copy?
>
> I am attaching filetype.vim and rebol.vim. I would suggest backing
> up the originals...
The list server would not send them as attachments. Would you please send
them as attachments again directly to my email address?
> >
> > Except for the paste problem, there is only one thing about vim I have
> > found so far that I don't like: when long lines are wrapped vim skips the
> > wrapped part of the line completely when pressing j or k, and goes to the
> > next line. Is it possible to change this?
>
> :set nowrap
But sometimes I want the lines wrapped, but I don't want the wrapped part
of the lines skipped when moving the cursor up or down. Why can't I find
that perfect editor? What I really want is an editor that will
automatically know what I need even when I don't, and will write all the
code for me without me having to touch the keyboard. :>) Have I
described emacs, Chris?
I appreciate all you guys on this list. You've all taught me a lot. Many
thanks!
Louis
[17/24] from: joel:neely:fedex at: 13-Mar-2002 6:16
Hi, Louis,
Dr. Louis A. Turk
wrote:
> Except for the paste problem, there is only one thing about vim
> I have found so far that I don't like: when long lines are
> wrapped vim skips the wrapped part of the line completely when
> pressing j or k, and goes to the next line.
>
I completely understand the (minor, I hope) frustration. When I
have spent lots of time in a word processor (OBTW: When does a
word processor
do to words what a "food processor" does with
food? When it's made by microSoft! ;-) and then get back to
a real text editor, I have to take a moment to retrain my eyes.
But let me see if I can offer a conceptual model that makes all
of this make sense.
> Is it possible to change this?
>
Not AFAIK. But there's a reason, having to do with the difference
between word processing and text processing (as in editing source
code for programming). Programmers most often use indentation to
show nesting of structure in source code, which can easily cause a
line to be arbitrarily long (especially if tabs are used for the
indentation, but see below). Indenting a line more deeply doesn't
change the fact that it is still one line, even if it ends up
wider than the current display window and has to wrap.
The command
j
moves you forward/down one line (as you already know) and
k
moves you backward/up one line. vi/vim defines "line" in terms
of newline characters, not the display. If you resize your
window and make it wider, then any "wrapped" lines should reflow
(possibly not needing multiple rows on the display any more).
The reason for sticking with the newline-based definition of
line
is that locations don't change depending on the current
size of your editing window. (I don't recall whether Cygwin
lets you resize the console window, but in general vi/vim
makes no assumptions about fixed window sizes. If you run the
windows binary of gvim, you can resize the window at will.)
For example, if you type
123G
you'll Go to the 123rd line of the file, which location won't
change depending on your window width.
Also, back in the day, it was common for people to use terminals
(e.g. VT 100) with 80-character width, but print to hardcopy
devices (e.g., line printers, DECwriters, etc.) with 132-character
width. Therefore "line" was viewed as a logical artifact, not
a physical one.
When you turn on line number display in vi/vim, using
:set number
(or the abbreviation
:set nu
in carpel-tunnel-defense mode ;-) the lines are numbered using the
same newline-based strategy, regardless of window width and any
wrapping that may have occurred. Then if you print your file to
a wider output device with a line-numbering utility (or stretch
your window horizontally), the line numbering won't change.
Finally, you can write macros to do useful things: for example,
if you were turning a plain text file into an HTML table,
with each line containing a single cell's data ...
(and please, nobody point out that this could be done with a
very small script... I'm just using a simple example that
requires no further explanation! ;-)
... you could write a single-keystroke macro that does the
following, starting on a line of text from the original data:
- insert above the current line a new line containing only
<td>
- move down one line (back to the line you started from)
- insert below the current line a new line containing only
</td>
- and move to the line following that insertion.
This would leave you positioned on the next (logical) line from
the original data following the one you started from. Thus you
could hit the macro key several times in succession to enclose
several items in <td>...</td> pairs.
Of course, you would want this to work the same regardless of
how wide or narrow your terminal was (i.e., whether or not
display-wrapping had occurred), so basing lines on the places
where newlines were found, rather than on temporary display
wrapping, would give you more stable, predictable behavior.
I hope this was of some help... I always find it easier to
deal with something when I know *why* it was designed the way
it was. Even if I disagree with the logic, at least I can
understand it, expect what it will do, and use it successfully.
-jn-
--
; sub REBOL {}; sub head ($) {@_[0]}
REBOL []
# despam: func [e] [replace replace/all e ":" "." "#" "@"]
; sub despam {my ($e) = @_; $e =~ tr/:#/.@/; return "\n$e"}
print head reverse despam "moc:xedef#yleen:leoj" ;
[18/24] from: joel:neely:fedex at: 13-Mar-2002 6:48
Hi, again, Louis,
Dr. Louis A. Turk
wrote:
> I made the files you suggested, and did what you said, and it
> worked. However, when I place the cursor in the middle of a
> line where I actually want the text to be inserted, it still
> does not work. Instead the text is inserted _above_ the line
> ...
>
Aha! Now I understand (sorry for not thinking of this earlier...)
When you Put text (or Paste, if you prefer) into the buffer, the
text will be Put into the new place at the same "level" that it
it was Yanked. If you yanked one or more lines in the original
case, then they will be put in as lines. However, you don't have
to yank whole lines. If you have a little buffer containing
this is a test
what if I wanted to insert some text
in the middle of a line
like right here, for example?
is that possible?
then you can:
- place the cursor at the beginning of the word "insert"
on the second line, for example by
1G/ins
followed by the enter key,
- enter the command
y3w
to Yank the following three Words,
- enter the command
/here
followed by the enter key, to move to the word here in the
fourth line,
- enter the command
P
to Put the currently-held text into the buffer just in front
of the cursor -- at which point the buffer looks like this
this is a test
what if I wanted to insert some text
in the middle of a line
like right insert some texthere, for example?
is that possible?
with the cursor still on the "h" of "here"
- type the lower-case letter "a", a space, and escape, to
insert a space Ahead of the "h" in "here",
and no line-breaking occurs, because you were dealing with words
instead of lines.
I was doing all of the above using a vim window open beside
my email window while writing.
Now, I just did a little experiment (but remember that I'm on
vim 5.5 at home) where I undid the last changes above, came
back to this email editing window (in Netscape), selected and
copied the phrase "insert some text" from the sample above,
went back to the vim window, placed the cursor on the "h" in
the word "here", and typed
"*P
at which point vim stuck the three words "insert some text"
into the line just as before.
The moral is
If you cut/copy lines, you'll paste lines,
if you cut/copy words, you'll paste words.
I hope that helps.
-jn-
> I learn best from printed documentation. On-line documentation
> is often confusing for a person trying to learn, and is
> generally best used mainly for reference in my opinion.
>
That is not an uncommon point of view. Forunately, the on-line
documentation for vim is actually supplied as text files that get
installed with the software, so you actually *can* print those
files off and read them at your leisure. Some of the tutorials
can be *quite* helpful.
Also, O'Reilly has a good book on vi that includes discussion of
vi clones such as vim and elvis, and there's a New Riders book
by Steve Oualline that is specific to vim and provides a VERY
detailed look at its features.
> It is because of you that I am trying vim.
>
I'm frightened to think that I might be corrupting yet another
generation of programmers!!! ;-) Seriously, thanks for the
kind words; as always, my views are only my opinions, which
you are free to use or ignore as you find appropriate.
-jn-
--
; sub REBOL {}; sub head ($) {@_[0]}
REBOL []
# despam: func [e] [replace replace/all e ":" "." "#" "@"]
; sub despam {my ($e) = @_; $e =~ tr/:#/.@/; return "\n$e"}
print head reverse despam "moc:xedef#yleen:leoj" ;
[19/24] from: chris:starforge:demon at: 13-Mar-2002 13:21
Dr. Louis A. Turk wrote:
> So, please explain: why do you think emacs is better than vim? and for
> what uses would vim be better than emacs? Also, what version of emacs
> do you recommend for use with Windows 2000?
To answer your questions in reverse order, Emacs-21.1 is the latest (and
best) version of Emacs, you can obtain it from
ftp://ftp.gnu.org/gnu/windows/emacs/21.1/emacs-21.1-fullbin-i386.tar.gz
The file is about 16Mb, winzip can understand the tar.gz - you just need to
unpack it somewhere on your system and run emacs-21.1\bin\emacs.exe
For an example of the different between emacs an vim, take your recent
cut and paste problem. In emacs you just highlight the section of text
you want to cut and either select "Cut" from the Edit menu, or press
Ctrl-w (to copy something simply select the text - that automagically sticks
it inthe clipboard). To paste stuff off the clipboard, more the cursor
to where you want it to go and press Ctrl-y or move the mouse over the
location you want it to go and press the middle mouse button. Copy and paste
between other programs via the clipboard works as well.
Emacs also offers multiple buffers visible in a single window, or multiple
windows each with multiple buffers (makes working on multiple sources
easy).You can even launch a DOS prompt inside the editor to test your
code without having to start DOS explicitly (press Alt-X, then type 'shell')
Loading files is just a matter of selecting Open File.. from the file menu
(or pressing Ctrl-C, Ctrl-F) saving is done via the menu of Ctrl-C, Ctrl-S.
You can also load a directory list (Ctrl-x, Ctrl-d or look in the File menu)
from which you can load files just by highlighting them wiht the mouse
(navigattion through the directory tree is also possible).
You can switch between buffers by pressing Ctrl and the left mouse button to
get a list, then select the buffer from the menu. There are modes for more
or less every programming language (including rebol), configuration of the
program's options is done via a hierarchical menu system, you can even
interactively launch internal operations by pressing Alt-X and then typing
th ecommand (with autocomplete no less) and...
Well really all I can suggest is that you give it a whirl - emacs is one of
those things you either love or hate. Unlike the shell-only version you
don't need to memorise all the keyboard commands (and most of the basic ones
are easy to pick up and remember, mostly Ctrl-combos) and 21.1 is a big
improvement over previous versions.
Chris
--
.------{ http://www.starforge.co.uk }-----. .--------------------------.
=[ Explorer2260, Designer and Coder \=\ P: TexMaker, ROACH, site \
=[___You_will_obey_your_corporate_masters___]==[ Stack: EETmTmTRRSS------ ]
[20/24] from: joel:neely:fedex at: 13-Mar-2002 7:16
Hi, Louis, (yet again ;-)
Dr. Louis A. Turk
wrote:
> > :set nowrap
>
> But sometimes I want the lines wrapped, but I don't want the
> wrapped part of the lines skipped when moving the cursor up
> or down. Why can't I find that perfect editor?
>
I have yet to find an editor that has a fully functional DWIM
command (Do What I Meant ;-).
Tim's post reminded me that there's one other option to consider
in your long-lines cases (at least if they are caused by use
of tabs to indent source code):
Type the command
:set ts=4
to tell vim that you want tabs to be treated as 4 characters
wide (instead of the default 8). That often keeps deeper
lines from needing to wrap at all. If you *REALLY* want to
be kind to yourself (and a REBOL hero ;-) follow that command
by
:set et
(this one's in vim, not vi) which says to expand tabs to the
equivalent number of spaces. That way you can use the tab
key without fear while composing code, but the result will be
to have spaces inserted for the indentation. Again, this will
put off line-wrapping a bit longer, but will also maye your
resulting file more consistent for printing/emailing/etc.
-jn-
--
; sub REBOL {}; sub head ($) {@_[0]}
REBOL []
# despam: func [e] [replace replace/all e ":" "." "#" "@"]
; sub despam {my ($e) = @_; $e =~ tr/:#/.@/; return "\n$e"}
print head reverse despam "moc:xedef#yleen:leoj" ;
[21/24] from: joel:neely:fedex at: 13-Mar-2002 7:10
Hi, Tim,
Tim Johnson wrote:
> To advocate for Chris here, I believe that emacs is an easier
> start than vim...
>
To be fair, I must admit that I've purchased the O'Reilly book
on GNU Emacs and plan to start (again) trying it out for some
things. However, I've never understood why some folks think
control-x control-f <filename>
is easier than
:e <filename>
to open a file, or why
control-b control-n control-p control-f
are easier than
h j k l
to move left, down, up, and right, respectively.
When I made the conscious decision years ago to learn vi
instead of emacs, it was solely for the pragmatic reason that
I found vi on more platforms that I was using than emacs.
That certainly isn't the case today, although it is still the
case that vi/vim has a much smaller footprint than emacs.
AFAICT, both allow you to start doing elementary text editing
with only about a dozen or so commands, and both probably have
more esoteric features than I will ever need in my lifetime.
Both are programmable (emacs in lisp, vim in perl -- and I
think I've seen references to a Python extension). The most
substantial difference that comes to mind is that vi/vim has
only two "modes"
- command mode: in which your keystrokes are interpreted as
commands telling vi/vim to manipulate or
move within your buffer, and
- insert mode: in which your keystrokes are interpreted as
data to be placed into the buffer;
while emacs has *lots* of modes, having to do with what kind
of data it assumes you are editing and whether it should be
doing context-dependent things (and allowing context-dependent
commands?) based on the kind of data (e.g. c source versus
lisp source versus English text, etc...)
> :set nowrap
>
I'm glad you mentioned that option, but I guess we should point
out that it makes the contents of the screen scroll horizontally
when moving through lines wider than the window, and some folks
find that distracting. In addition, it makes *very* deeply
indented lines look like blank lines if you are sitting at the
left-hand margin. However, as I said, I'm glad you brought it
up because it *IS* another option to consider.
-jn-
--
; sub REBOL {}; sub head ($) {@_[0]}
REBOL []
# despam: func [e] [replace replace/all e ":" "." "#" "@"]
; sub despam {my ($e) = @_; $e =~ tr/:#/.@/; return "\n$e"}
print head reverse despam "moc:xedef#yleen:leoj" ;
[22/24] from: chris:starforge:demon at: 13-Mar-2002 17:53
#Wednesday 13 March 2002 13:10# Message from Joel Neely:
> To be fair, I must admit that I've purchased the O'Reilly book
> on GNU Emacs and plan to start (again) trying it out for some
> things. However, I've never understood why some folks think
>
> control-x control-f <filename>
>
> is easier than
>
> :e <filename>
The main difference here is that, unless you're using the Version Of Emacs
For The Psychotically Masocistic (ie: running it in a plain tty), you have
the option of using a mouse and menu in emacs. When I started learning emacs
I didn't use the keyboard shortcuts - I didn't know most of them. Instead I
used the menus: they provide access to the options most people need when
they're just starting to use an editor. With vim you're dropped in at the
deep end - you either learn the commands quickly, or you get stuck.
> to open a file, or why
> control-b control-n control-p control-f
> are easier than
> h j k l
> to move left, down, up, and right, respectively.
Can't say I use them at all - I just use the cursor keys ;)
> That certainly isn't the case today, although it is still the
> case that vi/vim has a much smaller footprint than emacs.
Definately, especially comparing a full install of emacs on
Linux (around 48Mb) to vim (about 400k).
> AFAICT, both allow you to start doing elementary text editing
> with only about a dozen or so commands,
Yes, although as I say IMO emacs is easier to start with as the
basic (and some not so basic) options are usually avilable in a
menu.
> while emacs has *lots* of modes, having to do with what kind
> of data it assumes you are editing and whether it should be
> doing context-dependent things (and allowing context-dependent
> commands?) based on the kind of data (e.g. c source versus
> lisp source versus English text, etc...)
It's a bit more complex than that, because you have major modes
(which are chosen basedon the type of data in the buffer) and
minor modes which modify or add functionality to the major mode.
For example, when I load a c file emacs switches to c-mode, but
I can also start hs-minor-mode on top of that (which allows
blocks of code to be "folded").
Chris
--
.------{ http://www.starforge.co.uk }-----. .---------------------------.
=[ Explorer2260, Designer and Coder \=\ P: TexMaker, Draktar \
=[_[ You will obey the corporate masters. ]_]==[ Stack: EEOeOeOeTmTmDD---- ]
--
Fifth Law of Procrastination:
Procrastination avoids boredom; one never has the feeling that
there is nothing important to do.
[23/24] from: joel:neely:fedex at: 13-Mar-2002 13:33
Hi, Chris,
Chris wrote:
> The main difference here is that, unless you're using the Version
> Of Emacs For The Psychotically Masocistic (ie: running it in a
<<quoted lines omitted: 4>>
> to use an editor. With vim you're dropped in at the deep end - you
> either learn the commands quickly, or you get stuck.
Sorry, but not so. See my other post laying emacs and vim side by
side, but the key point is that gvim *DOES* allow the use of mouse
selection, menu actions, etc...
-jn-
PS: Maybe it makes my Psychotically Masochistic, but even when using
gvim in XWindows or w32, I still use the keyboard for most things
instead of having to stop, move my hand to the mouse, wiggle the mouse
around while mashing and releasing buttons, then move my hand back to
the keyboard to continue typing. In short, I (personal opinion here)
see mice as good for two things:
1) training wheels for apps I don't use very often, and which
therefore my fingers haven't learned to drive on autopilot, and
2) apps which actually depend on hand/eye coordination, such as
graphics programs.
When I'm programming or writing text, I usually think much faster
than I can type (or should I say "type much slower than I think" ;-)
and so begrudge the time I have to spend with my hands off of the
keyboard.
[24/24] from: joel:neely:fedex at: 13-Mar-2002 14:15
Hi, all,
Just for the sake of clarification, comparison, and contrast (not for
advocacy -- I suspect that the more one thinks about it the smaller
the differences appear), let me offer corresponding information for
vim.
the current official version of vim (6.0 -- 6.1 is still considered
beta).
Chris wrote:
> Emacs-21.1 is the latest (and best) version of Emacs, you can
> obtain it from
>
> ftp://ftp.gnu.org/gnu/windows/emacs/21.1/emacs-21.1-fullbin-i386.tar.gz
>
Vim 6.0 is the latest user release (6.1 is beta as of this note),
and is available from many mirrors, including
ftp://ftp.us.vim.org/pub/vim/
> The file is about 16Mb, winzip can understand the tar.gz - you
> just need to unpack it somewhere on your system and run
> emacs-21.1\bin\emacs.exe
>
IIRC you can get everything in one file, for example on w32,
ftp://ftp.us.vim/org/pub/vim/pc/gvim60.exe
which is about 3.5 Mb. Download and execute it to start the install.
> For an example of the different between emacs an vim, take your
> recent cut and paste problem. In emacs you just highlight the
<<quoted lines omitted: 5>>
> the middle mouse button. Copy and paste between other programs via the
> clipboard works as well.
I just did essentially the same thing in gvim 6.0 on my work box running
w2k. I selected text by dragging across it with the mouse, right
clicked
to get a menu containing "Copy", clicked in a different location, right
clicked to get a menu containing "Paste" et voila...
I could also have used the "Copy" and "Paste" commands from the menu bar
in the gvim window, or I could have set the cursor position with the
mouse
and used keyboard commands
"+P or [p
to put the copied text before the cursor or
"+p or ]p
to put the text after the cursor.
> Emacs also offers multiple buffers visible in a single window,
>
As does vim.
> or multiple windows each with multiple buffers (makes working on
> multiple sources easy).
>
Which I've done on a few occasions by simply starting vim twice (or
more).
> You can even launch a DOS prompt inside the editor to test your
> code without having to start DOS explicitly (press Alt-X, then
> type 'shell')
>
Using vim on A Real O/S you can:
- use
:!<command>
to run a command and then return to vim (this also works on
wimp-dos),
- use
control-z
to suspend vi/vim (if you're using a shell with job control, such
as ksh), do something else, and then resume vi/vim with the
fg
commmand, or
- use
:!<shellname>
to suspend vi/vim and run the named shell (such as sh, ksh, etc.)
then type
exit
to return to the editing session.
In the latter two cases, of course, you can run anything you want,
whether compiles or whatever.
> Loading files is just a matter of selecting Open File.. from the
> file menu
>
Same with gvim
> (or pressing Ctrl-C, Ctrl-F)
>
which is equivalent to one of
:e <filename>
or
:browse e
(which brings up the system file-open dialogue) in gvim.
> saving is done via the menu of Ctrl-C, Ctrl-S.
>
Via "Save" or "Save as..." in the menu, or simply by
:w
in a buffer that was read from a file, or
:sav
to do the equivalent of "Save as...".
> You can also load a directory list (Ctrl-x, Ctrl-d or look in the
> File menu) from which you can load files just by highlighting them
> wiht the mouse (navigattion through the directory tree is also
> possible).
>
See the above description of ":browse e"
> You can switch between buffers by pressing Ctrl and the left mouse
> button to get a list, then select the buffer from the menu.
>
You can select which buffer you want in the current window/frame by
picking it from the "Buffers" menu.
Typing
:e#
switches you to "the other" (most recent) edit buffer for the
individual frame you are in. If you have two (or more) frames open
in the window, each frame as two buffers that it can switch between
with the above command.
You can also use keyboard commands such as
:#b
(where "#" is a number, not the character "#") to pick which buffer
to display in the current window/frame, or
:#bn
(where, again "#" indicates a number) to pick the buffer that is #
positions next/forward in the (circular) list of buffers.
There are lots of variations, but these make the point that you can
be working on (and viewing) multiple files simultaneously in gvim, and
can move among them quickly using either the mouse/menus or keystrokes.
> There are modes for more or less every programming language
> (including rebol),
>
gvim has syntax coloring (with some fairly sophisticated control, see
the March 2002 issue of Linux Magazine for an article that shows how
to have intelligent syntax coloring that supports a mixture of Scheme
and Perl in the same file.
As for "mode" in the sense of distinct editing behavior depending on
the contents of the edit buffer, one can define macros to do specific.
arbitrarily complex editing actions. Those definitions can be either
global to the editing session or local to a specific buffer.
> configuration of the program's options is done via a hierarchical
> menu system,
>
Also available with gvim.
> you can even interactively launch internal operations by pressing
> Alt-X and then typing th ecommand (with autocomplete no less)
> and...
>
vim can be compiled to have a Perl or Python interface, thus allowing
you to script vim in either of those languages to manipulate text
being edited. When using (for example) a Perl-scriptable copy of vim,
you can have a Perl command executed against a specified range of the
current buffer, all with a single entry on the command line.
I could point out that having an open-source version of REBOL would
allow us to have a REBOL-scripted editor (but I won't do so... ;-)
Again, my point here is not advocacy, but rather the assertion that
both emacs and gvim have evolved along parallel trajetories so that
most features/capabilities of one appear somewhere in the other,
although with some variation of details.
By all means, try all the editors you can get your hands on (and have
time to fiddle with) then make your selection based on what meets your
own needs. My choice for editors was driven by the same philosophical
issues that attracted me to REBOL
1) cross-platform
2) compact
but YMMV!
-jn-
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted