How to open copied file by VI

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











up vote
6
down vote

favorite












Say, I have 'a.txt'. I would like to copy the file and open the newly copied file using VI.



cp a.txt b.txt
vi b.txt


How to combine the two command in a command?










share|improve this question



















  • 13




    Hmm I’ve got to ask: why?!
    – Konrad Rudolph
    Aug 15 at 10:20










  • @Rudolph Because of the curiosity and laziness. In addition, I think someday, I can apply the method to the other problems.
    – comphys
    Aug 26 at 3:27















up vote
6
down vote

favorite












Say, I have 'a.txt'. I would like to copy the file and open the newly copied file using VI.



cp a.txt b.txt
vi b.txt


How to combine the two command in a command?










share|improve this question



















  • 13




    Hmm I’ve got to ask: why?!
    – Konrad Rudolph
    Aug 15 at 10:20










  • @Rudolph Because of the curiosity and laziness. In addition, I think someday, I can apply the method to the other problems.
    – comphys
    Aug 26 at 3:27













up vote
6
down vote

favorite









up vote
6
down vote

favorite











Say, I have 'a.txt'. I would like to copy the file and open the newly copied file using VI.



cp a.txt b.txt
vi b.txt


How to combine the two command in a command?










share|improve this question















Say, I have 'a.txt'. I would like to copy the file and open the newly copied file using VI.



cp a.txt b.txt
vi b.txt


How to combine the two command in a command?







bash






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 15 at 7:53









msp9011

3,46643862




3,46643862










asked Aug 15 at 7:49









comphys

8116




8116







  • 13




    Hmm I’ve got to ask: why?!
    – Konrad Rudolph
    Aug 15 at 10:20










  • @Rudolph Because of the curiosity and laziness. In addition, I think someday, I can apply the method to the other problems.
    – comphys
    Aug 26 at 3:27













  • 13




    Hmm I’ve got to ask: why?!
    – Konrad Rudolph
    Aug 15 at 10:20










  • @Rudolph Because of the curiosity and laziness. In addition, I think someday, I can apply the method to the other problems.
    – comphys
    Aug 26 at 3:27








13




13




Hmm I’ve got to ask: why?!
– Konrad Rudolph
Aug 15 at 10:20




Hmm I’ve got to ask: why?!
– Konrad Rudolph
Aug 15 at 10:20












@Rudolph Because of the curiosity and laziness. In addition, I think someday, I can apply the method to the other problems.
– comphys
Aug 26 at 3:27





@Rudolph Because of the curiosity and laziness. In addition, I think someday, I can apply the method to the other problems.
– comphys
Aug 26 at 3:27











4 Answers
4






active

oldest

votes

















up vote
14
down vote



accepted










You can use vi itself to do the copy, by opening a.txt then saving the contents to b.txt (effectively copying it) and then switching to b.txt.



Putting it all together:



vi -c 'w b.txt' -c 'e#' a.txt


This is equivalent to running vi a.txt, followed by the :w b.txt command (inside vi), which will save the contents to a file named b.txt. But vi will still be editing a.txt at this point, so you follow up with the :e# command, which means "edit alternative file" (or "edit last file") and given vi has just touched b.txt, it will switch to editing that file.






share|improve this answer




















  • Im not sure if vi has saveas (it may have come from vim) but it would shorten the command.
    – D. Ben Knoble
    Aug 15 at 12:57






  • 3




    The :f command may be useful - that will just change the filename, and the user can write it the normal way at the end of the editing session with :wq.
    – Random832
    Aug 15 at 21:03

















up vote
4
down vote













using && operator



cp a.txt b.txt && vi b.txt





share|improve this answer




















  • Thank you. Is there any other way where I can type b.txt only once?
    – comphys
    Aug 15 at 7:57










  • @comphys src=a.txt; dst=b.txt; cp "$src" "$dst" && vi "$dst"
    – Kirill Bulygin
    Aug 15 at 9:43






  • 5




    @comphys Yes we actually can: cp a.txt b.txt && vi $_. Grump reminded me of this in another comment thread.
    – Hielke Walinga
    Aug 15 at 12:44

















up vote
3
down vote













You can write your own function and use that function.
In the below example, you can use cp1 as a command.



example:



$ cat test.txt
function cp1()
source_file=$1
destination_file=$2
cp "$source_file" "$destination_file"
vi "$destination"


