You are not logged in.
Is there a shortcut for this? Ie. say I have a line like
... /home/alphaniner/data/Downloads/isos/Linux/syslinux/custom/sysresccd-20130927-2009.md5and I want to delete from my cursor to the last / on the line. I know I could count the slashes/etc. but that's just tiresome.
But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner
Offline
I don't know if there is a single key just for this, but these 5 would do it, you could make that into a binding for any character:
$F/d0"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Online
That deletes to the beginning of the line, not the cursor. You could set a mark first (maybe there's even some kind of automatic mark for this? I need to learn to use marks more):
ma$F/d`aBut you could also do (in this example)
d//sysr<CR>This is usable as long as the part after the last / is (visible and) unique (and doesn't share a long prefix with a path element between it and the cursor).
Last edited by Raynman (2013-09-27 22:46:17)
Offline
For what it's worth, you could also use visual mode for that:
v$F/dwhich would work pretty similarly to Raynman's mark method, but without having to actually mess around with marks.
Offline
I want to delete from my cursor to the last / on the line.
D:: Registered Linux User No. 223384
:: github
:: infinality-bundle+fonts: good looking fonts made easy
Offline
alphaniner wrote:I want to delete from my cursor to the last / on the line.
D
I think he means specific character (in the example a / ), not the last character on the line
Offline
I think he means specific character (in the example a / ), not the last character on the line
Oh yes, you're right. My bad, sorry.
:: Registered Linux User No. 223384
:: github
:: infinality-bundle+fonts: good looking fonts made easy
Offline
df/.......It's vim golf, just with bad putting... ![]()
# edit: FWIW, I just take a wild guess at the number and refine once the damage is done. In th above case I initially guessed a 6, which just leaves `..`
Offline
If you know its the last character in the line, why not this?
vj?*-Enter-dvisual mode - go down a line - reverse search for character (put the character you want) and press enter - delete
Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.
Offline
ngoonee, that's like v$F/d except requiring more keypresses and failing if there is a / near the beginning of the line below.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Online
Thanks Trilby. I don't know what 'F' is in vim though, not bound to anything for me (I'm assuming its basically ?).
Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.
Offline
'F' searches back for the character. 'Fi' moves the cursor to the previous occurrence of 'i'. 'fi' does the same, but forward.
Offline
F and f only work within a line. Is this possibly why you are not seeing any effect, ngoonee? Go to the end of a line of text, for example, and hit F<space>. "?" searches backward, but it waits for a <enter> to end a string of text, while F I would not call a search, but a cursor movement like h, l, w, or b.
Last edited by Trilby (2013-09-28 12:25:02)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Online
Oh yes, it's a move, not a search, my bad.
Offline
F and f only work within a line. Is this possibly why you are not seeing any effect, ngoonee? Go to the end of a line of text, for example, and hit F<space>. "?" searches backward, but it waits for a <enter> to end a string of text, while F I would not call a search, but a cursor movement like h, l, w, or b.
Years of using vim and I never knew this! Thanks Trilby (and karol)
I've always used / and ? for searching.
Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.
Offline
More terrible putting, you could do this while recording a macro and using a mark.
In NORMAL mode with your cursor where you want it to be on one line of your choice...
qqma$F/d`axqqq - Start recording into 'q'
ma - Set a mark at the current position of the cursor named 'a'
$ - Go to the end of the line
F/ - Find, going backwards, the first occurrence of '/'
d`a - Delete from the current position to the position of the mark 'a'
x - Delete the leftover slash character
q - Stop recordingNow this is stored in a macro you can use again and again from normal mode by typing:
@qOr more simply to repeat the last executed macro:
@@Offline
This is the shortest I could come up with.
$T/d0$ - end of line
T/ - go back till /
d0 - delete to beginning of lineYou could turn this into a macro if you need to repeat this.
We wants it, we needs it. Must have the precious. Arch Linux.
Offline
Stewie, that's basically the same as my first shot - that deletes from the beginning of the line, not from the current cursor position. Wibjarm's seems to be the best answer (so far?).
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Online
Stewie, that's basically the same as my first shot - that deletes from the beginning of the line, not from the current cursor position. Wibjarm's seems to be the best answer (so far?).
Your answer will still leave a / . I'm assuming alphaniner wanted that removed. My answer is very similiar to Wibjarm's, just a different method. I hadn't seen anyone use the `T' command yet, and it seemed appropriate in this situation.
We wants it, we needs it. Must have the precious. Arch Linux.
Offline
Wow, I wasn't expecting so much input, thanks everybody. ![]()
I'll test them out later when I have a chance.
But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner
Offline
Can do it as a command, too:
:s/\%#.*\//\%# is the cursor position.
Last edited by Procyon (2013-09-30 14:50:32)
Offline