Share to EffectHub.com

You can earn money or coins from your share:)

Tips: you can use Sparticle for uploading away3D effects.

Tips: you can download Sparticle for uploading effects.

Tips: The ActionScript editor is supporting Away3D, Starling, Dragonbones and Flex frameworks.

Tips: paste the web page URL then click button:)

EffectHub.com: Your Best Source for Gaming
Login    or

Learn Vim Progressively (3)

4th Level – Vim Superpowers

With all preceding commands you should be comfortable using vim. But now, here are the killer features. Some of these features were the reason I started to use vim.

Move on current line: 0 ^ $ g_ f F t T , ;

  • 0 → go to column 0

  • ^ → go to first character on the line

  • $ → go to the last column

  • g_ → go to the last character on the line

  • fa → go to next occurrence of the letter a on the line. ,(resp. ;) will find the next (resp. previous) occurrence.

  • t, → go to just before the character ,.

  • 3fa → find the 3rd occurrence of a on this line.

  • F and T → like f and t but backward.

    Line moves

A useful tip is: dt" → remove everything until the ".

Zone selection <action>a<object> or<action>i<object>

These command can only be used after an operator in visual mode. But they are very powerful. Their main pattern is:

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

Where action can be any action, for example, d (delete), y (yank), v(select in visual mode). The object can be: w a word, W a WORD (extended word), s a sentence, p a paragraph. But also, natural character such as "')}].

Suppose the cursor is on the first o of (map (+) ("foo")).

  • vi" → will select foo.

  • va" → will select "foo".

  • vi) → will select "foo".

  • va) → will select ("foo").

  • v2i) → will select map (+) ("foo")

  • v2a) → will select (map (+) ("foo"))

Text objects selection

Select rectangular blocks: <C-v>.

Rectangular blocks are very useful for commenting many lines of code. Typically: 0<C-v><C-d>I-- [ESC]

  • ^ → go to the first non-blank character of the line

  • <C-v> → Start block selection

  • <C-d> → move down (could also be jjj or %, etc…)

  • I-- [ESC] → write -- to comment each line

Rectangular blocks

Note: in Windows you might have to use <C-q> instead of <C-v> if your clipboard is not empty.

Completion: <C-n> and <C-p>.

In Insert mode, just type the start of a word, then type <C-p>, magic…

Completion

Macros : qa do something q@a@@

qa record your actions in the register a. Then @a will replay the macro saved into the register a as if you typed it. @@ is a shortcut to replay the last executed macro.

Example

On a line containing only the number 1, type this:

  • qaYp<C-a>q →

    • qa start recording.

    • Yp duplicate this line.

    • <C-a> increment the number.

    • q stop recording.

  • @a → write 2 under the 1

  • @@ → write 3 under the 2

  • Now do 100@@ will create a list of increasing numbers until 103.

Macros

Visual selection: v,V,<C-v>

We saw an example with <C-v>. There is also v and V. Once the selection has been made, you can:

  • J → join all the lines together.

  • < (resp. >) → indent to the left (resp. to the right).

  • = → auto indent

Autoindent

Add something at the end of all visually selected lines:

  • <C-v>

  • go to desired line (jjj or <C-d> or /pattern or % etc…)

  • $ go to the end of the line

  • A, write text, ESC.

Append to many lines

Splits: :split and vsplit.

These are the most important commands, but you should look at :help split.

  • :split → create a split (:vsplit create a vertical split)

  • <C-w><dir> : where dir is any of hjkl or ←↓↑→ to change the split.

  • <C-w>_ (resp. <C-w>|) : maximise the size of the split (resp. vertical split)

  • <C-w>+ (resp. <C-w>-) : Grow (resp. shrink) split

Split

Conclusion

That was 90% of the commands I use every day. I suggest that you learn no more than one or two new commands per day. After two to three weeks you’ll start to feel the power of vim in your hands.

Learning Vim is more a matter of training than plain memorization. Fortunately vim comes with some very good tools and excellent documentation. Run vimtutor until you are familiar with most basic commands. Also, you should read this page carefully: :help usr_02.txt.

Then, you will learn about !, folds, registers, plugins and many other features. Learn vim like you’d learn piano and all should be fine.


...

You must Sign up as a member of Effecthub to view the content.

1401 views    2 comments

You must Sign up as a member of Effecthub to join the conversation.

Chenzhi Wu

A PHP Error was encountered

Severity: Notice

Message: Undefined index: HTTP_ACCEPT_LANGUAGE

Filename: helpers/time_helper.php

Line Number: 22

2013-09-06
>>Back to TextEditor group


Latest Posts


Sponsor


They are waiting for your help



Share

Join Effecthub.com


Or Login with Your Email Address:

Or Sign Up with Your Email Address:
This field must contain a valid email
Password should be at least 1 character

A PHP Error was encountered

Severity: Notice

Message: Undefined index: HTTP_ACCEPT_LANGUAGE

Filename: views/footer.php

Line Number: 6

A PHP Error was encountered

Severity: Notice

Message: Undefined index: HTTP_ACCEPT_LANGUAGE

Filename: controllers/topic.php

Line Number: 21

A PHP Error was encountered

Severity: Notice

Message: Undefined index: HTTP_ACCEPT_LANGUAGE

Filename: controllers/topic.php

Line Number: 85