sponsor Vim development Vim logo Vim Book Ad

intermediate Tip #674: One-liner Replacement for ':sb(uffer) | e(dit) somefile'

 tip karma   Rating 1/6, Viewed by 846 

Read and edit this tip on the Vim tip wiki. The wiki may have a more recent version of this tip.

created:   March 9, 2004 12:44      complexity:   intermediate
author:   C² (cciulla)      as of Vim:   5.7

I prefer to use buffers and split windows [unlike a coworker who shall remain nameless (Bob) who insists on having many, many gvim instances open ;) ].

While rather tedious and error-prone, I was satisfied with the built-in method of splitting the buffer and editing a file... Until today, that is.

Critical mass was achieved after I fat-fingered ':sb | e somefile' four times in a row, leading to these, my first user commands:

"Put this in your .vimrc
command! -nargs=1 -complete=file Sedit sbuffer | edit <args>
command! -nargs=1 -complete=file Vedit vsplit | edit <args>

---------------
Help References
---------------
"User Commands
:help user-commands

"Argument Handling
:help E175

"Command Completion
:help command-completion

Enjoy!

 rate this tip  Life Changing Helpful Unfulfilling 

<< dealing with typing ":wq" in insert-mode | How to turn off all colors >>

Additional Notes

Anonymous, March 10, 2004 6:18
> Critical mass was achieved after I fat-fingered ':sb | e somefile' four times in a row, leading to these, my first user commands:
I thing you could use ':sp somefile'

ah.
Anonymous, March 10, 2004 7:49
How is this different from ":new somefile"?
C² (cciulla), March 10, 2004 8:05
':sp somefile' does indeed work, and I am feeling rather sheepish indeed.

Mea culpa!

---------------
Help References
---------------
:h split_f
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Sponsored by Web Concept Group Inc. SourceForge.net Logo