$ . ./test.txt
$ cp1 a.txt b.txt





share|improve this answer






















  • I would like to know an ad hoc method which can be written in one command line. Anyway, thank you for the helpful answer.
    – comphys
    Aug 15 at 8:47






  • 2




    @comphys If this is something you do frequently, why not define a function for it? If you don't do it enough to need a function, why does it even matter?
    – Barmar
    Aug 15 at 17:27










  • @Barmar I don't frequently encounter this kind of situation. However, I wanted to know the answer to apply it to the other similar situation and the curiosity makes me ask!
    – comphys
    Aug 26 at 3:08

















up vote
2
down vote













If you want a way to save you typing you can use bash build in functionality to repeat the last word of the previous command. You can do this by ALT+.



> cp a.txt b.txt
> vi ALT+.


Very useful, and reminds you of the dot operator of vim.



Happy golfing.






share|improve this answer
















  • 1




    Hmm this doesn’t seem to work for me. Is this a readline Emacs command (I’m working in vim mode)?
    – Konrad Rudolph
    Aug 15 at 10:22







  • 1




    !$ may be better than ALT+.
    – Grump
    Aug 15 at 12:30










  • @Grump That's indeed an interesting suggestion. I haven't thought of using that stuff. Actually $_ is more interesting, because it repeats the last executed command as opposed to the last command in history (that is what !$ does). But why would it be better. If we count keystrokes it is more and I also think the special symbols are a bit hard to reach.
    – Hielke Walinga
    Aug 15 at 12:40






  • 1




    @KonradRudolph Indeed, this is for the emacs readline mode. Vim mode has the same functionality, but since . already has a function underscore is used here. ALT + Underscore also works in emacs mode btw.
    – Hielke Walinga
    Aug 15 at 12:42






  • 2




    !$ is the last argument from the last command in history. I suggest it because it works in more shells and doesn't rely on keybindings
    – Grump
    Aug 15 at 12:43










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
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',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f462686%2fhow-to-open-copied-file-by-vi%23new-answer', 'question_page');

);

Post as a guest






























4 Answers
4






active

oldest

votes








4 Answers
4






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
14
down vote



accepted










You can use vi itself to do the copy, by opening a.txt then saving the contents to b.txt (effectively copying it) and then switching to b.txt.



Putting it all together:



vi -c 'w b.txt' -c 'e#' a.txt


This is equivalent to running vi a.txt, followed by the :w b.txt command (inside vi), which will save the contents to a file named b.txt. But vi will still be editing a.txt at this point, so you follow up with the :e# command, which means "edit alternative file" (or "edit last file") and given vi has just touched b.txt, it will switch to editing that file.






share|improve this answer




















  • Im not sure if vi has saveas (it may have come from vim) but it would shorten the command.
    – D. Ben Knoble
    Aug 15 at 12:57






  • 3




    The :f command may be useful - that will just change the filename, and the user can write it the normal way at the end of the editing session with :wq.
    – Random832
    Aug 15 at 21:03














up vote
14
down vote



accepted










You can use vi itself to do the copy, by opening a.txt then saving the contents to b.txt (effectively copying it) and then switching to b.txt.



Putting it all together:



vi -c 'w b.txt' -c 'e#' a.txt


This is equivalent to running vi a.txt, followed by the :w b.txt command (inside vi), which will save the contents to a file named b.txt. But vi will still be editing a.txt at this point, so you follow up with the :e# command, which means "edit alternative file" (or "edit last file") and given vi has just touched b.txt, it will switch to editing that file.






share|improve this answer




















  • Im not sure if vi has saveas (it may have come from vim) but it would shorten the command.
    – D. Ben Knoble
    Aug 15 at 12:57






  • 3




    The :f command may be useful - that will just change the filename, and the user can write it the normal way at the end of the editing session with :wq.
    – Random832
    Aug 15 at 21:03












up vote
14
down vote



accepted







up vote
14
down vote



accepted






You can use vi itself to do the copy, by opening a.txt then saving the contents to b.txt (effectively copying it) and then switching to b.txt.



Putting it all together:



vi -c 'w b.txt' -c 'e#' a.txt


