This chapter we learn the automatic completion function
1. Auto-Complete priority gets the complete list from the current edit area
For example:
Let's write down the following:
Aaaaaaabbbaaab
When we enter AA again, and then we press TAB, a list containing aaaaa aabbb Aaab is popped up.
Conditions for triggering the completion mode
1. In the Insert mode
Meanwhile, ctrl+p Ctrl + N also moves up and down to select the complement list item
There are other methods of completion, as follows
These methods are all started with Ctrl + X, followed by the complement style you want
1. <c-n>- Common keyword 2. <c-x><c-n>- Current buffer 3.<c-x> <c-i>- contains the file keyword 4. <c-x><c-]>- Tag file keyword 5. <c-x><c-k >- Dictionary lookup 6. <c-x><c-l>-Complete Line Completion
For line completion
For example, let's do the following
1. Automatic (this time we do <c-x><c-l> operation, will be automatically complete for "This chapter we learn auto-complete function")
7. <c-x><c-f>- file name completion 8. <c-x><c-o>-All-round complement
When we pop up the list, what can we do with the AutoComplete list?
1. <c-n>- matches the next 2. <c-p>- matches the previous 3. <c-y>- confirm that the current match is used (previously you want to use the ENTER key to achieve the selection, has not been successful, although selected, it will be wrapped) 4. <c-e>- exit complete list 5. <c-h>-reduces one character from the current match (for example, the current input is AA, the complement list cursor is on AABBB, you use <c-h > , the input will become AABB)6. <c-l>-adds a character from the current match (for example, the current input is AA, the complement list cursor is on the AABBB, you use <c-h> , the input will become AaB)7. {char}-inserts the character followed by the complete list item at the time of the cursor, terminating the completion
There is a small trick, that is, we use the completion of the time, as far as possible through the <c-n> to pull up the complete list, and then we pressed the <C-P>, when the cursor is in the list of 0 lines, we add or reduce the character >, the list will be automatically reduced or added
Auto-complete function of vim basic learning