Open new file while keeping the focus on the the current buffer
Clash Royale CLAN TAG#URR8PPP
It is possible to open a new file with :edit or :tabnew but without jumping to that new buffer ?
buffers
add a comment |
It is possible to open a new file with :edit or :tabnew but without jumping to that new buffer ?
buffers
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
add a comment |
It is possible to open a new file with :edit or :tabnew but without jumping to that new buffer ?
buffers
It is possible to open a new file with :edit or :tabnew but without jumping to that new buffer ?
buffers
buffers
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
add a comment |
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
add a comment |
2 Answers
2
active
oldest
votes
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.
Wow, I didn't know about this! Way better than the custom command solution! Nice.
– f41lurizer
Mar 17 at 18:43
add a comment |
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.
For windows, you could do(v)split | wincmd p
– D. Ben Knoble
Mar 17 at 22:16
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
Wow, I didn't know about this! Way better than the custom command solution! Nice.
– f41lurizer
Mar 17 at 18:43
add a comment |
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.
Wow, I didn't know about this! Way better than the custom command solution! Nice.
– f41lurizer
Mar 17 at 18:43
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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.
For windows, you could do(v)split | wincmd p
– D. Ben Knoble
Mar 17 at 22:16
add a comment |
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.
For windows, you could do(v)split | wincmd p
– D. Ben Knoble
Mar 17 at 22:16
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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