This is equivalent to running vi a.txt, followed by the :w b.txt command (inside vi), which will save the contents to a file named b.txt. But vi will still be editing a.txt at this point, so you follow up with the :e# command, which means "edit alternative file" (or "edit last file") and given vi has just touched b.txt, it will switch to editing that file.






share|improve this answer












You can use vi itself to do the copy, by opening a.txt then saving the contents to b.txt (effectively copying it) and then switching to b.txt.



Putting it all together:



vi -c 'w b.txt' -c 'e#' a.txt


This is equivalent to running vi a.txt, followed by the :w b.txt command (inside vi), which will save the contents to a file named b.txt. But vi will still be editing a.txt at this point, so you follow up with the :e# command, which means "edit alternative file" (or "edit last file") and given vi has just touched b.txt, it will switch to editing that file.







share|improve this answer












share|improve this answer



share|improve this answer










answered Aug 15 at 8:01









Filipe Brandenburger

3,734622




3,734622











  • Im not sure if vi has saveas (it may have come from vim) but it would shorten the command.
    – D. Ben Knoble
    Aug 15 at 12:57






  • 3




    The :f command may be useful - that will just change the filename, and the user can write it the normal way at the end of the editing session with :wq.
    – Random832
    Aug 15 at 21:03
















  • Im not sure if vi has saveas (it may have come from vim) but it would shorten the command.
    – D. Ben Knoble
    Aug 15 at 12:57






  • 3




    The :f command may be useful - that will just change the filename, and the user can write it the normal way at the end of the editing session with :wq.
    – Random832
    Aug 15 at 21:03















Im not sure if vi has saveas (it may have come from vim) but it would shorten the command.
– D. Ben Knoble
Aug 15 at 12:57




Im not sure if vi has saveas (it may have come from vim) but it would shorten the command.
– D. Ben Knoble
Aug 15 at 12:57




3




3




The :f command may be useful - that will just change the filename, and the user can write it the normal way at the end of the editing session with :wq.
– Random832
Aug 15 at 21:03




The :f command may be useful - that will just change the filename, and the user can write it the normal way at the end of the editing session with :wq.
– Random832
Aug 15 at 21:03












up vote
4
down vote













using && operator



cp a.txt b.txt && vi b.txt





share|improve this answer




















  • Thank you. Is there any other way where I can type b.txt only once?
    – comphys
    Aug 15 at 7:57










  • @comphys src=a.txt; dst=b.txt; cp "$src" "$dst" && vi "$dst"
    – Kirill Bulygin
    Aug 15 at 9:43






  • 5




    @comphys Yes we actually can: cp a.txt b.txt && vi $_. Grump reminded me of this in another comment thread.
    – Hielke Walinga
    Aug 15 at 12:44














up vote
4
down vote













using && operator



cp a.txt b.txt && vi b.txt





share|improve this answer




















  • Thank you. Is there any other way where I can type b.txt only once?
    – comphys
    Aug 15 at 7:57










  • @comphys src=a.txt; dst=b.txt; cp "$src" "$dst" && vi "$dst"
    – Kirill Bulygin
    Aug 15 at 9:43






  • 5




    @comphys Yes we actually can: cp a.txt b.txt && vi $_. Grump reminded me of this in another comment thread.
    – Hielke Walinga
    Aug 15 at 12:44












up vote
4
down vote










up vote
4
down vote









using && operator



cp a.txt b.txt && vi b.txt





share|improve this answer












using && operator



cp a.txt b.txt && vi b.txt






share|improve this answer












share|improve this answer



share|improve this answer










answered Aug 15 at 7:52









msp9011

3,46643862




3,46643862











  • Thank you. Is there any other way where I can type b.txt only once?
    – comphys
    Aug 15 at 7:57










  • @comphys src=a.txt; dst=b.txt; cp "$src" "$dst" && vi "$dst"
    – Kirill Bulygin
    Aug 15 at 9:43






  • 5




    @comphys Yes we actually can: cp a.txt b.txt && vi $_. Grump reminded me of this in another comment thread.
    – Hielke Walinga
    Aug 15 at 12:44
















  • Thank you. Is there any other way where I can type b.txt only once?
    – comphys
    Aug 15 at 7:57










  • @comphys src=a.txt; dst=b.txt; cp "$src" "$dst" && vi "$dst"
    – Kirill Bulygin
    Aug 15 at 9:43






  • 5




    @comphys Yes we actually can: cp a.txt b.txt && vi $_. Grump reminded me of this in another comment thread.
    – Hielke Walinga
    Aug 15 at 12:44















