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

Reload Buffer

Expand Messages
  • stillLearningVim
    Is there a way to reload the vimrc (and other files), so that the changes in the vimrc take immediate effect. :e doesn t seem to do the trick. I m editing my
    Message 1 of 12 , Dec 20, 2012
    • 0 Attachment
      Is there a way to reload the vimrc (and other files), so that the changes in the vimrc take immediate effect. :e doesn't seem to do the trick.

      I'm editing my vimrc a lot, and I'm hoping there is an easier way than constantly closing and reopening everything.

      Any help and suggestions are appreciated
      Thanks

      --
      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
    • Niels Kobschätzki
      ... i.e.: :source ~/.vimrc Niels -- You received this message from the vim_use maillist. Do not top-post! Type your reply below the text you are replying to.
      Message 2 of 12 , Dec 20, 2012
      • 0 Attachment
        On 21 Dec 2012, at 6:52, stillLearningVim wrote:

        > Is there a way to reload the vimrc (and other files), so that the
        > changes in the vimrc take immediate effect. :e doesn't seem to do the
        > trick.

        :source PATH_TO_FILE
        i.e.: :source ~/.vimrc


        Niels

        --
        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
      • Nicolas Dermine
        ... changes in the vimrc take immediate effect. :e doesn t seem to do the trick. ... That, or ... nico ... -- You received this message from the vim_use
        Message 3 of 12 , Dec 20, 2012
        • 0 Attachment


          On 21 Dec 2012 07:16, "Niels Kobschätzki" <niels@...> wrote:
          >
          >
          > On 21 Dec 2012, at 6:52, stillLearningVim wrote:
          >
          >> Is there a way to reload the vimrc (and other files), so that the changes in the vimrc take immediate effect. :e doesn't seem to do the trick.
          >
          >
          > :source PATH_TO_FILE
          > i.e.: :source ~/.vimrc
          >
          >
          > Niels

          That, or
          :source $MYVIMRC

          nico

          >
          >
          > --
          > 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 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
        • Dominique Pellé
          ... A nice trick is to add the following line in your ~/.vimrc and your .vimrc will then be automatically re-sourced whenever you save it: au! BufWritePost
          Message 4 of 12 , Dec 21, 2012
          • 0 Attachment
            stillLearningVim <trotha01@...> wrote:

            > Is there a way to reload the vimrc (and other files), so that
            > the changes in the vimrc take immediate effect. :e doesn't
            > seem to do the trick.
            >
            > I'm editing my vimrc a lot, and I'm hoping there is an easier
            > way than constantly closing and reopening everything.
            >
            > Any help and suggestions are appreciated
            > Thanks


            A nice trick is to add the following line in your ~/.vimrc
            and your .vimrc will then be automatically re-sourced
            whenever you save it:

            au! BufWritePost .vimrc nested source %

            -- Dominique

            --
            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
          • 李季
            It is useful. -- 李季 ... -- You received this message from the vim_use maillist. Do not top-post! Type your reply below the text you are replying to. For
            Message 5 of 12 , Dec 21, 2012
            • 0 Attachment
              It is useful.




              --
              李季


              At 2012-12-21 16:17:15,"Dominique Pellé" <dominique.pelle@...> wrote:
              >stillLearningVim <trotha01@...> wrote: > >> Is there a way to reload the vimrc (and other files), so that >> the changes in the vimrc take immediate effect. :e doesn't >> seem to do the trick. >> >> I'm editing my vimrc a lot, and I'm hoping there is an easier >> way than constantly closing and reopening everything. >> >> Any help and suggestions are appreciated >> Thanks > > >A nice trick is to add the following line in your ~/.vimrc >and your .vimrc will then be automatically re-sourced >whenever you save it: > >au! BufWritePost .vimrc nested source % > >-- Dominique > >--  >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 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
            • stillLearningVim
              Thanks for the suggestions! Source looks excellent and Dominique, that is a very cool trick. With :source though, it seems to only execute the commands in the
              Message 6 of 12 , Dec 21, 2012
              • 0 Attachment
                Thanks for the suggestions!

                Source looks excellent and Dominique, that is a very cool trick. With :source though, it seems to only execute the commands in the vimrc, so if I remove something it doesn't un-execute if that makes any sense. Is there another way of doing this? Or maybe I'm missing something

                Thanks

                --
                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
              • Marcin Szamotulski
                ... There is no easy way of making it work as you wish, i.e. unset changes. The possible thing is to make a list of all options and prior to execute vimrc file
                Message 7 of 12 , Dec 21, 2012
                • 0 Attachment
                  On 06:01 Fri 21 Dec , stillLearningVim wrote:
                  > Thanks for the suggestions!
                  >
                  > Source looks excellent and Dominique, that is a very cool trick. With :source though, it seems to only execute the commands in the vimrc, so if I remove something it doesn't un-execute if that makes any sense. Is there another way of doing this? Or maybe I'm missing something
                  >
                  > Thanks
                  >
                  > --
                  > 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

                  There is no easy way of making it work as you wish, i.e. unset changes.
                  The possible thing is to make a list of all options and prior to execute
                  vimrc file set all the options to its default value with a loop

                  for se in settings
                  exe 'set '.se.'&'
                  endfor

                  Though this will not work when you set local values (with setl). You
                  can then wrap this loop and a vimrc source command in a function which
                  is called via BufWritePost autocommand.

                  Best,
                  Marcin

                  --
                  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
                • Gary Johnson
                  ... There is also the issue of autocommands. You can unset all of those that were set in your .vimrc by putting them in their own group, then clearing that
                  Message 8 of 12 , Dec 21, 2012
                  • 0 Attachment
                    On 2012-12-21, Marcin Szamotulski wrote:
                    > On 06:01 Fri 21 Dec , stillLearningVim wrote:
                    > > Thanks for the suggestions!
                    > >
                    > > Source looks excellent and Dominique, that is a very cool trick.
                    > > With :source though, it seems to only execute the commands in
                    > > the vimrc, so if I remove something it doesn't un-execute if
                    > > that makes any sense. Is there another way of doing this? Or
                    > > maybe I'm missing something

                    > There is no easy way of making it work as you wish, i.e. unset changes.
                    > The possible thing is to make a list of all options and prior to execute
                    > vimrc file set all the options to its default value with a loop
                    >
                    > for se in settings
                    > exe 'set '.se.'&'
                    > endfor
                    >
                    > Though this will not work when you set local values (with setl). You
                    > can then wrap this loop and a vimrc source command in a function which
                    > is called via BufWritePost autocommand.

                    There is also the issue of autocommands. You can unset all of those
                    that were set in your .vimrc by putting them in their own group,
                    then clearing that group with :au! as the first command in the
                    group. See

                    :help autocmd-remove
                    help :augroup-delete

                    Regards,
                    Gary

                    --
                    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
                  • stillLearningVim
                    @Marcin and @Gary, thanks for the brilliant suggestions of resetting the options and the auto commands. Here s what I ended up with: if !exists( *ReloadVimrc )
                    Message 9 of 12 , Dec 21, 2012
                    • 0 Attachment
                      @Marcin and @Gary, thanks for the brilliant suggestions of resetting the options and the auto commands. Here's what I ended up with:

                      if !exists("*ReloadVimrc")
                      function! ReloadVimrc()
                      au!
                      set all&
                      so $HOME/.vimrc
                      endfunction
                      endif

                      I tried "au BufWritePost .vimrc call ReloadVimrc()", but vim ends up doing something recursive and progressively gives me more errors every time I save (BufWrite isn't supposed to be recursive, not sure what's happening).

                      "au!" removes all autocommands, although I should definitely start putting mine in groups. "set all&" resets all global and local variables to their default values (calling set on anything changes both the local and global, interesting info at ":h local-options" and a cool table a scroll away from ":h setg").

                      Sorry it took me so long to respond. I kept getting a black-and-white every time I called the function. Apparently calling :source on the vimrc didn't change all the options back (used :set before and after calling this function to see changes between non-default options), this included filetype=vim. I hardcoded this into the function, hopefully I can find a better fix later.

                      I usually don't like long posts, so sorry about this one. Thanks again for all the suggestions and cool tips. If you think of anything to improve on this, please let me know. Every little bit helps. Thanks!

                      --
                      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
                    • Adrian Luff
                      I tweaked this a bit and you asked for feedback… Clear then re-read options after editing silent! function! ReloadVimrc() au! set all& source $MYVIMRC
                      Message 10 of 12 , Dec 26, 2012
                      • 0 Attachment
                        I tweaked this a bit and you asked for feedback…
                        " Clear then re-read options after editing
                        silent! function! ReloadVimrc()
                        au!
                        set all&
                        source $MYVIMRC
                        endfunction
                        autocmd! BufWritePost $MYVIMRC nested call ReloadVimrc()

                        With $MYVIMRC this is not platform specific. However, vim forgets that $MYVIMRC is filetype=vim after running. I added a modeline:
                        " vim: set filetype=vim :
                        …to the top of the file as a workaround.

                        -Adrian

                        On Dec 21, 2012, at 10:45 PM, stillLearningVim <trotha01@...> wrote:

                        > @Marcin and @Gary, thanks for the brilliant suggestions of resetting the options and the auto commands. Here's what I ended up with:
                        >
                        > if !exists("*ReloadVimrc")
                        > function! ReloadVimrc()
                        > au!
                        > set all&
                        > so $HOME/.vimrc
                        > endfunction
                        > endif
                        >
                        > I tried "au BufWritePost .vimrc call ReloadVimrc()", but vim ends up doing something recursive and progressively gives me more errors every time I save (BufWrite isn't supposed to be recursive, not sure what's happening).
                        >
                        > "au!" removes all autocommands, although I should definitely start putting mine in groups. "set all&" resets all global and local variables to their default values (calling set on anything changes both the local and global, interesting info at ":h local-options" and a cool table a scroll away from ":h setg").
                        >
                        > Sorry it took me so long to respond. I kept getting a black-and-white every time I called the function. Apparently calling :source on the vimrc didn't change all the options back (used :set before and after calling this function to see changes between non-default options), this included filetype=vim. I hardcoded this into the function, hopefully I can find a better fix later.
                        >
                        > I usually don't like long posts, so sorry about this one. Thanks again for all the suggestions and cool tips. If you think of anything to improve on this, please let me know. Every little bit helps. Thanks!
                        >
                        > --
                        > 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 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
                      • Juanmi
                        ... Hello, I edit a lot my vimrc I have this key map: nmap ev :e $MYVIMRC nmap sv :so $MYVIMRC so every time I need to reload
                        Message 11 of 12 , Dec 27, 2012
                        • 0 Attachment
                          El viernes, 21 de diciembre de 2012 06:52:27 UTC+1, stillLearningVim escribió:
                          > Is there a way to reload the vimrc (and other files), so that the changes in the vimrc take immediate effect. :e doesn't seem to do the trick.
                          >
                          > I'm editing my vimrc a lot, and I'm hoping there is an easier way than constantly closing and reopening everything.
                          >
                          > Any help and suggestions are appreciated
                          > Thanks

                          Hello, I edit a lot my vimrc I have this key map:
                          nmap <silent> <leader>ev :e $MYVIMRC
                          nmap <silent> <leader>sv :so $MYVIMRC
                          so every time I need to reload vimrc I push leader (my case ,) and sv and when I want to edit I push leader ev.
                          Kind Regards

                          --
                          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
                        • stillLearningVim
                          Using $MYVIMRC is definitely a smart move. I m not sure why the function has to be silent though. I m also not sure why the autocmd is nested. Don t we only
                          Message 12 of 12 , Dec 30, 2012
                          • 0 Attachment
                            Using $MYVIMRC is definitely a smart move. I'm not sure why the function has to be silent though. I'm also not sure why the autocmd is nested. Don't we only want it to call the function once?

                            The "!" after autocmd fixes the problem I was having though. Every time I :source vimrc, it re-added the autocmd, so when saved there were 2 autocmds doing the same thing, then 4, then 8, etc.

                            I love the key map to edit the vimrc, beautiful! The key map to sourcing the vimrc however leads to problems mentioned above, like when you remove a map or an autocmd. I think calling a function from a keymap is much more useful.

                            Also, I was wrong au! does not remove all autocommands, so using Gary's suggestion of putting them in groups I think is best (or using au! to define them). Also comclear is causing problems. Here's where I'm at within the function for the moment:
                            set all&
                            " comclear
                            abclear
                            mapclear
                            xmapclear
                            smapclear
                            mapclear!
                            lmapclear
                            so $MYVIMRC
                            set filetype=vim

                            Thanks

                            --
                            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
                          Your message has been successfully submitted and would be delivered to recipients shortly.