Vim and vi

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

Vim and vi

viktiglemma
Hi,

As a relatively new Vim user I have gathered that vi is an old text editor that has spawned many so called clones and Vim is one of them.

As I read the documentation for Vim, I feel that half the text I'm reading is about how this command is different from how it is in vi or not and all the things that are not possible to do in vi.

Why doesn't Vim leave vi behind? As a new user I do not benefit from all the vi-information. The only two reasons I see why vi should continually be referenced are
1) there are still a large number of people using vi and who will be very confused if they are ever forced to work in Vim
2) sentimentality and appreciation for vi as the mother editor

The last one, in my opinion, is not a valid reason to include so much vi-information in the help files.

What do you think?
Reply | Threaded
Open this post in threaded view
|

Re: Vim and vi

Raúl Núñez de Arenas Coronado-2

Saluton viktiglemma :)

On Tue 5 May 2009 11:58 +0200, viktiglemma <[hidden email]> dixit:
> Why doesn't Vim leave vi behind? As a new user I do not benefit from
> all the vi-information.

Myself, I don't even see the point of Vim being able to behave
"compatibly" with old vi, but I know that Bram has his reasons and as
the author, he has the right of doing things that way. While for me
":set nocp" is basic, for many other users it may be wrong not being
able to ":set cp".

> The only two reasons I see why vi should continually be
> referenced are
> 1) there are still a large number of people using vi and who will be very
> confused if they are ever forced to work in Vim
> 2) sentimentality and appreciation for vi as the mother editor

3) vi is a POSIX standard command, and if I remember correctly, you can
even read how it should behave and be used in Single Unix Specification
v3. Being as compatible as possible with POSIX vi may be of help if you
have to use Vim on some machines, other vi flavors in other machines,
who knows.

4) It would probably take more time getting rid of POSIX-vi information
from help files than maintain it.

5) There is a large number of people using POSIX vi or any other
POSIX-vi compatible vi implementation that may want to switch to Vim,
and being able to behave in a compatible way with POSIX vi makes such
transitions less painful.

6) Many people may have switched to Vim after years of having use POSIX
vi and may wonder why Vim doesn't do certain things like POSIX vi. The
help files give them the information.

7) Any other set of reasons Bram may have. ;)

--
Raúl "DervishD" Núñez de Arenas Coronado
Linux Registered User 88736 | http://www.dervishd.net
It's my PC and I'll cry if I want to... RAmen!

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

RE: Vim and vi

Rogers, Brian A.
On Tue 5 May 2009 11:58 +0200, viktiglemma <[hidden email]> dixit:
> Why doesn't Vim leave vi behind? As a new user I do not benefit from
> all the vi-information.

Personally, I am ecstatic that Vim is grounded in vi.  I am/was a vi user and the transition has been entirely seamless.  My friend suggested Vim to me and now we trade tips that we picked up from being core Vim or core Vi users.

Having Vim grounded in vi, in my opinion, is also a great thing since, again, in my opinion, vi is the ultimate in efficiency.  There is so much I can do in vi many many times faster than a big IDE editor.  Often to the extent that I'll leave the IDE, make the changes in vi, and then go back.  Vim carrying on this tradition is very honorable!

Those are just my 2 cents.  Good question!

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Vim and vi

Karl Guertin
In reply to this post by viktiglemma

On Tue, May 5, 2009 at 5:58 AM, viktiglemma <[hidden email]> wrote:
> As I read the documentation for Vim, I feel that half the text I'm reading
> is about how this command is different from how it is in vi or not and all
> the things that are not possible to do in vi.
>
> Why doesn't Vim leave vi behind? As a new user I do not benefit from all the
> vi-information.

The vi information is a product of Vim's origins as a vi clone. Vim is
closing in on 20 years of continuous development by Bram and there was
an extended period of time where Vim was one of a number of clones
instead of the primary clone that more or less everybody uses. The
help files continuously reference it because it documents the
deviations from the original, which is helpful if you're switching.

As for the :set cp behavior, a significant fraction of mastering vi is
not learning the commands so much as it is knowing how to apply them
(idoms) and being able to do so without having to think about it
(tacit application). As an example, when you're in an argument list
for a C like language, %by% copies the function call. Veteran vi(m)
users have a huge bag of these tricks (e.g. ci" replaces the content
of a string, ctC is useful for editing camelCase words, etc)  and
they're all very much dependent on things working like you expect. I
go crazy on shallow vi copies because they only implement the basics
and my idioms fail. For veterans that have a set of idioms built
around the base vi behaviors, the :set cp option can be important.