Thank you. Is there any other way where I can type b.txt only once?
– comphys
Aug 15 at 7:57




Thank you. Is there any other way where I can type b.txt only once?
– comphys
Aug 15 at 7:57












@comphys src=a.txt; dst=b.txt; cp "$src" "$dst" && vi "$dst"
– Kirill Bulygin
Aug 15 at 9:43




@comphys src=a.txt; dst=b.txt; cp "$src" "$dst" && vi "$dst"
– Kirill Bulygin
Aug 15 at 9:43




5




5




@comphys Yes we actually can: cp a.txt b.txt && vi $_. Grump reminded me of this in another comment thread.
– Hielke Walinga
Aug 15 at 12:44




@comphys Yes we actually can: cp a.txt b.txt && vi $_. Grump reminded me of this in another comment thread.
– Hielke Walinga
Aug 15 at 12:44










up vote
3
down vote













You can write your own function and use that function.
In the below example, you can use cp1 as a command.



example:



$ cat test.txt
function cp1()
source_file=$1
destination_file=$2
cp "$source_file" "$destination_file"
vi "$destination"


$ . ./test.txt
$ cp1 a.txt b.txt





share|improve this answer






















  • I would like to know an ad hoc method which can be written in one command line. Anyway, thank you for the helpful answer.
    – comphys
    Aug 15 at 8:47






  • 2




    @comphys If this is something you do frequently, why not define a function for it? If you don't do it enough to need a function, why does it even matter?
    – Barmar
    Aug 15 at 17:27










  • @Barmar I don't frequently encounter this kind of situation. However, I wanted to know the answer to apply it to the other similar situation and the curiosity makes me ask!
    – comphys
    Aug 26 at 3:08














up vote
3
down vote













You can write your own function and use that function.
In the below example, you can use cp1 as a command.



example:



$ cat test.txt
function cp1()
source_file=$1
destination_file=$2
cp "$source_file" "$destination_file"
vi "$destination"


$ . ./test.txt
$ cp1 a.txt b.txt





share|improve this answer






















  • I would like to know an ad hoc method which can be written in one command line. Anyway, thank you for the helpful answer.
    – comphys
    Aug 15 at 8:47






  • 2




    @comphys If this is something you do frequently, why not define a function for it? If you don't do it enough to need a function, why does it even matter?
    – Barmar
    Aug 15 at 17:27










  • @Barmar I don't frequently encounter this kind of situation. However, I wanted to know the answer to apply it to the other similar situation and the curiosity makes me ask!
    – comphys
    Aug 26 at 3:08












up vote
3
down vote










up vote
3
down vote









You can write your own function and use that function.
In the below example, you can use cp1 as a command.



example:



$ cat test.txt
function cp1()
source_file=$1
destination_file=$2
cp "$source_file" "$destination_file"
vi "$destination"


$ . ./test.txt
$ cp1 a.txt b.txt





share|improve this answer














You can write your own function and use that function.
In the below example, you can use cp1 as a command.



example:



$ cat test.txt
function cp1()
source_file=$1
destination_file=$2
cp "$source_file" "$destination_file"
vi "$destination"


$ . ./test.txt
$ cp1 a.txt b.txt






share|improve this answer














share|improve this answer



share|improve this answer








edited Aug 15 at 19:03









Jens

1,0221128




1,0221128










answered Aug 15 at 8:15









Kamaraj

2,9231413




2,9231413











  • I would like to know an ad hoc method which can be written in one command line. Anyway, thank you for the helpful answer.
    – comphys
    Aug 15 at 8:47






  • 2




    @comphys If this is something you do frequently, why not define a function for it? If you don't do it enough to need a function, why does it even matter?
    – Barmar
    Aug 15 at 17:27










  • @Barmar I don't frequently encounter this kind of situation. However, I wanted to know the answer to apply it to the other similar situation and the curiosity makes me ask!
    – comphys
    Aug 26 at 3:08
















  • I would like to know an ad hoc method which can be written in one command line. Anyway, thank you for the helpful answer.
    – comphys
    Aug 15 at 8:47






  • 2




    @comphys If this is something you do frequently, why not define a function for it? If you don't do it enough to need a function, why does it even matter?
    – Barmar
    Aug 15 at 17:27










  • @Barmar I don't frequently encounter this kind of situation. However, I wanted to know the answer to apply it to the other similar situation and the curiosity makes me ask!
    – comphys
    Aug 26 at 3:08















