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

Best practice on cleaning vimrc files

Expand Messages
  • Malusi Gcakasi
    ... I m new to Vim and have been wondering about this for a bit. As most vimrc and gvimrc setups are similar, is it good practice to split these into different
    Message 1 of 3 , Feb 12, 2013
    • 0 Attachment
      > Yet my settings in GVim and Vim (terminal) are identical...

      I'm new to Vim and have been wondering about this for a bit. As most vimrc
      and gvimrc setups are similar, is it good practice to split these into
      different files? Or should they simply be split into different functions and
      centralized in one file with the "gui_running" flag?

      " Now running a gvim function
      If("gui_running")
      Foo()
      Bar()
      Endif

      Secondly, what are the best practices for how a vimrc setup should be
      structured. Or are the details of this up to the individual user?

      Kind Regards
      Malusi Gcakasi

      --
      --
      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Tony Mechelynck
      ... You can do either. Remember though, that vimrc si not only for Console Vim but also for gvim (which performs the whole ordinary startup described under
      Message 2 of 3 , Feb 12, 2013
      • 0 Attachment
        On 12/02/13 15:31, Malusi Gcakasi wrote:
        >> Yet my settings in GVim and Vim (terminal) are identical...
        >
        > I'm new to Vim and have been wondering about this for a bit. As most vimrc
        > and gvimrc setups are similar, is it good practice to split these into
        > different files? Or should they simply be split into different functions and
        > centralized in one file with the "gui_running" flag?
        >
        > " Now running a gvim function
        > If("gui_running")
        > Foo()
        > Bar()
        > Endif

        You can do either.

        Remember though, that vimrc si not only for Console Vim but also for
        gvim (which performs the whole "ordinary" startup described under ":help
        startup", adding at step 8 the GUI startup described under ":help gui-init".

        Also, it is not :if("gui_running") [which will always return FALSE, even
        in gvim, since it means: if there is a nonzero number at the start of
        the string 'gui_running'], but :if has("gui_running") — see
        :help has()
        :help feature-list " and scroll down until gui_running

        >
        > Secondly, what are the best practices for how a vimrc setup should be
        > structured. Or are the details of this up to the individual user?
        >
        > Kind Regards
        > Malusi Gcakasi
        >

        The details are up to the individual user.

        This said, I recommend (but it is just my opinion) to source the
        vimrc_example.vim from your vimrc and add additional to that any desired
        settings (including, if desired, overrides to undo things that the
        example vimrc does that you don't want), mostly after that line but some
        might have to go before it. I also recommend to comment every script
        heavily (Vim comments start with a double quotation mark and extend to
        the end of the line, but they cannot be used after some commands which
        regard the quote as part of their arguments).

        Example of a "vimrc stub" to be further customized by its user:



        " Vim configuration script

        " force English messages
        " this must come before setting up menus
        " remove this whole nested :if if not desired
        if has("multi_lang") " otherwise there is no :language command
        if has("unix") " only POSIX OSes know about the C locale
        language messages C
        else " assume Windows (Mac OS 9 is long obsolete)
        language messages en
        endif
        endif

        " source the example vimrc from $VIMRUNTIME
        runtime vimrc_example.vim

        " undo filetype-specific indent set by the example vimrc
        filetype indent off " comment this line out if you want FT indents

        " additional user settings come here



        Best regards,
        Tony.
        --
        And on the seventh day, He exited from append mode.

        --
        --
        You received this message from the "vim_use" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php

        ---
        You received this message because you are subscribed to the Google Groups "vim_use" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • John Beckett
        ... It would be good if that were documented somewhere in a simple way. The following has some ideas. http://vim.wikia.com/wiki/Keep_your_vimrc_file_clean John
        Message 3 of 3 , Feb 12, 2013
        • 0 Attachment
          Malusi Gcakasi wrote:
          > Secondly, what are the best practices for how a vimrc setup
          > should be structured. Or are the details of this up to the
          > individual user?

          It would be good if that were documented somewhere in a simple
          way. The following has some ideas.

          http://vim.wikia.com/wiki/Keep_your_vimrc_file_clean

          John

          --
          --
          You received this message from the "vim_use" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php

          ---
          You received this message because you are subscribed to the Google Groups "vim_use" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
        Your message has been successfully submitted and would be delivered to recipients shortly.