ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Vim编辑器-Basic Visual Mode

2021-10-08 10:32:27  阅读:153  来源: 互联网

标签:text lines visual Visual command mode Basic block Mode


6 Basic Visual Mode

  • How to start visual mode
  • Visual yanking
  • Using visual mode to change text
  • Visual commands for programmers
  • Visual block mode

  • Entering Visual Mode
    To enter visual mode, type the v command.

  • The Three Visual Modes
    TheV command starts linewise visual mode.You can highlight only full lines in this mode.

To get help on the commands that operate in visual mode, use the prefix v_. Therefore :help v_d
describes what the d command does in visual mode.

To highlight a rectangle on the screen, use CTRL-V.This mode is extremely useful if you want to work with tables.You can highlight a column and delete it using the d command.

  • Leaving Visual Mode
    Normally, you leave visual mode by typing a visual-mode command, such as d to delete the highlighted text. But you can also cancel visual mode by pressing the key. Remember, you can always type to get back to normal mode so you know
    where you are. Some people find a little annoying because it beeps if you type it twice.The first goes from visual mode to normal mode.The second in normal mode is an error and generates the beep. (The command CTRL-C will do the same thing as well.)
    If you want to make sure that you are in normal mode and do not want to gener- ate a beep, use the CTRL-\CTRL-N command.This acts just like but without the noise.

  • Editing with Visual Mode

  • Deleting Text in Visual Mode
    The d command deletes the highlighted text.
    The D command deletes the highlighted lines, even if only part of a line is high-
    lighted.

  • Yanking Text
    The y command places the highlighted text into a register.
    Y, places each line of the highlighted text into a register.

  • Switching Modes
    Suppose you are in character mode (started by v) and you realize you want to be in block mode.You can switch to block mode by just pressing CTRL-V.
    In fact, you can switch visual modes at any time by just selecting the new mode.To cancel visual mode, press the key; or you can switch to the mode you are already in. (In other words, if you use v to start visual mode, you can use another v to exit it.)

  • Changing Text
    The c command deletes the highlighted text and starts insert mode.The C command
    does the same thing, but it works only on whole lines.

  • Joining Lines
    The J command joins all the highlighted lines into one long line. Spaces are used to separate the lines.
    If you want to join the lines without adding spaces, use the gJ command.

r and s do the same thing as c in visual mode. The same thing goes for R and S.

  • Commands for Programmers
    The > command indents the selected lines by one “shift width.” (The amount of white space can be set with the 'shiftwidth' option.) The < does the process in reverse.
    (Note that these commands have a different meaning when using visual block mode.)
    The = command indents the text.The CTRL-] command will jump to definition of the function highlighted.

  • Keyword Lookup
    The K command is designed to look up the selected text using the “man” command. It works just like the normal-mode K command except that it uses the highlighted text as the keyword.

  • Visual Block Mode
    Some commands work a little differently in visual block mode.Visual block mode is started by pressing CTRL-V and is used to define a rectangle on the screen.

  • Inserting Text
    The command Istring inserts the text on each line starting at the left side of the visual block.

  • Changing Text
    he visual block c command deletes the block and then throws you into insert mode to enable you to type in a string.The string will be inserted on each line in the block.
    The c command works only if you enter less than one line of new text. If you enter something that contains a newline, only the first line is changed. (In other words, visual block c acts just normal-mode c if the text contains more than one line.)

The string will not be inserted on lines that do not extend into the block. Therefore if the block includes some short lines, the string will not be inserted in the short lines.

The C command deletes text from the left edge of the block to the end of line. It then puts you in insert mode so that you can type in a string, which is added to the end of each line. Again, short lines that do not reach into the block are excluded.
The visual block A throws Vim into insert mode to enable you to input a string.The string is appended to the block. If there are short lines in the block, spaces are added to pad the line and then string is appended.
You may notice that the A command affects short lines, whereas the other editing commands do not.

  • Replacing
    The rchar command applies all the selected characters with a single character. Short lines that do not extend into the block are not affected.

  • Shifting
    The command > shifts the text to the right one shift width, opening whitespace.The starting point for this shift is the left side of the visual block.
    The < command removes one shift width of whitespace at the left side of the block (see Figure 6.17).This command is limited by the amount of text that is there; so if there is less than a shift width of whitespace available, it removes what it can.

  • Visual Block Help
    Getting help for the commands that use visual block mode differs a little from other commands.You need to prefix the command with v_b_.To get help on the visual block r command, for example, type the following:
    :help v_b_r

标签:text,lines,visual,Visual,command,mode,Basic,block,Mode
来源: https://www.cnblogs.com/chao8888/p/15378546.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有