I would like to know an ad hoc method which can be written in one command line. Anyway, thank you for the helpful answer.
– comphys
Aug 15 at 8:47




I would like to know an ad hoc method which can be written in one command line. Anyway, thank you for the helpful answer.
– comphys
Aug 15 at 8:47




2




2




@comphys If this is something you do frequently, why not define a function for it? If you don't do it enough to need a function, why does it even matter?
– Barmar
Aug 15 at 17:27




@comphys If this is something you do frequently, why not define a function for it? If you don't do it enough to need a function, why does it even matter?
– Barmar
Aug 15 at 17:27












@Barmar I don't frequently encounter this kind of situation. However, I wanted to know the answer to apply it to the other similar situation and the curiosity makes me ask!
– comphys
Aug 26 at 3:08




@Barmar I don't frequently encounter this kind of situation. However, I wanted to know the answer to apply it to the other similar situation and the curiosity makes me ask!
– comphys
Aug 26 at 3:08










up vote
2
down vote













If you want a way to save you typing you can use bash build in functionality to repeat the last word of the previous command. You can do this by ALT+.



> cp a.txt b.txt
> vi ALT+.


Very useful, and reminds you of the dot operator of vim.



Happy golfing.






share|improve this answer
















  • 1




    Hmm this doesn’t seem to work for me. Is this a readline Emacs command (I’m working in vim mode)?
    – Konrad Rudolph
    Aug 15 at 10:22







  • 1




    !$ may be better than ALT+.
    – Grump
    Aug 15 at 12:30










  • @Grump That's indeed an interesting suggestion. I haven't thought of using that stuff. Actually $_ is more interesting, because it repeats the last executed command as opposed to the last command in history (that is what !$ does). But why would it be better. If we count keystrokes it is more and I also think the special symbols are a bit hard to reach.
    – Hielke Walinga
    Aug 15 at 12:40






  • 1




    @KonradRudolph Indeed, this is for the emacs readline mode. Vim mode has the same functionality, but since . already has a function underscore is used here. ALT + Underscore also works in emacs mode btw.
    – Hielke Walinga
    Aug 15 at 12:42






  • 2




    !$ is the last argument from the last command in history. I suggest it because it works in more shells and doesn't rely on keybindings
    – Grump
    Aug 15 at 12:43














up vote
2
down vote













If you want a way to save you typing you can use bash build in functionality to repeat the last word of the previous command. You can do this by ALT+.



> cp a.txt b.txt
> vi ALT+.


Very useful, and reminds you of the dot operator of vim.



Happy golfing.






share|improve this answer
















  • 1




    Hmm this doesn’t seem to work for me. Is this a readline Emacs command (I’m working in vim mode)?
    – Konrad Rudolph
    Aug 15 at 10:22







  • 1




    !$ may be better than ALT+.
    – Grump
    Aug 15 at 12:30










  • @Grump That's indeed an interesting suggestion. I haven't thought of using that stuff. Actually $_ is more interesting, because it repeats the last executed command as opposed to the last command in history (that is what !$ does). But why would it be better. If we count keystrokes it is more and I also think the special symbols are a bit hard to reach.
    – Hielke Walinga
    Aug 15 at 12:40






  • 1




    @KonradRudolph Indeed, this is for the emacs readline mode. Vim mode has the same functionality, but since . already has a function underscore is used here. ALT + Underscore also works in emacs mode btw.
    – Hielke Walinga
    Aug 15 at 12:42






  • 2




    !$ is the last argument from the last command in history. I suggest it because it works in more shells and doesn't rely on keybindings
    – Grump
    Aug 15 at 12:43












up vote
2
down vote










up vote
2
down vote









If you want a way to save you typing you can use bash build in functionality to repeat the last word of the previous command. You can do this by ALT+.



> cp a.txt b.txt
> vi ALT+.


Very useful, and reminds you of the dot operator of vim.



Happy golfing.






share|improve this answer












If you want a way to save you typing you can use bash build in functionality to repeat the last word of the previous command. You can do this by ALT+.



> cp a.txt b.txt
> vi ALT+.


