105

GitHub - joereynolds/place.vim: Enter pieces of text without moving

 6 years ago
source link: https://github.com/joereynolds/place.vim
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

place.vim

place.vim allows you to add insertions to your text without moving your cursor. If you suffer from the following problems, this plugin might be for you:

  • Forgotten to add a ';' at the end of a line.
  • Forgotten var, let, $ or any other variant at the beginning of a line.
  • Wanted to insert some text without having to enter insert mode, move to the place, leave insert mode, and go back

68747470733a2f2f692e696d6775722e636f6d2f4e3372634455692e676966

Mapping

Add a mapping of your choice to get place.vim working for you.

Example:

nmap ga <Plug>(place-insert)
nmap gb <Plug>(place-insert-multiple)

Examples

(Examples are using ga as the prefix key but it can be anything you want)

place.vim works in the 'vim' way. Here are a few examples of what it does

| denotes cursor position

function(na|me, $age)
gab$

Results in

function($name, $age)
$thi|s->doSomeStuff = 5
ga$;

Results in

$this->doSomeStuff = 5;

It also supports multiple line motions

This
is
a
really long
line
gaG.

Results in

This
is
a
really long
line.

A more complex motion (t)

T|his is Y sentence
gatYM

Results in

This is MY sentence

I want to enter 'var' or 'let' like you said I could in the README!

Sure thing, there's a separate mapping <Plug>(place-insert-multiple) to map to. Read the docs.

Now, when you finish your motion, an input box will appear with what you want to insert.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK