Open new file while keeping the focus on the the current buffer

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












4















It is possible to open a new file with :edit or :tabnew but without jumping to that new buffer ?










share|improve this question






















  • no, but you can make a custom command, that will jump back from after opening a new window/tabpage

    – Christian Brabandt
    Mar 17 at 16:41















4















It is possible to open a new file with :edit or :tabnew but without jumping to that new buffer ?










share|improve this question






















  • no, but you can make a custom command, that will jump back from after opening a new window/tabpage

    – Christian Brabandt
    Mar 17 at 16:41













4












4








4








It is possible to open a new file with :edit or :tabnew but without jumping to that new buffer ?










share|improve this question














It is possible to open a new file with :edit or :tabnew but without jumping to that new buffer ?







buffers






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 17 at 16:01









Kevin LópezKevin López

232




232












  • no, but you can make a custom command, that will jump back from after opening a new window/tabpage

    – Christian Brabandt
    Mar 17 at 16:41

















  • no, but you can make a custom command, that will jump back from after opening a new window/tabpage

    – Christian Brabandt
    Mar 17 at 16:41
















no, but you can make a custom command, that will jump back from after opening a new window/tabpage

– Christian Brabandt
Mar 17 at 16:41





no, but you can make a custom command, that will jump back from after opening a new window/tabpage

– Christian Brabandt
Mar 17 at 16:41










2 Answers
2






active

oldest

votes


















2














Perhaps :badd fname is what you are looking for. It just adds a new buffer to the buffer list without switching to it.



See :help badd.



I don't think there is something similar for tabs.






share|improve this answer

























  • Wow, I didn't know about this! Way better than the custom command solution! Nice.

    – f41lurizer
    Mar 17 at 18:43


















0














I'm not aware of a command to do this. Not to worry though - you can define your own commands to do it!



For edit, you might want to use something like this to open the file then immediately switch to the previous buffer.



command -nargs=1 Bgedit edit <args> | bprevious



Which you can call with :Bgedit filename.



Explanation:



command - Create a new user-defined command



-nargs=1 - With one argument (the filename)



Bgedit - Name of the command (user-defined commands have to start with capital letters).



What comes next is what you will run when :Bgedit gets called:



edit <args> - open the file



| - Used in vim to chain two commands together, like a semicolon in bash



bprevious - switch to the previous buffer.



For tabnew, you can do the same thing, but using tabprevious



command -nargs=1 Tabbgedit tabnew <args> | tabprevious



You would put these two lines in your .vimrc.






share|improve this answer























  • For windows, you could do (v)split | wincmd p

    – D. Ben Knoble
    Mar 17 at 22:16











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "599"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fvi.stackexchange.com%2fquestions%2f19222%2fopen-new-file-while-keeping-the-focus-on-the-the-current-buffer%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














Perhaps :badd fname is what you are looking for. It just adds a new buffer to the buffer list without switching to it.



See :help badd.



I don't think there is something similar for tabs.






share|improve this answer

























  • Wow, I didn't know about this! Way better than the custom command solution! Nice.

    – f41lurizer
    Mar 17 at 18:43















2














Perhaps :badd fname is what you are looking for. It just adds a new buffer to the buffer list without switching to it.



See :help badd.



I don't think there is something similar for tabs.






share|improve this answer

























  • Wow, I didn't know about this! Way better than the custom command solution! Nice.

    – f41lurizer
    Mar 17 at 18:43













2












2








2







Perhaps :badd fname is what you are looking for. It just adds a new buffer to the buffer list without switching to it.



See :help badd.



I don't think there is something similar for tabs.






share|improve this answer















Perhaps :badd fname is what you are looking for. It just adds a new buffer to the buffer list without switching to it.



See :help badd.



I don't think there is something similar for tabs.







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 17 at 20:02

























answered Mar 17 at 17:20









RalfRalf

3,4951317




3,4951317












  • Wow, I didn't know about this! Way better than the custom command solution! Nice.

    – f41lurizer
    Mar 17 at 18:43

















  • Wow, I didn't know about this! Way better than the custom command solution! Nice.

    – f41lurizer
    Mar 17 at 18:43
















Wow, I didn't know about this! Way better than the custom command solution! Nice.

– f41lurizer
Mar 17 at 18:43





