Play the Vim editor-navigate Mobile __vim

Source: Internet
Author: User

Fun VIM Editor - Navigation Mobile

      If you move the cursor through h, j, k, l as mentioned above, it will be time consuming and inefficient during a large amount of movement. This section uses a few quick navigation moves to quickly move the cursor to the specified position. Numerical parameter

For example, if you want to move 4 characters to the right, you can use 4l, which is equivalent to llll. Scroll full page or half page

Navigation key

description

CTRL+F

Scroll down the entire page

CTRL+B

Scroll up the entire page

CTRL+D

Scroll down half a page

CTRL+U

Scroll up half a page

CTRL+E

Scroll down one line

CTRL+Y

Scroll up one line

Word navigation
Navigation key

description

w

Move to the beginning of the next word

W

Move to the beginning of the next WORD

e

Move to the end of the current word

E

Move to the end of the current WORD

b

Move to the beginning of the previous word

B

Move to the beginning of the previous WORD

The difference between word and WORD
Word consists of a series of characters, numbers, and underscores, and WORD is a string of non-whitespace characters separated by spaces. For example, image[0].x = 192.15, then this has a lot of word components, and only three WORDs are composed: image[0].x, =, and 192.15. Several cursor special positions in a row

Navigation key

description

0

Jump to the beginning of the current line

$

Jump to the end of the current line

^

Jump to the first non-null character at the beginning of the current line

G_

Jump to the last non-empty character of the current line

Jump of paragraphs, chapters, statements
Navigation key

description

{

Move to the beginning of the current paragraph

}

Move to the beginning of the next paragraph

[[

Move to the beginning of the current chapter

]]

Move to the beginning of the next chapter

(

Move to the beginning of the current statement

)

Move to the beginning of the next statement

      Take a good look at the meaning of paragraphs, chapters, and statements. Where paragraphs are used in comparison, you can jump back and forth from a subfunction. Chapter: Big jump. Statement: Blank line split. Screen navigation

Navigation key

description

H

Move to the top of the screen - home

M

Move to the middle of the screen -middle

L

Move to the bottom of the screen - last

nH

Move to the nth line at the top of the screen

nL

Move to the nth line on the bottom of the screen

Redraw the screen with the current line
Navigation key

description

z then ENTER

Move the cursor line to the top of the screen and scroll the screen

z.

Move the cursor line to the center of the screen and scroll the screen

z-

Move the cursor line to the bottom of the screen and scroll the screen

200z then ENTER

Will move line 200 to the top of the screen

Quickly jump to the beginning and end of the file
Navigation key

description

:0

Jump to file header - method 1

Gg

Jump to file header - method 2

1G

Jump to file header - method 3

:$

Jump to the end of the file - method 1

G

Jump to the end of the file - method 2

Jump to the Nth character of the file, N%
Navigation key

description

50%

Jump to 50% of the file, which is in the middle of the file

75%

Jump to 75% of the file, ie 3/4

100l

Jump to the 100th character calculated from the current position

100<space>

Jump to the 100th space calculated from the current character, meaning the same as above 100l

:goto 25

Move to the 25th character from the beginning of the file

25 |

Move to the 25th character of the current line

Show current lines
command

description

:set number

:set nu

Display the number of lines

:set nonumber

:set nonu

Do not display the number of rows

:set numberwidth=10

The number of lines shows that the default width is 4 characters, which we can use to set it to 10 characters.

Jump to a specific line
Navigation key

description

:50

Jump to line 50 - method 1

50gg

Jump to line 50 - method 2

50G

Jump to line 50 - method 3

Source navigation
      The following are useful for system administrators who often write program source code or write shell scripts.

Navigation key

description

%

Jump to match pair, can be (), {} or []

[(

Jump to the previous one without matching (

[)

Jump to the previous one without matching)

[{

Jump to the previous one that does not match {

[}

Jump to the previous one without a match}

Move the cursor in the inserted state
      In the normal state, we can use w and W to move the cursor in word, but once we enter insert mode, we can't use these two navigation keys, but we don't need to exit insert mode, then use w navigation, we You can use the SHIFT+ arrow keys to move quickly. Use CTRL+O and CTRL+L to jump

      Vim will save all of our navigation operations to a list, we can use: jumps to view the list, and use the navigation keys below to jump.

CTRL+O

Jump to the previous record point
CTRL+i

Jump to the next record point

5CTRL+O

Jump to the first 5 of the current record point

5CTRL+i

Jump to the last 5 of the current record point

Navigate in a long line
      We know that every line of a general terminal will have a word limit. If the number of characters in a line exceeds this limit, it will automatically jump to the next line. For example, the actual line may look like 5 or 6 lines. When you use j, k, there is an illusion of jumping N lines. In this case, if in the visual case, jump to the next line (actually the same line), use the navigation key below.

Navigation key

description

Gj

The next line in the vision

Gk

Upper line in vision

g^

The beginning of the current visual line

g$

The end of the current visual line

Gm

In the middle of the current visual line

Vim command line navigation
      When we use vim to open the file, we can jump to the specified location according to our needs.

Command Line

description

Vim +143 <filename>

Open the file filename and jump to line 143

Vim +/search-term <filename>

Open the file filename and jump to the first eligible location from the beginning of the file

Vim +?search-term <filename>

Open the file filename and jump to the first eligible location starting at the end of the file

Vim –t TAG

Jump to a specific TAG

Create local bookmarks with tags
      There are two types of bookmarks, local bookmarks and global bookmarks, the difference is that the lowercase letters are used locally and the uppercase letters are used globally.

Bookmark command

description

Ma

Create a bookmark at the cursor position a

`a

Jump to the exact location of bookmark a

‘a

Jump to the beginning of the line where bookmark a is located

Create a global bookmark
      You can create a global bookmark A by changing ma to mA.

      This is mainly used when creating multiple files when we open multiple files, it is convenient to jump in each file. Show all bookmarks

You can use the command: marks to display all bookmarks. We will find out when all the bookmarks are opened, there will be ', ”, [,] and .. These are the default bookmarks, which have special meanings.

Default bookmark

description

`"

The last edited position before exiting

`[

The first character that was last modified or copied

`]

Last modified or copied last character

`<

The first line of the last visual area

`>

Last line of the last visual area

`.

Last modified location

`^

The position where the last insert mode was stopped

You can also use: marks a to display all the details about bookmark a. Use ctags to effectively jump in source code

1. Of course, you need to install the ctags package before using it.

2. In the source folder, use ctags *.c to generate a message tag file named tags.

3. Then vim main.c, enter: ta main to jump directly to the mian definition.

4. You can also use CTRL+] to jump to the definition of the function and use it to return to the original file with CTRL+T.

5. You can also use it: ta * and then press tab to facilitate the function you need to query;

Vim command

description

:ts

Show all tag tables

:tn

Jump to the next tag in the list

:tp

Jump to the previous tag in the list

:tf

Jump to the first tag in the list

:tl

Jump to the last tag in the list

Turn vim into a very attractive source browser
Install the taglish plugin. For details, please refer to installing the taglish article.

For example, open the file vim main.c, and then type: TlistOpen to list all the tag information;

Enter a specific function or variable to see more detailed information;

Of course, the tag window is also a vim session, we can return to the tag window by jumping to the next session method. Review of Vi mobile commands

mobile

command

Scroll forward a full screen

^F

Scroll back a full screen

^B

Scroll forward half screen

^D

Scroll back half screen

^U

Scroll forward one line

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.