came tutorial

http://www.cnblogs.com/threef/p/3349653.htmlBelieve






in the power of accumulation
Return to     homepageThreeF Blog     Garden     HomepageNew
EssayContact     ManagementSubscribeSubscribe     Essay -     351 Articles - 0 Comments - 0 vim tutorial ---Restore content start --- http://coolshell.cn/articles/5426.html The learning curve of vim is quite large (see the learning curve of various text editors), so if you see a lot of VIM at first Command classification, you will definitely lose interest in this editor. The following article is translated from "Learn Vim Progressively". I think this is the best VIM upgrade tutorial for beginners. It does not list all the commands, but only lists the most useful commands. very good. —————————Start of text ————————— Do you want to learn VIM, the best text editor in human history, at the fastest speed? You have to know how to survive VIM first, and then learn tricks bit by bit. Vim the Six Billion Dollar editor     Better, Stronger, Faster. Learn vim and it will be your last text editor. There is no better text editor than this one, very hard to learn, but incredibly easy to use.




























I suggest these four steps:

    Survive
    feel good
    feel better, be stronger, and
    use VIM's superpowers faster

When you finish this article, you'll be a vim superstar.

Before I start learning, I need to give you some warning:

    learning vim is painful at first.
    It takes time
    and constant practice, just like you learn an instrument.
    Don't expect you to be able to make vim more efficient than other editors in 3 days.
    In fact, you need 2 weeks of hard work, not 3 days.


Level 1 - live

    install vim
    start vim
    do nothing! PLEASE READ FIRST

When you've installed an editor, you're bound to want to type something into it, and see what the editor looks like. But vim is not like this, please follow the command below:

    After starting Vim, vim is in Normal mode.
    Let's enter Insert mode, press the key i. (Chen Hao's Note: You will see a word –insert- in the lower left corner of vim, which means that you can enter it in the way of insert)
    At this point, you can enter text, just like you use “Notepad”.
    If you want to return to Normal mode, press ESC.

Now, you know how to switch between Insert and Normal modes. Here are some commands that will allow you to survive Normal mode:

        i → Insert mode, press ESC to return to Normal mode.
        x → Delete a character at the current cursor position.
        :wq → save + exit (:w save, :q quit) (Chen Hao note: :w can be followed by file name)
        dd → delete the current line, and save the deleted line to the clipboard
        p → paste the clipboard

    recommendation :

        hjkl (strongly recommended to move the cursor, but not required) → you can also use the cursor keys (←↓↑→). Note: j is like the down arrow.
        :help <command> → Display help for the associated command. You can also just type :help without the command. (Chen Hao Note: You need to enter: q to exit the help)

You only need the above 5 commands to survive in vim, you can edit the text, you must practice these commands into a subconscious state. So you can start to progress to the second level.

When it is, when you get to the second level, you need to say something about Normal mode. In general editors, when you need to copy a piece of text, you need to use the Ctrl key, for example: Ctrl-C. That is to say, the Ctrl key is like a function key. When you press the function key Ctrl, C is no longer C, and it is a command or a shortcut key. In the Normal mode of VIM, all the The keys are function keys. This you need to know.

Mark:

    In the text below, if it is Ctrl-λ, I will write it as <C-λ>.
    Commands that start with : you need to type <enter>, for example - if I write :q that means you type :q<enter>.

Level 2 - feel good Those commands

