Loading ...
Sorry, an error occurred while loading the content.
 

RE: Learning vim "portably"

Expand Messages
  • Halim, Salman
    Okay; here goes: You have a pretty extensive help system available to you in Vim, including a tutorial to get you started. Try :help as a command (remember
    Message 1 of 6 , Apr 2, 2004
      Okay; here goes:

      You have a pretty extensive help system available to you in Vim,
      including a tutorial to get you started. Try :help as a command
      (remember that commands are preceded by the tapping of a colon to take
      you to the command-line, hence this paradigm) to get you started.

      So, to figure out what "behave", "source" and "nocompatible" do, try
      :help behave, :help source and :help nocompatible.

      You can further examine the contents of any file being "source"d for
      more information; try :help gf.

      By the way, I got sick of hitting the : (shift-;) all the time, so have
      the following in my _vimrc:

      map ; :

      _vimrc commands don't need to be started with a : -- it is assumed.
      This allows me to simply hit ; (without the shift) and get to the
      command prompt. Note that the ; DOES perform a function in Vim, which
      you will lose. (:help ;)

      Now, the mswin lines in your _vimrc below are definitely going to tailor
      the behaviour toward a Windows user and are probably not what you'd want
      in a cross-platform Vim environment (I don't use them, personally).

      In a nutshell, 'compatible' (and nocompatible) toggle some vi-specific
      behaviours -- to use Vim to its advantage, you DON'T want to be
      compatible, so the nocompatible line is better. To give you one
      example, standard vi only has one undo/redo, but Vim has a
      user-specified undo size -- you can read :help undo to get an in-depth
      idea of it, but the default values are pretty good, so just read the top
      portion of :help undo to get you started there.

      If you want a true vanilla Vim, you could remove all lines from the
      _vimrc except the nocompatible one.

      Hope this helps,

      Salman.

      -----Original Message-----
      From: Chris Lott [mailto:chris@...]
      Sent: Friday, April 02, 2004 1:55 PM
      To: Vim Mailing List
      Subject: Learning vim "portably"


      I've decided it is high time that I learn to use vim. Though I am
      confirmed emacs user, there are times when it is not available. However,

      I would like to learn vim in a way that is as portable as possible. My
      primary computer runs windows xp.

      I installed gvim62.exe and it seems to work fine. However, I noticed
      that by default it has a number of things configured for me. A few of
      these look like windows specific hackery/emulation. So my question is,
      what represents a "vanilla" vim installation as I am likely to encounter

      it on a foreign system, particularly a Unix/Linux system running X?

      The default _vimrc looks like the following: should I just get rid of
      the mswin.vim line?

      **
      set nocompatible
      source $VIMRUNTIME/vimrc_example.vim
      source $VIMRUNTIME/mswin.vim
      behave mswin

      set diffexpr=MyDiff()
      function MyDiff()
      let opt = ''
      if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
      if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
      silent execute '!C:\apps\vim\vim62\diff -a ' . opt . '"' . v:fname_in

      . '" "' . v:fname_new . '" > "' . v:fname_out . '"'
      endfunction
      **

      c
      --
      Chris Lott (chris@...)
      http://www.chrislott.org/

      "May my silences become more accurate" --Theodore Roethke
    • Antoine J. Mechelynck
      ... After you read all answers, you will of course decide for yourself. With all the configuration options there are in Vim, I don t think there is one
      Message 2 of 6 , Apr 2, 2004
        Chris Lott <chris@...> wrote:
        > I've decided it is high time that I learn to use vim. Though I am
        > confirmed emacs user, there are times when it is not available.
        > However, I would like to learn vim in a way that is as portable as
        > possible. My primary computer runs windows xp.
        >
        > I installed gvim62.exe and it seems to work fine. However, I noticed
        > that by default it has a number of things configured for me. A few of
        > these look like windows specific hackery/emulation. So my question is,
        > what represents a "vanilla" vim installation as I am likely to
        > encounter it on a foreign system, particularly a Unix/Linux system
        > running X?
        >
        > The default _vimrc looks like the following: should I just get rid of
        > the mswin.vim line?
        >
        > **
        > set nocompatible
        > source $VIMRUNTIME/vimrc_example.vim
        > source $VIMRUNTIME/mswin.vim
        > behave mswin
        >
        > set diffexpr=MyDiff()
        > function MyDiff()
        > let opt = ''
        > if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
        > if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
        > silent execute '!C:\apps\vim\vim62\diff -a ' . opt . '"' .
        > v:fname_in . '" "' . v:fname_new . '" > "' . v:fname_out . '"'
        > endfunction
        > **
        >
        > c
        > --
        > Chris Lott (chris@...)
        > http://www.chrislott.org/
        >
        > "May my silences become more accurate" --Theodore Roethke

        After you read all answers, you will of course decide for yourself. With all
        the configuration options there are in Vim, I don't think there is one
        solution that fits everyone.

        As has been said, you can start with command-lines like

        gvim -u NONE -U NONE

        (for maximum vi compatibility), or

        gvim -u NONE -U NONE -N

        (the same, but with "vim-like" defaults rather that "vi-like" defaults for
        most options). However, this won't read any config files, so, for instance,
        you won't have syntax coloring, and, once you learn how the options work,
        you won't be able to tweak them to your liking.

        The "mswin.vim" script is -- IMHO -- a PITA. I avoid sourcing it even on M$W
        machines. Concerning the ":behave" command, it sets 4 options reversibly, so
        that's less of a problem. Personally I use something which is neither
        ":behave xterm" nor ":behave mswin", but rather is set to my own
        preferences -- but more of that later.

        I like most of the settings set by the "vimrc_example" script -- but not all
        of them. Also, I want the messages from Vim in English and not in the
        language (French) set by MS-Windows. And, finally, I prefer a cross-platform
        vimrc (on my dual-boot machine) so I use "if has()" and if exists()" (see
        ":help has()" and ":help exists()") for better compatibiulity between
        versions and platforms.

        So I would recommend to you a vimrc like the following (lines starting with
        a double-quote are comments):

        set nocompatible
        " Remove from if to endif if you want the
        " messages in the languiage set in the OS
        if has("x11")
        language messages C
        else
        language messages en
        endif
        source $VIMRUNTIME/vimrc_example.vim
        " most user tweaks will come here

        You may want to start using gvim with nothing else. Then stop reading here
        for the time being, but save it, and come back at a later time.

        Once you feel at ease with (g)vim, you will want to tweak some settings. You
        will then, after reading ":help :set", start at ":help option-summary" and
        proceed through the list to set what really suits you. Use

        :set optionname?

        from the keyboard to know the current value of 'optionname', and add one of
        the following lines to your vimrc to set the value you want if it is
        different:

        " to set a boolean option (make it TRUE)
        set optionname

        " to clear a boolean option (make it FALSE)
        set nooptionname

        " to set a value option to the null string
        set optionname=

        " to set a value option to some value
        set optionname=value

        Some options have spaces, etc. in them, that need to be backslash-escaped.
        Instead of

        :set optionname?

        a handy trick is

        :set optionname=<Tab>

        (where <Tab> represents hitting the tab key, see ":help <>") which will
        (assuming that 'compatible' is off) bring up the current value of the option
        with escaping backslashes if and where needed. You may edit the value on the
        command-line, then either hit <Enter> to accept the changes, or <Esc> to
        abandon the changes.

        Another possibility is to use the "options window", which is brought up by
        the ":options" command, and/or the ":mkvimrc" command (see ":help :mkvimrc")
        to write a vimrc with most of the current settings (however, 'lines' and
        'columns' are not written, although they are handy to resize the gvim
        window). Also, the file written by ":mkvimrc" will of course not contain
        "source" lines; rather, it will explicitly set all the settings, which may
        make it unwieldy compared to a vimrc which you would build up little by
        little, starting with something fairly simple as shown above.

        HTH,
        Tony.
      • Antony Scriven
        ... If you are going to be using random Unix boxes then be prepared for no vim either. But don t worry, Vim is 99% vi compatible. Stay away from the scroll bar
        Message 3 of 6 , Apr 2, 2004
          Chris Lott wrote:

          > I've decided it is high time that I learn to use vim. Though I am
          > confirmed emacs user, there are times when it is not available. However,
          > I would like to learn vim in a way that is as portable as possible. My
          > primary computer runs windows xp.
          >
          > I installed gvim62.exe and it seems to work fine. However, I noticed
          > that by default it has a number of things configured for me. A few of
          > these look like windows specific hackery/emulation. So my question is,
          > what represents a "vanilla" vim installation as I am likely to encounter
          > it on a foreign system, particularly a Unix/Linux system running X?

          If you are going to be using random Unix boxes then be
          prepared for no vim either. But don't worry, Vim is 99% vi
          compatible. Stay away from the scroll bar and arrow keys and
          you'll be fine :-) The tutorial is a good one, and it
          teaches you all the basics which are present in any version
          of vi.

          >
          > The default _vimrc looks like the following: should I just get rid of
          > the mswin.vim line?
          >
          > **
          > set nocompatible

          Hmm, does this need to be unset? I thought the mere
          prescence of a .vimrc (I'm assuming also a _vimrc) would set
          nocompatible.

          > source $VIMRUNTIME/vimrc_example.vim

          This changes a few things, but not a lot, and nothing bad
          (unless you like ex mode :-). It's a standard file, so all
          systems should have it. If you add more stuff to your vimrc
          make sure it comes after this line. It sets nocompatible
          which in turn sets some other options.

          > source $VIMRUNTIME/mswin.vim

          This is for people who /have/ to hit Ctrl-F4 to close a
          window and Ctrl-V to paste. It sounds like you don't want
          this.

          > behave mswin

          This sets mouse/selection behaviour. See `:help behave' to
          check what this does. I would suggest that you don't use
          this either. But some people prefer things to be more
          windowsy when on a windows system.

          Hmm, mswin.vim does a `behave mswin' anyway so I don't know
          why that's in the file.

          Antony
        Your message has been successfully submitted and would be delivered to recipients shortly.