2

I'm not talking about learning or introducing commands, but how to work by switching between modes, and using normal known commands. Do most vim users stay more in normal mode instead of in insert mode? I find it impossible to use vim more in normal mode. Apart from Replace mode, how can anybody type without being in Insert mode?

Example scenario: I sometime copy a paragraph from a web browser to vim. After that I will edit it into bullet points from a paragraph.

I will rearrange the points that I have made out of the paragraph according to priority. I will even add in some of my own remarks over the points.

Now, how can I use normal mode for such a thing? I am relatively new to vim, so I will mostly do it in insert mode, unless I want to highlight to move the lines using d or dd command.

As for breaking the paragraph into point lines, I will use insert mode (just press <enter>). I have being wondering how to do <CR> or <enter> in normal mode, so that I don't have to switch to insert mode just to do an <enter>.

I also type my remarks in Insert mode.

1
  • 1
    You may like to know that the tag section is searchable, so you can start typing "normal" and find a tag normal-mode
    – D. Ben Knoble
    Aug 23 '20 at 17:24
4

I happen to be teaching myself kdenlive (video editor) this weekend. In need of a subject for my first project, I created a video demonstrating some of what you mention.

In particular, the tasks I perform in the video are...

  1. Paste several Ipsum Lorem sentences from the clipboard into vim
  2. Find the ending period ('.') of the first sentence and append two newlines (first sentence is now separated from the others)
  3. Advance to the end of each subsequent sentence and perform a repeat-last-edit (now all sentences are their own paragraphs)
  4. Join the broken lines of each sentence into one long line.
  5. Set the document text width to 64 characters
  6. Reformat each sentence to fit within the 64 character limit
  7. Indent each sentence (multi-line indent)
  8. Add a bullet symbol to in front of each sentence

I document the keystrokes I pressed to perform these operations. I also roughly measured the time I spent in normal, visual, command and insert modes and published the results at the end of the video (and here: 2min, 15sec, 7sec 5sec - all numbers a approximate!)

Here's my kdenlive project, freshly posted to youtube...

Brief vim demo creating a bulleted list

3
  • 1
    Good demo Bob, well done. But please remove colons from your video instructions to avoid confusion. Some people might think, for example, }: is what they need to enter to get the same result.
    – elmclose
    Aug 24 '20 at 6:36
  • 3
    Things you might like: >ap, vipJ, gqap or gggqG. Visual mode not used as much as operators on text-objects.
    – D. Ben Knoble
    Aug 24 '20 at 13:16
  • 1
    @D. Ben Knoble Good suggestions. When I do normal mode operations I find it useful to deconstruct in my mind the meaning of each keystroke, or pair of keystrokes. A mnemonic device. Of your ideas, gggqG makes sense "go to top of doc ('gg'), and reformat ('gq') to end of the doc ('G')". But I couldn't decipher >ap, vipJ and gqap until I looked up ap ("a paragraph) and ip ("inner paragraph"). Too easy to live inside a subset of vim commands and not expand one's toolset! I'm here trying to help others and, in so doing, learn more myself - even tho I've used vim +25 yrs, still much to learn! thx Aug 24 '20 at 16:45
2

I try to address this specific "how": "breaking the paragraph into point lines"

Navigate to whitespace where you want the break to occur and replace it with Enter:

r<Enter>

You will stay in normal mode.

1
  • It seems to me that in this case it's easier to switch into insert mode, enter, and back to normal mode: i<enter><esc> Aug 27 '20 at 20:06
2

Do most vim users stay more in normal mode instead of in insert mode? I find it impossible to use vim more in normal mode. Apart from Replace mode, how can anybody type without being in Insert mode?

I don't know about "most vim users," but I edited your entire post mostly in normal mode. I'm typing this answer in vim, in insert mode to add the text, but in normal mode to edit things (like changing character case with ~, reflowing paragraphs with gq, and inserting blockquotes > with either visual-block or a :substitute command).

Example scenario: I sometime copy a paragraph from a web browser to vim. After that I will edit it into bullet points from a paragraph.

Since that's close to what I did, I'll mention a few things I used:

  • searching with / is one of the fastest navigation tools
  • but within a line, f and friends can also be very fast
  • I had to add backticks to your words like <enter>: I did it using a plugin called surround.vim, so I pressed:
ysa>`

But I could have also done

:%substitute/<[^>]*>/`&`/g
  • to rearrange points, I used sentence navigation and text-objects (( and ), is and as) as well as )hrEnter like in the other answer

I will rearrange the points that I have made out of the paragraph according to priority. I will even add in some of my own remarks over the points.

You have to type in insert mode; that's mostly a given. But to rearrange points, ddp or :move are quite nice. (If your points are multiline, you may need d2j or dap.)

I find normal mode faster than visual mode for many things, and certainly faster than insert mode for deleting (no more holding backspace) or finding words (searching) or changing things (c is helpful if you keep hitting d<...>i). I think you may need to learn some basic normal mode commands; there's so much more than hjkl, v, and d.

Or, it may not be that modal editing is for you; it isn't for everyone.

2
  • @andrew_ysk suggestion: there is no one true way. Learn by doing, reading, asking questions about how to do something more efficiently, rather than by emulating others. We’re happy to help, since we’ve picked up our own tricks and habits and techniques. But ultimately it’s your editor; make it work for you.
    – D. Ben Knoble
    Aug 27 '20 at 18:41
  • @andrew_ysk they are probably still in your inbox, unless the comments were deleted. Also, questions about the site can be asked on Vi and Vim Meta and Vi and Vim Chat
    – D. Ben Knoble
    Aug 27 '20 at 19:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.