Vim cursor setup
Let's say I have this line in Vim and I click $
to reach EOL.
Hello Worl*d
The asterisk marks the place of the cursor, i.e.
Let's say now that I wanted to delete backwards until the space, so I use dT<Space>
. This leaves me with:
Hello *d
The problem is that the cursor is actually between the l
and the d
.
Another option in this case would diw
(or diW
if the word contained hyphens etc), but I like to be able to use the motion that first pops up in my head, and sometimes it's more obvious to do a motion until a character.
Is there any workaround here? One idea is to have the cursor moved to the right of the cursor block, instead of the left. I haven't found anything on this.
vim
add a comment |
Let's say I have this line in Vim and I click $
to reach EOL.
Hello Worl*d
The asterisk marks the place of the cursor, i.e.
Let's say now that I wanted to delete backwards until the space, so I use dT<Space>
. This leaves me with:
Hello *d
The problem is that the cursor is actually between the l
and the d
.
Another option in this case would diw
(or diW
if the word contained hyphens etc), but I like to be able to use the motion that first pops up in my head, and sometimes it's more obvious to do a motion until a character.
Is there any workaround here? One idea is to have the cursor moved to the right of the cursor block, instead of the left. I haven't found anything on this.
vim
Where do you see a/
?
– harrymc
Jan 30 at 11:23
Not slash, I cursivated the l and d in World. I fix it so we avoid misunderstandings.
– Max
Jan 30 at 12:29
add a comment |
Let's say I have this line in Vim and I click $
to reach EOL.
Hello Worl*d
The asterisk marks the place of the cursor, i.e.
Let's say now that I wanted to delete backwards until the space, so I use dT<Space>
. This leaves me with:
Hello *d
The problem is that the cursor is actually between the l
and the d
.
Another option in this case would diw
(or diW
if the word contained hyphens etc), but I like to be able to use the motion that first pops up in my head, and sometimes it's more obvious to do a motion until a character.
Is there any workaround here? One idea is to have the cursor moved to the right of the cursor block, instead of the left. I haven't found anything on this.
vim
Let's say I have this line in Vim and I click $
to reach EOL.
Hello Worl*d
The asterisk marks the place of the cursor, i.e.
Let's say now that I wanted to delete backwards until the space, so I use dT<Space>
. This leaves me with:
Hello *d
The problem is that the cursor is actually between the l
and the d
.
Another option in this case would diw
(or diW
if the word contained hyphens etc), but I like to be able to use the motion that first pops up in my head, and sometimes it's more obvious to do a motion until a character.
Is there any workaround here? One idea is to have the cursor moved to the right of the cursor block, instead of the left. I haven't found anything on this.
vim
vim
edited Jan 30 at 12:29
Max
asked Jan 30 at 10:26
MaxMax
479
479
Where do you see a/
?
– harrymc
Jan 30 at 11:23
Not slash, I cursivated the l and d in World. I fix it so we avoid misunderstandings.
– Max
Jan 30 at 12:29
add a comment |
Where do you see a/
?
– harrymc
Jan 30 at 11:23
Not slash, I cursivated the l and d in World. I fix it so we avoid misunderstandings.
– Max
Jan 30 at 12:29
Where do you see a
/
?– harrymc
Jan 30 at 11:23
Where do you see a
/
?– harrymc
Jan 30 at 11:23
Not slash, I cursivated the l and d in World. I fix it so we avoid misunderstandings.
– Max
Jan 30 at 12:29
Not slash, I cursivated the l and d in World. I fix it so we avoid misunderstandings.
– Max
Jan 30 at 12:29
add a comment |
2 Answers
2
active
oldest
votes
I understand that the problem is to delete the last word in the line when the EOL
character immediately follows this word, when your preferred shortcut leaves
the last character without deleting it.
The problem might be because Vim makes a distinction between inclusive and exclusive
motions. Using v
toggles the "inclusiveness" or "exclusiveness" of a motion.
So you may use this combination:
d+v+T+Space
See :help inclusive
for an explication.
If this is too long, you may record a
macro
for it.
You could also use the following shortcuts:
daw : delete the word under the cursor (includes spaces before the next word)
caw : same and puts you in insert mode
diw : delete entire word without touching whitespace around it
daW : delete all characters between two whitespaces
Just what I was looking for. Will use thev
command a lot, for sure. Thanks for the options as well.
– Max
Jan 30 at 14:28
add a comment |
- With
:set virtualedit=onemore
, you can move the cursor to the right of the last character, and your command would work:$ldT<Space>
- As you've mentioned, the natural motion would be
iw
in this case. - Instead of
T<Space>
, you could also useb
here. - I probably would use
bD
here. - If
dT<Space>
is what first comes to your mind, you can correct the missed character withx
. As long as you don't use the deleted contents or undo, this doesn't matter.
Thanks for the clarification and the possible solutions, I read up some one "onemore" and it seems that it may break some plugins etc, so I'll opt for the solution to togglev
inclusiveness.
– Max
Jan 30 at 14:26
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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%2fsuperuser.com%2fquestions%2f1400019%2fvim-cursor-setup%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
I understand that the problem is to delete the last word in the line when the EOL
character immediately follows this word, when your preferred shortcut leaves
the last character without deleting it.
The problem might be because Vim makes a distinction between inclusive and exclusive
motions. Using v
toggles the "inclusiveness" or "exclusiveness" of a motion.
So you may use this combination:
d+v+T+Space
See :help inclusive
for an explication.
If this is too long, you may record a
macro
for it.
You could also use the following shortcuts:
daw : delete the word under the cursor (includes spaces before the next word)
caw : same and puts you in insert mode
diw : delete entire word without touching whitespace around it
daW : delete all characters between two whitespaces
Just what I was looking for. Will use thev
command a lot, for sure. Thanks for the options as well.
– Max
Jan 30 at 14:28
add a comment |
I understand that the problem is to delete the last word in the line when the EOL
character immediately follows this word, when your preferred shortcut leaves
the last character without deleting it.
The problem might be because Vim makes a distinction between inclusive and exclusive
motions. Using v
toggles the "inclusiveness" or "exclusiveness" of a motion.
So you may use this combination:
d+v+T+Space
See :help inclusive
for an explication.
If this is too long, you may record a
macro
for it.
You could also use the following shortcuts:
daw : delete the word under the cursor (includes spaces before the next word)
caw : same and puts you in insert mode
diw : delete entire word without touching whitespace around it
daW : delete all characters between two whitespaces
Just what I was looking for. Will use thev
command a lot, for sure. Thanks for the options as well.
– Max
Jan 30 at 14:28
add a comment |
I understand that the problem is to delete the last word in the line when the EOL
character immediately follows this word, when your preferred shortcut leaves
the last character without deleting it.
The problem might be because Vim makes a distinction between inclusive and exclusive
motions. Using v
toggles the "inclusiveness" or "exclusiveness" of a motion.
So you may use this combination:
d+v+T+Space
See :help inclusive
for an explication.
If this is too long, you may record a
macro
for it.
You could also use the following shortcuts:
daw : delete the word under the cursor (includes spaces before the next word)
caw : same and puts you in insert mode
diw : delete entire word without touching whitespace around it
daW : delete all characters between two whitespaces
I understand that the problem is to delete the last word in the line when the EOL
character immediately follows this word, when your preferred shortcut leaves
the last character without deleting it.
The problem might be because Vim makes a distinction between inclusive and exclusive
motions. Using v
toggles the "inclusiveness" or "exclusiveness" of a motion.
So you may use this combination:
d+v+T+Space
See :help inclusive
for an explication.
If this is too long, you may record a
macro
for it.
You could also use the following shortcuts:
daw : delete the word under the cursor (includes spaces before the next word)
caw : same and puts you in insert mode
diw : delete entire word without touching whitespace around it
daW : delete all characters between two whitespaces
answered Jan 30 at 13:13
harrymcharrymc
264k14272581
264k14272581
Just what I was looking for. Will use thev
command a lot, for sure. Thanks for the options as well.
– Max
Jan 30 at 14:28
add a comment |
Just what I was looking for. Will use thev
command a lot, for sure. Thanks for the options as well.
– Max
Jan 30 at 14:28
Just what I was looking for. Will use the
v
command a lot, for sure. Thanks for the options as well.– Max
Jan 30 at 14:28
Just what I was looking for. Will use the
v
command a lot, for sure. Thanks for the options as well.– Max
Jan 30 at 14:28
add a comment |
- With
:set virtualedit=onemore
, you can move the cursor to the right of the last character, and your command would work:$ldT<Space>
- As you've mentioned, the natural motion would be
iw
in this case. - Instead of
T<Space>
, you could also useb
here. - I probably would use
bD
here. - If
dT<Space>
is what first comes to your mind, you can correct the missed character withx
. As long as you don't use the deleted contents or undo, this doesn't matter.
Thanks for the clarification and the possible solutions, I read up some one "onemore" and it seems that it may break some plugins etc, so I'll opt for the solution to togglev
inclusiveness.
– Max
Jan 30 at 14:26
add a comment |
- With
:set virtualedit=onemore
, you can move the cursor to the right of the last character, and your command would work:$ldT<Space>
- As you've mentioned, the natural motion would be
iw
in this case. - Instead of
T<Space>
, you could also useb
here. - I probably would use
bD
here. - If
dT<Space>
is what first comes to your mind, you can correct the missed character withx
. As long as you don't use the deleted contents or undo, this doesn't matter.
Thanks for the clarification and the possible solutions, I read up some one "onemore" and it seems that it may break some plugins etc, so I'll opt for the solution to togglev
inclusiveness.
– Max
Jan 30 at 14:26
add a comment |
- With
:set virtualedit=onemore
, you can move the cursor to the right of the last character, and your command would work:$ldT<Space>
- As you've mentioned, the natural motion would be
iw
in this case. - Instead of
T<Space>
, you could also useb
here. - I probably would use
bD
here. - If
dT<Space>
is what first comes to your mind, you can correct the missed character withx
. As long as you don't use the deleted contents or undo, this doesn't matter.
- With
:set virtualedit=onemore
, you can move the cursor to the right of the last character, and your command would work:$ldT<Space>
- As you've mentioned, the natural motion would be
iw
in this case. - Instead of
T<Space>
, you could also useb
here. - I probably would use
bD
here. - If
dT<Space>
is what first comes to your mind, you can correct the missed character withx
. As long as you don't use the deleted contents or undo, this doesn't matter.
answered Jan 30 at 13:05
Ingo KarkatIngo Karkat
17.8k22646
17.8k22646
Thanks for the clarification and the possible solutions, I read up some one "onemore" and it seems that it may break some plugins etc, so I'll opt for the solution to togglev
inclusiveness.
– Max
Jan 30 at 14:26
add a comment |
Thanks for the clarification and the possible solutions, I read up some one "onemore" and it seems that it may break some plugins etc, so I'll opt for the solution to togglev
inclusiveness.
– Max
Jan 30 at 14:26
Thanks for the clarification and the possible solutions, I read up some one "onemore" and it seems that it may break some plugins etc, so I'll opt for the solution to toggle
v
inclusiveness.– Max
Jan 30 at 14:26
Thanks for the clarification and the possible solutions, I read up some one "onemore" and it seems that it may break some plugins etc, so I'll opt for the solution to toggle
v
inclusiveness.– Max
Jan 30 at 14:26
add a comment |
Thanks for contributing an answer to Super User!
- 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%2fsuperuser.com%2fquestions%2f1400019%2fvim-cursor-setup%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
Where do you see a
/
?– harrymc
Jan 30 at 11:23
Not slash, I cursivated the l and d in World. I fix it so we avoid misunderstandings.
– Max
Jan 30 at 12:29