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

Re: Opening files in new buffers

Expand Messages
  • Ven Tadipatri
    ... Actually I found out one neat trick - :sp splits a new window (or new buffer? Are the two names interchangeable), but keeps the cursor on the same file, so
    Message 1 of 5 , Dec 1, 2010
    • 0 Attachment
      On Wed, Dec 1, 2010 at 4:51 PM, Ven Tadipatri <vtadipatri@...> wrote:
      > I like the way vim allows you to view the files in a directory, then
      > directly go to them. But then to go back after editing the file I
      > chose, I repeatedly hit ctrl-O until I get back to the file listing.
      > It would be nice if I can maybe open the file in a new buffer, and
      > when I'm done, just close the new buffer I opened. Is there an easy
      > way to do this? Ctrl+w, followed by enter didn't seem to work, and
      > neither did gF.

      Actually I found out one neat trick - :sp splits a new window (or new
      buffer? Are the two names interchangeable), but keeps the cursor on
      the same file, so I just hit enter again to open the file.
      There's tabbed browsing in vim as well right? Sometimes I notice links
      being opened in horizontal tabs. What's the difference between these
      tabs and the buffers that are opened? In other words, what are the
      advantages/disadvantages of using tabs versus buffers?

      >  Also, on a somewhat related note, is there a way to quickly save a
      > buffer and then close it. :wq allows you to save and quit, but I'm a
      > bit annoyed by having to do :w<enter>, :bd<enter>.
      >   I think vim has started to make me lazy to type, where I'm always
      > looking for 1 or 2 letter commands to do everything.
      >
      > -Ven
      >

      --
      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
    • Tim Chase
      ... It sounds like you want o (lowercase-oh), used to open the file under the cursor in a new window. ... Though I agree that your Ctrl+W and gF are
      Message 2 of 5 , Dec 1, 2010
      • 0 Attachment
        On 12/01/2010 03:51 PM, Ven Tadipatri wrote:
        > I like the way vim allows you to view the files in a directory, then
        > directly go to them. But then to go back after editing the file I
        > chose, I repeatedly hit ctrl-O until I get back to the file listing.
        > It would be nice if I can maybe open the file in a new buffer, and
        > when I'm done, just close the new buffer I opened. Is there an easy
        > way to do this? Ctrl+w, followed by enter didn't seem to work, and
        > neither did gF.

        It sounds like you want "o" (lowercase-oh), used to open the file
        under the cursor in a new window.

        :help netrw-o

        Though I agree that your Ctrl+W and gF are reasonable
        expectations...I myself used them diminishingly for the 2-3
        months it took me to finally wire my brain to use "o". :)

        > Also, on a somewhat related note, is there a way to quickly save a
        > buffer and then close it. :wq allows you to save and quit, but I'm a
        > bit annoyed by having to do :w<enter>, :bd<enter>.

        I don't know of any built-in single-command to do it. However,
        you can either map a command to do it:

        :nnoremap <f4> :w<cr>:bd<cr>

        or you can fiddle with the 'bufhidden' option:

        :set bufhidden=delete

        and then just use ":wq" as normal.

        -tim



        --
        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
      • Charles E Campbell Jr
        ... Try ... If you use a mouse, then also look at :he netrw-mouse ; you can ge a double-leftmouse click to return you to the netrw window. Regards, Chip
        Message 3 of 5 , Dec 1, 2010
        • 0 Attachment
          Ven Tadipatri wrote:
          > I like the way vim allows you to view the files in a directory, then
          > directly go to them. But then to go back after editing the file I
          > chose, I repeatedly hit ctrl-O until I get back to the file listing.
          > It would be nice if I can maybe open the file in a new buffer, and
          > when I'm done, just close the new buffer I opened. Is there an easy
          > way to do this? Ctrl+w, followed by enter didn't seem to work, and
          > neither did gF.
          > Also, on a somewhat related note, is there a way to quickly save a
          > buffer and then close it. :wq allows you to save and quit, but I'm a
          > bit annoyed by having to do :w<enter>, :bd<enter>.
          > I think vim has started to make me lazy to type, where I'm always
          > looking for 1 or 2 letter commands to do everything.
          >
          Try

          :Rex

          If you use a mouse, then also look at :he netrw-mouse ; you can ge a
          double-leftmouse click to return you to the netrw window.

          Regards,
          Chip Campbell

          --
          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
        • Chris Jones
          On Wed, Dec 01, 2010 at 05:07:19PM EST, Ven Tadipatri wrote: [..] ... More like tabbed editing. ;-) ... Chasing the web browser analogy, Vim s windows and tab
          Message 4 of 5 , Dec 2, 2010
          • 0 Attachment
            On Wed, Dec 01, 2010 at 05:07:19PM EST, Ven Tadipatri wrote:

            [..]

            > There's tabbed browsing in vim as well right?

            More like tabbed editing. ;-)

            > Sometimes I notice links being opened in horizontal tabs. What's the
            > difference between these tabs and the buffers that are opened? In
            > other words, what are the advantages/disadvantages of using tabs
            > versus buffers?

            This may help clarify buffers vs. windows & tabs:

            :help buffers
            :help window
            :help tabpage

            Chasing the web browser analogy, Vim's windows and tab pages loosely
            correspond to a tabbed browser's tabs, while Vim's buffers are a bit
            like the browser's cache.

            Do you mean (dis)advantages of using ‘windows’ vs. using ‘tab pages’?

            This Vim tip provides many interesting suggestions of things you can do
            to put Vim's ‘tab pages’ to good use:

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

            If you enter ‘tabs’ in the wiki's search box you will get a list of all
            the currently available tips relative to ‘tabs pages’:

            http://vim.wikia.com/wiki/Category:Tabs

            HTH

            cj

            --
            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.