当前位置:网站首页>2 normal mode

2 normal mode

2020-11-09 07:30:24 osc_71qxolcv

  • Vim The natural relaxation state of
  • The whole book talks about how to use common patterns
    • This chapter only deals with some core concepts
    • General skills

  • Other editors spend most of the time Vim Insertion mode

  • Many normal mode commands are executed with a specified number of times

  • skill 10

    • A pair of commands for adding and subtracting values
    • And you'll see how these two commands are combined with the number of times , Do simple arithmetic operations
  • Specifying the number of times to execute can reduce the number of keys

  • You'll see some examples ,

    • Simply repeat a command ,
    • It's better than taking the time to figure out how many times you want to execute

  • The power of normal mode commands ,
    • Largely because it can combine operators with action commands .
  • At the end of this chapter , We're going to see the effect of this combination .

skill 7 Please move the brush when you pause

  • Painters don't put their brushes on the canvas when they're resting .
  • Yes Vim It's the same thing about it , The normal pattern is Vim The natural relaxation of

  • Painters spend only a small part of their time painting
  • Programmers also spend only a fraction of their time writing code
  • Most of the time I think about 、 read , And shuttling through the code
  • When you really want to modify , Who said you had to switch to insert mode ?
  • We can reformat the existing code , Copy them , Move its position , Or delete them
  • In normal mode , There are many tools to use

skill 8 Cut the undo unit into blocks

  • u Undo the latest changes
  • A modification can be any operation that changes the text within the document ,
    • Included in the normal mode 、 Commands triggered in visual mode and command line mode
    • And a modification also includes input in insert mode ( Or delete ) The text of ,
    • i{insert some text} It's a modification

  • In a schema insensitive text editor , Enter some words and use the undo command ,
    • There are two possibilities .
    • Undo the last character entered ;
    • The other is better , It may break characters into blocks , Make each undo delete a word instead of a character .

  • Vim You can control the granularity of undo commands
  • Start with insertion mode ,
    • To return to normal mode ,
    • Anything entered or deleted during this period is treated as a modification
  • As long as it's under control <Esc> Use
    • You can make the undo command work on the word 、 A sentence or paragraph .

  • How often should you leave insert mode ?
  • I like
    • Every “ Revocable block ” Corresponding to a thinking process
  • In writing this passage ( Of course is in Vim Write in ),
    • I often end with a pause ,
    • What do you want to write next
  • No matter how short the pause is ,
    • It's a natural break point ,
    • It's time for me to quit plug-in mode .
  • When you're ready to continue writing , Press A Just go back to where you were and continue

  • If I think I'm going in the wrong direction , I switch to normal mode , Then press u
  • Every time you do undo , The words follow the way I first wrote , Cut into well-organized pieces , That means I can easily try to write a sentence or two , If it doesn't feel right , You can discard it by pressing a key or two .

  • When in insert mode ,
    • If the cursor is at the end of the line , The fastest way to start another line is to press .
  • Sometimes I prefer to press o ,
    • Because I have a hunch , Maybe I want to have a finer granularity in undo
    • It doesn't sound very understandable , When you are right Vim More and more familiar with , It's easier to switch modes .

  • If you pause long enough to ask “ Should I quit insert mode ?” This problem ,
    So quit .

Moving the cursor in insert mode resets the modification state

  • The undo command reverses the input from entering insert mode to exiting this mode ( Or delete ) When all the characters of ,
  • I've missed a little detail .
  • If you use 、 、
    or These cursor keys , A new undo block will be generated .
  • You can think of it as switching back to normal mode first ,
    • And then use h 、 j 、 k or l Command to move the cursor ,
    • The only difference is that we're not out of insert mode .
    • That would be right . The operation of the command has an impact .

版权声明
本文为[osc_71qxolcv]所创,转载请带上原文链接,感谢