Also, having it in the help files doesn't really hurt anything and
it'd probably be more effort to remove all the references than it is
to type 'this feature does not exist in vi' for the new features. If
you don't care about the vi information, ignore it.

Regards.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Vim and vi

Reid Thompson

On Tue, 2009-05-05 at 07:22 -0400, Karl Guertin wrote:
> As an example, when you're in an argument list
> for a C like language, %by% copies the function call. Veteran vi(m)
> users have a huge bag of these tricks (e.g. ci" replaces the content
> of a string, ctC is useful for editing camelCase words, etc)

got any pointers to links listing other examples?

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Vim and vi

viktiglemma
Thanks for your answers, guys! I was curious how the experienced user looked upon this issue.

Since there are still people transiting from vi or switching back and forth I guess it is still useful to maintain the information in the help files.
Reply | Threaded
Open this post in threaded view
|

Re: Vim and vi

Tim Chase
In reply to this post by Karl Guertin

> Veteran vi(m) users have a huge bag of these tricks (e.g. ci"
> replaces the content of a string,

Just a note here:  text-objects are a vim add-on and aren't in
classic vi.  And even the quotation text-objects are fairly new
(added in 7.0 I believe, as I believe I was the one to suggest
their addition to 6.2[1] :)  I'm repeatedly thankful to whomever
implemented them!

Additionally, most of the "Vim vs. vi" differences are
consolidated in

   :help vi_diff.txt

though there are references elsewhere in the docs.  Just in case
you want to see most of them in one place.

-tim


[1] http://42.pl/tex/prog/vim/todo.html





--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Vim and vi

Karl Guertin
In reply to this post by Reid Thompson

On Tue, May 5, 2009 at 7:37 AM, Reid Thompson <[hidden email]> wrote:
> got any pointers to links listing other examples?

The Vim tips [1] is a ridiculously huge collection of them. The
problem is that it's huge and significant swaths of it are not going
to be useful to you. The closest thing I know of a coherent collection
is Efficient Editing in Vim [2], but that's just a start. Bram gave a
google tech talk about building your idioms (though he didn't call it
that) and the general idea is that you should notice when you're
repeating yourself and figure out the correct way to do it. This is no
different from noticing copying/pasting code and upping your
abstraction to cover future cases. Everybody's idioms are different.

[1] http://vim.wikia.com/wiki/Category:VimTip
[2] http://jmcpherson.org/editing.html

My general tips beyond Efficient Editing are:

* know and love the f and t motions and the text objects. There are a
LOT of tricks with these, far too many to list. E.g. =i{ indents your
current block in a c like language, ct, is useful for replacing
arguments, swapping nested array access ``a['o|ne']['two']``
->``a['two']|['one']`` is da[%p (or P if you're going the other way),
etc, etc, etc. Text object motions are particularly useful because
they're generally effective when you repeat.
* % jumps between parens and whatnot but it also SEARCHES FORWARD and
jumps if you're not on a matchpair character. Primary use for this is
function calls/definitions
* `` is your friend. The rest of the mark movements are useful but ``
is the best.
* I love visual block mode for ad hoc linewise stuff, I inserts on
every line, A appends on every line.
* I use :'<,'>s/pattern/replace/ daily, frequently in context with a
visual selection via % or `a
* \zs and \ze  in patterns are very convenient
* Fastest way to remove the word under the cursor from the entire file
is *:%s///g and you get back to where you started with ``
* I don't find the ' motion useful over `, so I :nnoremap ' @a in my
.vimrc and always do macros into the a register so I can trivially
repeat it with '. It's then generally <c-n>'  to jump to the next
location and re-execute the macro
* The J and gJ commands
* :g and :g! are selectively handy, particularly :g!/pattern/d,
:g/^/m0, :g/pattern/m$

Beyond that, you get into more setup dependent idioms. Some examples
(| is cursor):

* I like splits for editing multiple files and :map <C-J> <C-W>j<C-W>_
(and same for <C-K>) for flipping between files.
* I like using <Leader> mappings for toggling settings (e.g. \p
toggles paste). Examples:
        :noremap <silent> <Leader>p :se invpaste<CR>:echo &paste ?
"Paste ON!" : "Paste off"<CR>
        :noremap <silent> <Leader>l :se invlist<CR>
        :noremap <silent> <Leader>n :se invhlsearch<CR>
*  if my current line looks like ``get(a['foo|'])``, typing ) gets me
``get(a['foo'])|`` due to my autoclose.vim plugin
*  using the same ``get(a['foo|'])``, <esc>cs'" gets me
``get(a["foo|"])`` while csw{ produces ``get(a['{foo|}'])`` both due
to the surround.vim plugin
* If I have ``<tr|``, closing the tag with > produces ``<tr>|</tr>``
and a second > splits the tags onto different lines with the cursor
between them at the correct indent. This is from a special xml.vim
* I have an extensive set of snippets that I'm migrating from
snippetsEmu to the most excellent snipMate. Using a snippets plugin
and curating your own set of snippets is the bee's knees. I don't
generally like other people's snippets but mine are probably the
biggest single speedup in my toolkit. I actually use ; as my snippet
expansion because I like to keep tab for word completion.

You just build them up over time. A lot aren't useful to other people,
hence why I call them idioms.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Vim and vi

Karl Guertin
In reply to this post by Tim Chase

On Tue, May 5, 2009 at 8:28 AM, Tim Chase <[hidden email]> wrote:
> Just a note here:  text-objects are a vim add-on and aren't in
> classic vi.  And even the quotation text-objects are fairly new
> (added in 7.0 I believe, as I believe I was the one to suggest
> their addition to 6.2[1] :)  I'm repeatedly thankful to whomever
> implemented them!

Yes. Before I found text objects I was doing stuff like T"c, to
replace strings, which is less convenient and robust. Thanks for
making the suggestion.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

RE: Vim and vi

Gene Kwiecinski
In reply to this post by viktiglemma

>Why doesn't Vim leave vi behind? As a new user I do not
>benefit from all the vi-information. The only two reasons

In "compatible mode", you can turn 'vim' into 'vi', essentially.  Still,
people who come from different environments are still used to the 'vi'
way of doing things, and in fact, I disliked undo/redo at first, as I
could "uuuuuuu..." in 'vi' and see the exact last-change being toggled
on/off (in/out, whatever) almost like looking at 2 almost-identical
sheets of printed paper held up to the light to see the small difference
between the 2.

Point being, sometimes people will start out in compatible mode to get
the feel for the new editor, then gradually phase in the new
functionality.  Once you start to deviate too far from its base, it no
longer is a 'vi' variant, but is its own new (and different) editor.

At that point, might as well go all-out and call it something else, not
'.*vi.*'.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Vim and vi

Benjamin Fritz
In reply to this post by Karl Guertin



On May 5, 9:56 am, Karl Guertin <[hidden email]> wrote:

> On Tue, May 5, 2009 at 7:37 AM, Reid Thompson <[hidden email]> wrote:
> > got any pointers to links listing other examples?
>
> The Vim tips [1] is a ridiculously huge collection of them. The
> problem is that it's huge and significant swaths of it are not going
> to be useful to you.
>
> [snip]
>
> [1]http://vim.wikia.com/wiki/Category:VimTip

Woah! No wonder the Vim Tips seem overwhelming...

Don't look at them all at once, browse for areas that interest you:
http://vim.wikia.com/wiki/Category:Browse

After you've got that out of the way, pressing "Random page" two or
three times daily will give you some good (or at least interesting)
tips in a manageable dosage.

Also, don't forget the featured tips page for a quick glance at some
of our best:
http://vim.wikia.com/wiki/Vim_Tips_Wiki:Featured_Tip
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Vim and vi

Charlie Kester

On Tue 05 May 2009 at 20:00:52 PDT Ben Fritz wrote:

>
>Woah! No wonder the Vim Tips seem overwhelming...
>
>Don't look at them all at once, browse for areas that interest you:
>http://vim.wikia.com/wiki/Category:Browse
>
>After you've got that out of the way, pressing "Random page" two or
>three times daily will give you some good (or at least interesting)
>tips in a manageable dosage.
>
>Also, don't forget the featured tips page for a quick glance at some
>of our best:
>http://vim.wikia.com/wiki/Vim_Tips_Wiki:Featured_Tip

Good advice.  I'll add this to my daily routine.  Thanks!

Perhaps this is itself a tip that should be on the main page?

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Vim and vi

Tony Mechelynck
In reply to this post by viktiglemma

On 05/05/09 11:58, viktiglemma wrote:

>
>
> Hi,
>
> As a relatively new Vim user I have gathered that vi is an old text editor
> that has spawned many so called clones and Vim is one of them.
>
> As I read the documentation for Vim, I feel that half the text I'm reading
> is about how this command is different from how it is in vi or not and all
> the things that are not possible to do in vi.
>
> Why doesn't Vim leave vi behind? As a new user I do not benefit from all the
> vi-information. The only two reasons I see why vi should continually be
> referenced are
> 1) there are still a large number of people using vi and who will be very
> confused if they are ever forced to work in Vim
> 2) sentimentality and appreciation for vi as the mother editor
>
> The last one, in my opinion, is not a valid reason to include so much
> vi-information in the help files.
>
> What do you think?

Well, I came to Vim without ever having used vi, and I had a vimrc (and
therefore 'nocompatible') from the start.

However, nowadays a significant part of my involvement in Vi consists of
helping newbies solve their problems, and for that it often helps to
detect if the problem might not be that they were in 'compatible' mode
without being aware of it. The {not in Vi} and similar reminders all
over the help are actually pointers to behaviours that might be
different with or without 'compatible'.

Actually there are three, not two, basic "statuses" of the settings
associated with compatibility mode (the 'cpoptions' flags):
- what I regard as "standard Vim behaviour" because it is what I use; it
corresponds to 'nocompatible' mode.
- "Vi-compatible" behaviour, corresponding to 'compatible' mode
- POSIX mode: this is what 'compatible' mode becomes when Vim is started
with $VIM_POSIX environment variable set.

I prefer 'nocompatible' mode, and so, apparently, do you, but the other
two have their reasons for being, as was pointed in the rest of this
thread: 'compatible' mode to make transition from legacy Vi as easy as
possible for the people who still use it, and POSIX mode because even if
POSIX standards are (at least IMHO) not always the best or even
sensible, at least all implementors of Unix-like software have some
knowledge of them, which make them a kind of "portability base" between
program built on different sources but trying to mimic the behaviour of
some common, known utility.


Best regards,
Tony.
--
College football is a game which would be much more interesting if the
faculty played instead of the students, and even more interesting if
the trustees played.  There would be a great increase in broken arms,
legs, and necks, and simultaneously an appreciable diminution in the
loss to humanity.
                -- H. L. Mencken

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Vim and vi

Tony Mechelynck
In reply to this post by Karl Guertin

On 05/05/09 16:56, Karl Guertin wrote:
[...]
> * I like splits for editing multiple files and :map<C-J>  <C-W>j<C-W>_
> (and same for<C-K>) for flipping between files.
[...]

With the following settings:

        :set wmh=0 wh=99999 hh=99999 cwh=99999

which I call "Rolodex Vim", going to any window opens it full-height as
with ^W_ ; then

        :map <F11> <C-W>w
        :map <S-F11> <C-W>W
        :imap <F11> <C-O><C-W>w
        :imap <S-F11> <C-O><C-W>W

allows using F11 to go to the next window, Shift-F11 to the previous
window (like your mappings to other keys do) or either of them with a
count (but not in Insert mode) to go to the nth window.


Best regards,
Tony.
--
"The eleventh commandment was `Thou Shalt Compute' or `Thou Shalt Not
Compute' -- I forget which."
                -- Epigrams in Programming, ACM SIGPLAN Sept. 1982

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Vim and vi

Tony Mechelynck
In reply to this post by Benjamin Fritz

On 06/05/09 05:00, Ben Fritz wrote:

>
>
>
> On May 5, 9:56 am, Karl Guertin<[hidden email]>  wrote:
>> On Tue, May 5, 2009 at 7:37 AM, Reid Thompson<[hidden email]>  wrote:
>>> got any pointers to links listing other examples?
>>
>> The Vim tips [1] is a ridiculously huge collection of them. The
>> problem is that it's huge and significant swaths of it are not going
>> to be useful to you.
>>
>> [snip]
>>
>> [1]http://vim.wikia.com/wiki/Category:VimTip
>
> Woah! No wonder the Vim Tips seem overwhelming...
>
> Don't look at them all at once, browse for areas that interest you:
> http://vim.wikia.com/wiki/Category:Browse
>
> After you've got that out of the way, pressing "Random page" two or
> three times daily will give you some good (or at least interesting)
> tips in a manageable dosage.
>
> Also, don't forget the featured tips page for a quick glance at some
> of our best:
> http://vim.wikia.com/wiki/Vim_Tips_Wiki:Featured_Tip

...and, of course, the built-in help is itself an amazing treasure
trove. IMHO, reading them the way I read the encyclopedia when I was a
kid makes for some really exciting reading: start anywhere, and
(recursively) follow any interesting-looking links to other places of
the help. Or start with a ":help {subject}" or ":helpgrep {pattern}" for
something you want to know about, and follow links from there.

See
        :help
        :help :help
        :help {subject}
        :help :helpgrep

the third of which should be type literally: curly-, ess, you, bee, jay,
eeh, see, tee, -bracket.


Best regards,
Tony.
--
The more laws and order are made prominent, the more thieves and
robbers there will be.
                -- Lao Tsu

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---