oeasy teaches you how to play vim – 50 – # Command line efficiency

Time:2022-11-25

command line efficiency

Recall the content of the previous lesson

Summarize

  • Last time we looked at the range command execution method
  • batch control indentation

    • :20,40>
  • Execute commands in normal mode in batches

    • :4,10normal A;
  • switch directly tofull screen command mode ex-mode

    • Q
  • execute external command

    • !javac oeasy.java
  • This way is really cool!

    • existviEverything is done!
  • Could the command pattern itself be more efficient?

list history

Use history commands

  • when outputting the command

    • Arrow key⬅️️➡️️️Can control left and right movement
    • shift+⬅️️➡️️️Move the cursor left and right according to the word
    • ctrl+bto the beginning begin
    • ctrl+eto the end end
    • ctrl+wdelete a word forward

      • Pay special attention to this, some browsers close tabs
      • I have no problem with firefox
    • ctrl+udelete to the beginning
  • Arrow key↑️↓️️️You can browse through the history commands

    • You can also enter first:h spress again↑️
    • can be found based on existing content

      • :h scrolloff
      • :h shiftwidth
  • What if you want to list all command history?

command history

  • We can list all executed commands:history

oeasy teaches you how to play vim - 50 - # Command line efficiency

  • :h his[tory]can be foundcommandline.txt
  • History can be viewed by type

    • :his cor:his :command class history
    • :his sor:his /or:his ?Search Class History
    • :his eor:his =expression register class
    • :his ior:his @input row class
    • :his dor:his >debug class
  • range can be added

    • :his 2,5 2-5command line history
    • :his / 3,9Query class command history3-9strip
    • his -5,-1Newest5strip
  • How many commands can be saved in total?

number of orders

  • :set history&

    • Revert to default history commands
  • :set history?

    • How much does it look like?
    • 50
  • set more command history

    • :set history=1000

oeasy teaches you how to play vim - 50 - # Command line efficiency

Modify the command directly

  • In command line modectrl+f
  • or in normal mode

    • q:query all commands
    • q:Query all search commands

oeasy teaches you how to play vim - 50 - # Command line efficiency

new window

  • This window has a history of commands

    • can move
    • can be modified
  • Execute the command on the line where the cursor is after the carriage return
  • after execution

    • Historical commands are not modified
    • Add a new command history
  • Can I copy and paste from the command line?

use register

  • Can I copy and paste from the command line?
  • You can check the manual:h c_ctrl-r

    • query command modectrl+r
    • This is consistent with using registers in insert mode
    • are allctrl+r
    • Then specify the register
  • This way we can use registers on the command line

oeasy teaches you how to play vim - 50 - # Command line efficiency

  • Let’s first look at what’s in the register?

    • :reg

Concrete operation

oeasy teaches you how to play vim - 50 - # Command line efficiency

  • First:Enter command line mode

    • Thenctrl+r
    • Then if we press the"
    • Put the contents of the default register into the command line
  • if we again:

    • Thenctrl+r
    • press down%Put the filename on the command line
    • for example:!javac You can use this method to enter the current file name into the command line
  • But still the simplest:!javac %

Summarize

  • Running cursor control from the command line

    • Arrow key⬅️️➡️️️Can control left and right movement
    • shift+⬅️️➡️️️Move the cursor left and right according to the word
    • ctrl+bto the beginning begin
    • ctrl+eto the end end
    • ctrl+wdelete a word forward

      • Close the window carefully!
    • ctrl+udelete to the beginning
  • Traversal of historical commands

    • Arrow key↑️↓️️️
  • History of the command line

    • :history
    • :his -5
    • :his s
  • Enter Command HistoryEdit

    • In command line statectrl+f
    • or in normal modeq:
    • select, edit, enter
  • use register

    • In command line statectrl+r
    • Then enter the name of the register
  • Can command mode read and write files?
  • next time

[Github address] (https://github.com/overmind19…)
[Gitee address] (https://gitee.com/overmind198…)
[Invitation Code FJWYIMGB of Lanqiao Experimental Building] (https://www.lanqiao.cn/course…)