Wow, I didn't know about this! Way better than the custom command solution! Nice.

– f41lurizer
Mar 17 at 18:43











0














I'm not aware of a command to do this. Not to worry though - you can define your own commands to do it!



For edit, you might want to use something like this to open the file then immediately switch to the previous buffer.



command -nargs=1 Bgedit edit <args> | bprevious



Which you can call with :Bgedit filename.



Explanation:



command - Create a new user-defined command



-nargs=1 - With one argument (the filename)



Bgedit - Name of the command (user-defined commands have to start with capital letters).



What comes next is what you will run when :Bgedit gets called:



edit <args> - open the file



| - Used in vim to chain two commands together, like a semicolon in bash



bprevious - switch to the previous buffer.



For tabnew, you can do the same thing, but using tabprevious



command -nargs=1 Tabbgedit tabnew <args> | tabprevious



You would put these two lines in your .vimrc.






share|improve this answer























  • For windows, you could do (v)split | wincmd p

    – D. Ben Knoble
    Mar 17 at 22:16















0














I'm not aware of a command to do this. Not to worry though - you can define your own commands to do it!



For edit, you might want to use something like this to open the file then immediately switch to the previous buffer.



command -nargs=1 Bgedit edit <args> | bprevious



Which you can call with :Bgedit filename.



Explanation:



command - Create a new user-defined command



-nargs=1 - With one argument (the filename)



Bgedit - Name of the command (user-defined commands have to start with capital letters).



What comes next is what you will run when :Bgedit gets called:



edit <args> - open the file



| - Used in vim to chain two commands together, like a semicolon in bash



bprevious - switch to the previous buffer.



For tabnew, you can do the same thing, but using tabprevious



command -nargs=1 Tabbgedit tabnew <args> | tabprevious



You would put these two lines in your .vimrc.






share|improve this answer























  • For windows, you could do (v)split | wincmd p

    – D. Ben Knoble
    Mar 17 at 22:16













0












0








0







I'm not aware of a command to do this. Not to worry though - you can define your own commands to do it!



For edit, you might want to use something like this to open the file then immediately switch to the previous buffer.



command -nargs=1 Bgedit edit <args> | bprevious



Which you can call with :Bgedit filename.



Explanation:



command - Create a new user-defined command



-nargs=1 - With one argument (the filename)



Bgedit - Name of the command (user-defined commands have to start with capital letters).



What comes next is what you will run when :Bgedit gets called:



edit <args> - open the file



| - Used in vim to chain two commands together, like a semicolon in bash



bprevious - switch to the previous buffer.



For tabnew, you can do the same thing, but using tabprevious



command -nargs=1 Tabbgedit tabnew <args> | tabprevious



You would put these two lines in your .vimrc.






share|improve this answer













I'm not aware of a command to do this. Not to worry though - you can define your own commands to do it!



For edit, you might want to use something like this to open the file then immediately switch to the previous buffer.



command -nargs=1 Bgedit edit <args> | bprevious



Which you can call with :Bgedit filename.



Explanation:



command - Create a new user-defined command



-nargs=1 - With one argument (the filename)



Bgedit - Name of the command (user-defined commands have to start with capital letters).



What comes next is what you will run when :Bgedit gets called:



edit <args> - open the file



| - Used in vim to chain two commands together, like a semicolon in bash



bprevious - switch to the previous buffer.



For tabnew, you can do the same thing, but using tabprevious



command -nargs=1 Tabbgedit tabnew <args> | tabprevious



You would put these two lines in your .vimrc.







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 17 at 16:58









f41lurizerf41lurizer

56247




56247












  • For windows, you could do (v)split | wincmd p

    – D. Ben Knoble
    Mar 17 at 22:16

















  • For windows, you could do (v)split | wincmd p

    – D. Ben Knoble
    Mar 17 at 22:16
















For windows, you could do (v)split | wincmd p

– D. Ben Knoble
Mar 17 at 22:16





For windows, you could do (v)split | wincmd p

– D. Ben Knoble
Mar 17 at 22:16

















draft saved

draft discarded
















































Thanks for contributing an answer to Vi and Vim Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fvi.stackexchange.com%2fquestions%2f19222%2fopen-new-file-while-keeping-the-focus-on-the-the-current-buffer%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown






Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay