2

I've started using Vim recently, and so far my main issue is with the buffer. I miss my Mac OS-style drawer with all open docs. I recently learned about tabs, and I think that's somewhat of a good solution, at least for when I have only a few files open. Opening a new tab is :tabe <filename>. Is there a way to remap that to :te <filename>?

eykanal
  • 26,437
  • 19
  • 82
  • 113
  • 2
    This is a possible duplicate of: http://stackoverflow.com/questions/7513380/vim-change-x-function-to-delete-buffer-instead-of-save-quit – Peter Rincker Sep 23 '11 at 16:08
  • Looks like you're right, the trick is a plugin called [cmdalias.vim](http://www.vim.org/scripts/script.php?script_id=746). Thanks for pointing that question out. – eykanal Sep 23 '11 at 16:36
  • By using the Buffergator plugin (http://www.vim.org/scripts/script.php?script_id=3619), and with "let g:buffergator_autodismiss_on_select=0" in your `~/.vimrc`, you should be able to get the always-open drawer behavior. – Jeet Sep 24 '11 at 07:03

1 Answers1

1

The first thing that came to my mind was a custom command.

command! -complete=file -nargs=1 Te tabedit <args>

Use the command: :Te <filename>

Please see the comments by Peter Rincker in this post.

John Kaul
  • 340
  • 1
  • 5
  • You want to be very careful with `cmap` such as these, they will "expand" in many more cases than you expect. e.g. `:update`, `:write`, `:execute`, `: substitute `, `:delete`, `:regeisters`, etc. Not to mention this will also expand when you do a search. e.g. `/update`. – Peter Rincker Sep 23 '11 at 19:01
  • Whoa! That's no good at all! Thank you for the heads up. *I removed ":cmap" portion of my answer above.* – John Kaul Sep 23 '11 at 19:42
  • 3
    your welcome. You may also want to simplify your command. `command! -complete=file -nargs=1 Te tabedit ` You do not need the function at all. You may also want to look at http://stackoverflow.com/questions/7513380/vim-change-x-function-to-delete-buffer-instead-of-save-quit/7515418#7515418 – Peter Rincker Sep 23 '11 at 19:47
  • Done. That link is the jackpot! Thank you again. – John Kaul Sep 23 '11 at 19:58