4

I've been using vim for a few years and I love how easy it is to do simple tasks like insert above current line, delete whole line, etc. I've even mapped my caps lock to escape because of it!

One problem with vim that I could never get over was how much thinking navigation requires compared to mouse movements, even after you've learned the keys. I know about some of the movements like %, ^, $, f/F, t/T and using numbers before a command but I feel like it takes a lot more effort to use them and they disrupt my workflow.

For example, I need to delete the "/many/sections/" of this url and the cursor is in the middle of the word "really":

http://this/is/a/real|ly/long/url/with/many/sections/

With a mouse, it takes no thinking power to just click and select the sections I want to remove and hit delete.

If I do this in vim, I find myself thinking: Ok, first $ brings the cursor to the end. Then I want to delete those sections so I can use the '/' as deliminator and now I have to count how many of the '/' I want to move back. It's two and I have to search backwards so it's F, not f. So I think the command should be $d2F/.

Alternatively, I could have used 'm' as a landmark for the cursor and delete to the end from there but then I'd have to scan the url to look for letters to use. And if there was another m, I'd also have to press ; repeatedly or start counting.

This seems a lot harder than just using a mouse, even with the delay of moving my hands off the keyboard. This is especially true for multiple line selections where I find myself spending a lot of time counting words or lines or looking for deliminators.

Also, sometimes the command either deletes or doesn't delete some extra deliminator characters because I used f instead of t or vice versa whereas with a mouse, I can pinpoint exactly what I'm trying to select.

Kent
  • 189,393
  • 32
  • 233
  • 301
Wei
  • 207
  • 3
  • 6
  • 3
    1) Stackoverflow isn't really the place to debate [opinions](http://stackoverflow.com/help/dont-ask), sorry. 2) Obligatory link to ["You don't grok vi"](http://stackoverflow.com/a/1220118). 3) Do you have a question? – glts Aug 28 '13 at 12:34
  • You know you can use your mouse in Vim, right? – romainl Aug 28 '13 at 12:44
  • 1
    I rolled back the EDIT, because the Edit from @octopusgrabbus made the question have different meaning. The OP wants to discuss the navigation in vim. not asking how to use mouse in vim. also by reading the question, he very likely knew how to use mouse in vim. – Kent Aug 28 '13 at 12:54
  • [A quick reference was made for vim navigation](https://www.reddit.com/r/vim/comments/kq0sbd/a_quick_reference_was_made_for_vim_navigation/) – Raos Jan 05 '21 at 02:53

4 Answers4

6

The / key is your friend. From where you are hit /ma ENTER. Then, hit D to delete the rest of the line.

DJG
  • 6,413
  • 4
  • 30
  • 51
  • 2
    with `set incsearch` this is rather nice +1. – FUD Aug 28 '13 at 12:51
  • Oh and for moving back `?ma` too is easy to think of. – FUD Aug 28 '13 at 12:53
  • What if there are things after /many/sections/ that I want to keep? – Wei Aug 28 '13 at 13:02
  • 1
    lets say from some weird reason i want to delete 'many/s' i would do `/ma[Enter]d/ec[Enter]` – FUD Aug 28 '13 at 13:05
  • @Wei: You could use something like `d2w` or `dw..` to repeat word deletion multiple times. – Xavier T. Aug 28 '13 at 13:13
  • @Wei, Vim is all about combining little blocks in specific ways to perform specific tasks. Some tasks are so common that they have their own pre-made combinations that most people know but some tasks are so complex and domain-specific that they require a bit of thinking. There's obviously a trade-off to find between thinking a minute or two before issuing a smart command and mashing keys/using the mouse to avoid thinking too hard. It's yours to find your threshold. If you have to cope with such tasks too often, use macros and mappings to make them more bearable. – romainl Aug 28 '13 at 13:31
3

The /maEnterD is probably the quickest solution and does not require hard motion planning. (And similarly use ? for reverse motion).

But if you feel you need more motion, you should definitely check Easymotion plugin. it expands the f,F motion to the whole window, rather than the single line.

Actually, I do agree that using F is quite cumbersome, I'd rather use text object, like vi) or dip.

Xavier T.
  • 40,509
  • 10
  • 68
  • 97
0

Use gvim so you can use your mouse.

cforbish
  • 8,567
  • 3
  • 28
  • 32
  • 1
    set mouse=a then you can use mouse in terminal vim too, but i don't think thats the intent of the question – FUD Aug 28 '13 at 12:44
  • @FUD, I thought maybe he might not have known about gvim. I never assume anything. – cforbish Aug 28 '13 at 16:34
0

If you don't like planning, what about repeating?

$dF/.

doesn't require any thinking whatsoever.

wwwwwwwD

doesn't require any thinking either.

Anyway, I would do /ma<CR>D like already mentioned.

And nothing prevents you from using the mouse if you are more comfortable with it.

romainl
  • 186,200
  • 21
  • 280
  • 313