above will only keep you alive, It's time to learn some more commands, here are my suggestions: (Chen Hao Note: All commands need to be used in Normal mode, if you don't know what mode you are in now, just press it a few times ESC key)

    various insert modes

            a → insert
            o after the cursor → insert a new line after the current line
            O → insert a new line before the current line
            cw → replace the character from the cursor position to the end of a word

    Simple movement Cursor

            0 → number zero, to the beginning of the line
            ^ → to the first position of the line that is not a blank character (the so-called blank character is space, tab, line feed, carriage return, etc.)
            $ → to the end of the line
            g_ → to the last of the line Not the position of the blank character.
            /pattern → search for the string of pattern (Chen Hao's note: if you find multiple matches, you can press the n key to go to the next one)

    copy/paste (Chen Hao's note: p/P can be used, p means after the current position, P means before the current position)

            P → paste
            yy → copy the current line to ddP

    Undo/Redo

            u → undo
            <Cr> → redo

    open/save/exit/change file (Buffer)

            :e <path/to/file> → open a file
            : w → save
            : saveas <path/to/file> → save as For <path/to/file>
            , ZZ or :wq → save and exit (:x means save only when needed, ZZ does not need to enter a colon and enter)
            :q! → exit without saving :qa! forcibly exit all The file being edited, even if other files have changed.
            :bn and :bp → You can have many files open at the same time, use these two commands to switch to the next or previous file. (Chen Hao Note: I like to use :n to go to the next file)

Take a moment to familiarize yourself with the above commands, once you get the hang of them, you can do almost anything other editors can do. But by now, you still feel that vim is a bit clumsy, but that's okay, you can progress to the third level.
Level 3 - Better, Stronger

, Congratulations! You did a great job. We can start something more interesting. At level 3, we only talk about commands that are compatible with vi. Better
Now, let's see how vim repeats itself:     . → (decimal point) can repeat the last command     N<command> → repeat a command N times






Bottom surface example, opening one sentence case 你 Can test Bottom command:

        2dd → ​​Exclusion 2 lines
        3p → Adhesive text book 3rd
        100idesu [ESC] → Under the meeting photo “desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu
        desu .
        3. → Heavy recovery 3rd “desu” (Caution: Unreasonable 300, 你 聠, VIM Cursor Akira 啊)

.

Jumping.

    NG → to the Nth line (Chen Hao Note: Note that the G in the command is capitalized, and I generally use: N to the Nth line, such as: 137 to the 137th line)
    gg → to the first line. (Chen Hao Note: Equivalent to 1G, or: 1)
    G → to the last line.
    Move by word:

            w → go to the beginning of the next word.
            e → to the end of the next word.

        > Use lowercase e and w if you think the word is by default. By default, a word consists of letters, numbers and underscores (Chen Hao Note: Program Variables)

        > If you think words are separated by blank characters, then you need to use uppercase E and W. (Chen Hao's note: program statement)

Next, let me talk about the strongest cursor movement:

        % : match the bracket movement, including (, {, [. (Chen Hao's note: you need to move the cursor to the bracket first)
        * and #: match the word the cursor is currently on, move the cursor to the next (or previous) matching word (* is the next, # is the previous)

believe me, the above three commands are quite powerful for programmers .faster You
must remember the movement of the cursor, because many commands can be linked to the commands that move the cursor. Many commands can be done as follows: <start position><command><end position> For example, the 0y$ command means write:     0 → go to line header     y first → start copying from here









    $ → Copy to the last character of the line

You can type ye to copy from the current position to the last character of the word.

You can also type y2/foo to copy the string between 2 "foo"s.

There is still a lot of time that you don't have to press y to copy, the following commands will also be copied:

    d (delete)
    v (visual selection)
    gU (uppercase)
    gu (lowercase)
    and so on

(Chen Hao ) Note: Visual selection is a very interesting command, you can first press v, then move the cursor, you will see the text is selected, then, you may d, or y, you can also capitalize, etc.)
Fourth level – Vim superpowers

You only need to master the previous commands, and you can use VIM comfortably. But, for now, we're introducing you to the killer feature of VIM. The following functions are the reasons why I only use vim.
Move the cursor on the current line: 0 ^ $ f F t T , ;

        0 → to the beginning of the line
        ^ → to the first non-blank character
        of the line $ → to the end of the line
        g_ → to the last non-blank character of the line.
        fa → go to the next character that is a, you can also fs to the next character that is s.
        t, → to the first character before the comma. Commas can become other characters.
        3fa → Find the third occurrence of a on the current line.
        F and T → same as f and t, but in opposite directions.

Another useful command is dt" → delete everything until double quotes - ".
Area selection <action>a<object> or <action>i<object>

In visual mode, these commands are very powerful, the command format is

<action>a<object> and <action>i<object>

    action can be any commands, such as d (delete), y (copy), v (can be selected depending on the mode).
    object may be: w a word, W a space-separated word, s a sentence, p a paragraph. Can also be a special character: ", ', ), }, ].

Suppose you have a string (map (+) ("foo")). And the cursor key is at the first o.

        vi" → would choose
        foo.va" → would choose "foo".
        vi) → would choose "foo".
        va) → would choose ("foo").
        v2i) → would choose map (+) ("foo")
        v2a) → will select (map (+) ("foo"))

block operations: <





    <Cd> → move down (you can also use hjkl to move the cursor, or use %, or something else)
    I-- [ESC] → I is insert, insert "--", press ESC key for each One line takes effect.

In vim under Windows, you need to use <Cq> instead of <Cv>, <Cv> is to copy the clipboard.
Auto-prompt: <Cn> and <Cp>

In Insert mode, you can enter the beginning of a word, then press <Cp> or <Cn>, the auto-completion function will appear...

Macro recording: qa Operation sequence q , @a, @@

    qa record your operation in register a.
    So @a will replay the recorded macro.
    @@ is a shortcut key to replay the latest recorded macro.

    Example

    In a text with only one line and only "1" in this line, type the following command:

        qaYp<Ca>q→
            qa start recording
            Yp copy line.
            <Ca> increment by 1.
            q stop recording.
        @a → write below 1 Next 2
        @@ → Write 3 on the front of 2
        Now doing 100@@ will create a new 100 rows and increase the data to 103.

Visual selection: v,V,<

Earlier, we saw an example of <Cv> (which should be <Cq> under Windows), and we can use v and V. Once selected, you can do the following:

    J → Concatenate all lines (into one line)
    < or > → Indent left and right
    = → Automatically indent (Chen Hao Note: This function is quite powerful, I like it so much)

Add something after all the selected lines:

    <Cv>
    select the relevant line (you can use j or <Cd> or /pattern or % etc...)
    $ to the end of the line
    A, enter string, press ESC.

Split screen: :split and vsplit.

The following are the main commands, you can use the help of VIM :help split. You can refer to a previous article on this site VIM split screen.

        :split → create a split screen (:vsplit creates a vertical split screen)
        <Cw><dir> : dir is the direction, which can be one of hjkl or ←↓↑→, which is used to switch the split screen.
        <Cw>_ (or <Cw>|) : maximize size (<Cw>| vertical split)
        <Cw>+ (or <Cw>-) :

Increase the size Conclusion

    Above is the author's most commonly used 90% of the commands.
    I recommend that you learn 1 or 2 new commands every day.
    After two to three weeks, you will feel vim powerful.

    Sometimes learning VIM is like memorizing something.
    Fortunately, vim has a lot of nice tools and excellent documentation.
    Run vimtutor until you are familiar with the basic commands.
    The online help document you should read carefully is: help usr_02.txt.
    You will learn many other functions such as !, directories, registers, plugins, etc.

Learning vim is like learning to play the piano. Once you learn it, you will benefit greatly.

—————————End of text ———————————

Just a comment about vi/vim: this is a place where you don’t need to use a mouse, no small keyboard, just a large keyboard An editor that can complete text editing with many complex functions. Otherwise, there will be no vim plugin for Visual Studio.

(End of full text)

---End of restoration content---
Tags: vim
good article to top, follow me, favorite this article
ThreeF follow-
1
follower- 2
+ plus follow
0
0
« Previous:windows,makefile,nmake
» Next : qt,script
posted @ 2013-10-02 20:55 ThreeF Reads (342) Comments (0) Edit Favorites
Refresh the comments and refresh the page back to the top
Registered users can only post comments after logging in. Please login or register to visit the homepage of the website.
[Recommended] 500,000 lines of VC++ source code: large-scale configuration industrial control, power simulation CAD and GIS source code library
[Free] Learn programming from scratch, and the developer's exclusive experimental platform is free to practice!
Udacity_0706
Latest IT News:
· TrackID, the most classic software of Sony Ericsson mobile phone, was completely abandoned
· How similar is it? iPhone 7P/OPPO R9s/R11 Comparison Chart Tour
· No one wants it for free! Windows 10 is not as good as XP
. The most important update after the official release of Linux kernel 4.12 version 4.9
. Henan Mobile pushes the exclusive data package of "King of Glory" for 6 yuan and 1GB
» More news...
Aurora Promotion_0701 The
latest knowledge base article:
The story of the little printf: what is a real programmer?
· The work, study and performance of programmers
· Why is software development difficult
· Let's sing the implementation of DevOps, the interpretation of the model technology of microservice CI/CD
· How do programmers go from mediocrity to ideal?
» More Knowledge Base Articles ... Believe

in the Power of Accumulation 29 30 1








2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5SearchCommon
    LinksMy     EssaysMy     CommentsMy     EngagementsLatest     CommentsMe Tags for     more links My tags     python(67)     algorithm(39)     English(38)     The Da Vinci Code(36)     Linux(33)     cs(23)     qt(17)     windows(17)     Acm(12)     c++(12 )     More Essay Archives     March 2014 (2)     February 2014 (12)     January 2014 (19)     November 2013 (1)     October 2013 (33)
































    2013年9月 (47)
    2013年8月 (48)
    2013年7月 (67)
    2013年6月 (102)
    2013年4月 (12)
    2013年3月 (8)

algorithm

    taocp mix simulator

c++

cs

    c# msdn tutorial
    C# voidrealms tutorial

ds

    list of data structures

git

    git document

java

perl

PySide

    pyside tutorial (zetcode)
    Python-Qt building tutorial

python

    Learn Python The Hard Way
    python offical site
    vamei

unix

vim

    vim keyboard
    vim offical site
    vim script ibm tutorial

windows     windows api tutorial     (

    zetcode     )

reading     leaderboard Language comparison(1043)     5. git merge(865)     6. python, flask, web, login(804)     7. python, file, os, shutil(774)     8. Qt, QObject(693)     9. python, regex( 590)     10. windows, makefile, nmake(584)     11. python, iterator, generator(570)     12. python, pickle, serialize(546)     13. python, decorator(514)     14. Qt, QEvent(460)     15. python,keyword arguments(458)
















    16. python,xml,dom,tree,parser,soup,beautiful soup(455)
    17. Java,Hashtable(410)
    18. python,ctypes(406)
    19. vs2012,vim,_vsvimrc(393)
    20. c++11,rvalue reference(387)
    21. python,cron,gae,bae(368)
    22. python,mysql,sql,mysqldb(357)
    23. python,gc(347)
    24. python,re,regex,中文文档(346)
    25. vim tutorial(342)
    26. python,HTMLParser,html,parser(339)
    27. python,xml,ELement Tree(338)
    28. Python Extension Programming with C(313)
    29. git tutorial(311)
    30. python,flask,login,login_request(307)
    31. signal and slot in pyside(297)
    32. English,all(290)
    33. Vim,Delete all lines containing a pattern(251)
    34. css,selector(249)
    35. python,build in functions(246)
    36. English,The Da Vinci Code,Chapter 1-3(240)
    37. python,web,webapp2,feature(238)
    38. python,deep copy,shallow copy(234)
    39. Windows,MSDN,Console Input Buffer(233)
    40. lex and yacc tutorial(231)

Copyright ©2017 ThreeF

相信积累的力量

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326335472&siteId=291194637