Visual feedback after executing mapping
I have the following mapping in my ~/.vimrc
file:
map <F3> my0v$"+y`y
It works correctly, but I'd like some visual feedback or some other indication to show that I've pressed the key. Any suggestions?
key-bindings
add a comment |
I have the following mapping in my ~/.vimrc
file:
map <F3> my0v$"+y`y
It works correctly, but I'd like some visual feedback or some other indication to show that I've pressed the key. Any suggestions?
key-bindings
1
No answer, but isn't that the same asmap <F3> "+yy
?
– Ralf
5 hours ago
This will copy the line character-wise instead of linewise. However, it will also copy the newline so it feels more linewise. I agree that it would probably be easier to just doyy
/Y
or:yank
and just accept to do a little cleanup on paste/put.
– Peter Rincker
4 hours ago
add a comment |
I have the following mapping in my ~/.vimrc
file:
map <F3> my0v$"+y`y
It works correctly, but I'd like some visual feedback or some other indication to show that I've pressed the key. Any suggestions?
key-bindings
I have the following mapping in my ~/.vimrc
file:
map <F3> my0v$"+y`y
It works correctly, but I'd like some visual feedback or some other indication to show that I've pressed the key. Any suggestions?
key-bindings
key-bindings
asked 5 hours ago
SabreWolfySabreWolfy
344313
344313
1
No answer, but isn't that the same asmap <F3> "+yy
?
– Ralf
5 hours ago
This will copy the line character-wise instead of linewise. However, it will also copy the newline so it feels more linewise. I agree that it would probably be easier to just doyy
/Y
or:yank
and just accept to do a little cleanup on paste/put.
– Peter Rincker
4 hours ago
add a comment |
1
No answer, but isn't that the same asmap <F3> "+yy
?
– Ralf
5 hours ago
This will copy the line character-wise instead of linewise. However, it will also copy the newline so it feels more linewise. I agree that it would probably be easier to just doyy
/Y
or:yank
and just accept to do a little cleanup on paste/put.
– Peter Rincker
4 hours ago
1
1
No answer, but isn't that the same as
map <F3> "+yy
?– Ralf
5 hours ago
No answer, but isn't that the same as
map <F3> "+yy
?– Ralf
5 hours ago
This will copy the line character-wise instead of linewise. However, it will also copy the newline so it feels more linewise. I agree that it would probably be easier to just do
yy
/Y
or :yank
and just accept to do a little cleanup on paste/put.– Peter Rincker
4 hours ago
This will copy the line character-wise instead of linewise. However, it will also copy the newline so it feels more linewise. I agree that it would probably be easier to just do
yy
/Y
or :yank
and just accept to do a little cleanup on paste/put.– Peter Rincker
4 hours ago
add a comment |
1 Answer
1
active
oldest
votes
You have options:
- Explicitly put an
:echo
at the end of your mapping.map <key> foo:echo "done"<cr>
- Use
'showcmd'
which will show partial commands. This will give you a slight clue that something happened for multi-key mappings/commands. (Not really helpful here) - Use a plugin like vim-highlightedyank to quickly highlight the last yank
General rule of thumbs for mappings:
- Supply a mode for mappings. e.g.
nmap
for normal mode - Use
*noremap
variants unless you want remapping to occur or using a<Plug>
mapping
This means you mapping would look like:
nnoremap <F3> my0v$"+y`y
Some more thoughts:
- This is very similar to
"+yy
/"+Y
,:yank +
, orV"+y
. There is another newline in the register, but it is easy to reason about. - You may not want the ending newline at all, so use
g_
instead of$
. - This mutates the
y
mark. This could be surprising, consider using a:yank
oryy
/Y
- Could "cast" put/paste or change the register type to accomplish the same effect. e.g.
nnoremap <f3> "+yy:call setreg('+', @+, 'v')<cr>
Personally, I lean toward using vim-highlightyank and the following mapping:
nnoremap <silent> <f3> "+yy:call setreg('+', @+, 'v')<cr>
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%2f18565%2fvisual-feedback-after-executing-mapping%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You have options:
- Explicitly put an
:echo
at the end of your mapping.map <key> foo:echo "done"<cr>
- Use
'showcmd'
which will show partial commands. This will give you a slight clue that something happened for multi-key mappings/commands. (Not really helpful here) - Use a plugin like vim-highlightedyank to quickly highlight the last yank
General rule of thumbs for mappings:
- Supply a mode for mappings. e.g.
nmap
for normal mode - Use
*noremap
variants unless you want remapping to occur or using a<Plug>
mapping
This means you mapping would look like:
nnoremap <F3> my0v$"+y`y
Some more thoughts:
- This is very similar to
"+yy
/"+Y
,:yank +
, orV"+y
. There is another newline in the register, but it is easy to reason about. - You may not want the ending newline at all, so use
g_
instead of$
. - This mutates the
y
mark. This could be surprising, consider using a:yank
oryy
/Y
- Could "cast" put/paste or change the register type to accomplish the same effect. e.g.
nnoremap <f3> "+yy:call setreg('+', @+, 'v')<cr>
Personally, I lean toward using vim-highlightyank and the following mapping:
nnoremap <silent> <f3> "+yy:call setreg('+', @+, 'v')<cr>
add a comment |
You have options:
- Explicitly put an
:echo
at the end of your mapping.map <key> foo:echo "done"<cr>
- Use
'showcmd'
which will show partial commands. This will give you a slight clue that something happened for multi-key mappings/commands. (Not really helpful here) - Use a plugin like vim-highlightedyank to quickly highlight the last yank
General rule of thumbs for mappings:
- Supply a mode for mappings. e.g.
nmap
for normal mode - Use
*noremap
variants unless you want remapping to occur or using a<Plug>
mapping
This means you mapping would look like:
nnoremap <F3> my0v$"+y`y
Some more thoughts:
- This is very similar to
"+yy
/"+Y
,:yank +
, orV"+y
. There is another newline in the register, but it is easy to reason about. - You may not want the ending newline at all, so use
g_
instead of$
. - This mutates the
y
mark. This could be surprising, consider using a:yank
oryy
/Y
- Could "cast" put/paste or change the register type to accomplish the same effect. e.g.
nnoremap <f3> "+yy:call setreg('+', @+, 'v')<cr>
Personally, I lean toward using vim-highlightyank and the following mapping:
nnoremap <silent> <f3> "+yy:call setreg('+', @+, 'v')<cr>
add a comment |
You have options:
- Explicitly put an
:echo
at the end of your mapping.map <key> foo:echo "done"<cr>
- Use
'showcmd'
which will show partial commands. This will give you a slight clue that something happened for multi-key mappings/commands. (Not really helpful here) - Use a plugin like vim-highlightedyank to quickly highlight the last yank
General rule of thumbs for mappings:
- Supply a mode for mappings. e.g.
nmap
for normal mode - Use
*noremap
variants unless you want remapping to occur or using a<Plug>
mapping
This means you mapping would look like:
nnoremap <F3> my0v$"+y`y
Some more thoughts:
- This is very similar to
"+yy
/"+Y
,:yank +
, orV"+y
. There is another newline in the register, but it is easy to reason about. - You may not want the ending newline at all, so use
g_
instead of$
. - This mutates the
y
mark. This could be surprising, consider using a:yank
oryy
/Y
- Could "cast" put/paste or change the register type to accomplish the same effect. e.g.
nnoremap <f3> "+yy:call setreg('+', @+, 'v')<cr>
Personally, I lean toward using vim-highlightyank and the following mapping:
nnoremap <silent> <f3> "+yy:call setreg('+', @+, 'v')<cr>
You have options:
- Explicitly put an
:echo
at the end of your mapping.map <key> foo:echo "done"<cr>
- Use
'showcmd'
which will show partial commands. This will give you a slight clue that something happened for multi-key mappings/commands. (Not really helpful here) - Use a plugin like vim-highlightedyank to quickly highlight the last yank
General rule of thumbs for mappings:
- Supply a mode for mappings. e.g.
nmap
for normal mode - Use
*noremap
variants unless you want remapping to occur or using a<Plug>
mapping
This means you mapping would look like:
nnoremap <F3> my0v$"+y`y
Some more thoughts:
- This is very similar to
"+yy
/"+Y
,:yank +
, orV"+y
. There is another newline in the register, but it is easy to reason about. - You may not want the ending newline at all, so use
g_
instead of$
. - This mutates the
y
mark. This could be surprising, consider using a:yank
oryy
/Y
- Could "cast" put/paste or change the register type to accomplish the same effect. e.g.
nnoremap <f3> "+yy:call setreg('+', @+, 'v')<cr>
Personally, I lean toward using vim-highlightyank and the following mapping:
nnoremap <silent> <f3> "+yy:call setreg('+', @+, 'v')<cr>
edited 2 hours ago
answered 3 hours ago
Peter RinckerPeter Rincker
10.1k11728
10.1k11728
add a comment |
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%2f18565%2fvisual-feedback-after-executing-mapping%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
1
No answer, but isn't that the same as
map <F3> "+yy
?– Ralf
5 hours ago
This will copy the line character-wise instead of linewise. However, it will also copy the newline so it feels more linewise. I agree that it would probably be easier to just do
yy
/Y
or:yank
and just accept to do a little cleanup on paste/put.– Peter Rincker
4 hours ago