Very useful, and reminds you of the dot operator of vim.



Happy golfing.







share|improve this answer












share|improve this answer



share|improve this answer










answered Aug 15 at 8:24









Hielke Walinga

1664




1664







  • 1




    Hmm this doesn’t seem to work for me. Is this a readline Emacs command (I’m working in vim mode)?
    – Konrad Rudolph
    Aug 15 at 10:22







  • 1




    !$ may be better than ALT+.
    – Grump
    Aug 15 at 12:30










  • @Grump That's indeed an interesting suggestion. I haven't thought of using that stuff. Actually $_ is more interesting, because it repeats the last executed command as opposed to the last command in history (that is what !$ does). But why would it be better. If we count keystrokes it is more and I also think the special symbols are a bit hard to reach.
    – Hielke Walinga
    Aug 15 at 12:40






  • 1




    @KonradRudolph Indeed, this is for the emacs readline mode. Vim mode has the same functionality, but since . already has a function underscore is used here. ALT + Underscore also works in emacs mode btw.
    – Hielke Walinga
    Aug 15 at 12:42






  • 2




    !$ is the last argument from the last command in history. I suggest it because it works in more shells and doesn't rely on keybindings
    – Grump
    Aug 15 at 12:43












  • 1




    Hmm this doesn’t seem to work for me. Is this a readline Emacs command (I’m working in vim mode)?
    – Konrad Rudolph
    Aug 15 at 10:22







  • 1




    !$ may be better than ALT+.
    – Grump
    Aug 15 at 12:30










  • @Grump That's indeed an interesting suggestion. I haven't thought of using that stuff. Actually $_ is more interesting, because it repeats the last executed command as opposed to the last command in history (that is what !$ does). But why would it be better. If we count keystrokes it is more and I also think the special symbols are a bit hard to reach.
    – Hielke Walinga
    Aug 15 at 12:40






  • 1




    @KonradRudolph Indeed, this is for the emacs readline mode. Vim mode has the same functionality, but since . already has a function underscore is used here. ALT + Underscore also works in emacs mode btw.
    – Hielke Walinga
    Aug 15 at 12:42






  • 2




    !$ is the last argument from the last command in history. I suggest it because it works in more shells and doesn't rely on keybindings
    – Grump
    Aug 15 at 12:43







1




1




Hmm this doesn’t seem to work for me. Is this a readline Emacs command (I’m working in vim mode)?
– Konrad Rudolph
Aug 15 at 10:22





Hmm this doesn’t seem to work for me. Is this a readline Emacs command (I’m working in vim mode)?
– Konrad Rudolph
Aug 15 at 10:22





1




1




!$ may be better than ALT+.
– Grump
Aug 15 at 12:30




!$ may be better than ALT+.
– Grump
Aug 15 at 12:30












@Grump That's indeed an interesting suggestion. I haven't thought of using that stuff. Actually $_ is more interesting, because it repeats the last executed command as opposed to the last command in history (that is what !$ does). But why would it be better. If we count keystrokes it is more and I also think the special symbols are a bit hard to reach.
– Hielke Walinga
Aug 15 at 12:40




@Grump That's indeed an interesting suggestion. I haven't thought of using that stuff. Actually $_ is more interesting, because it repeats the last executed command as opposed to the last command in history (that is what !$ does). But why would it be better. If we count keystrokes it is more and I also think the special symbols are a bit hard to reach.
– Hielke Walinga
Aug 15 at 12:40




1




1




@KonradRudolph Indeed, this is for the emacs readline mode. Vim mode has the same functionality, but since . already has a function underscore is used here. ALT + Underscore also works in emacs mode btw.
– Hielke Walinga
Aug 15 at 12:42




@KonradRudolph Indeed, this is for the emacs readline mode. Vim mode has the same functionality, but since . already has a function underscore is used here. ALT + Underscore also works in emacs mode btw.
– Hielke Walinga
Aug 15 at 12:42




2




2




!$ is the last argument from the last command in history. I suggest it because it works in more shells and doesn't rely on keybindings
– Grump
Aug 15 at 12:43




!$ is the last argument from the last command in history. I suggest it because it works in more shells and doesn't rely on keybindings
– Grump
Aug 15 at 12:43

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f462686%2fhow-to-open-copied-file-by-vi%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

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

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?