Vim: Implement `[ and `]

Created on 5 Sep 2017  路  3Comments  路  Source: VSCodeVim/Vim

  • Click thumbs-up 馃憤 on this issue if you want it!
  • Click confused 馃槙 on this issue if not having it makes VSCodeVim unusable.

The VSCodeVim team prioritizes issues based on reaction count.


Opening an issue to gather support for the `[ and `] motions which respectively go to the start or end of the previously operated or put text.

I find myself using these in vim a lot, for example after pasting in a bunch of text, I can use =`[ to reindent the block of text that I just pasted in.

help wanted kinfeature

Most helpful comment

Used this mapping a lot:

" Quickly select text you just pasted
noremap gV `[v`]

All 3 comments

Used this mapping a lot:

" Quickly select text you just pasted
noremap gV `[v`]

Implementing this would be valuable ... after yanking in visual mode the cursor moves to the top of the block when often you are looking to paste it right after that block that was just copied. The `] allows you to move to the end of that last visual block much closer to where one typically wants to paste.

I also think this is a useful VIM feature that would be great to have in VSCode Vim! Wonder how difficult it would be to implement. Perhaps an easy first PR could just handle putting text?

Pasting the docs from VIM as a sort of spec for this feature:

                                                        *'[* *`[*
'[  `[                  To the first character of the previously changed
                        or yanked text.  {not in Vi}

                                                        *']* *`]*
']  `]                  To the last character of the previously changed or
                        yanked text.  {not in Vi}

After executing an operator the Cursor is put at the beginning of the text
that was operated upon.  After a put command ("p" or "P") the cursor is
sometimes placed at the first inserted line and sometimes on the last inserted
character.  The four commands above put the cursor at either end.  Example:
After yanking 10 lines you want to go to the last one of them: "10Y']".  After
inserting several lines with the "p" command you want to jump to the lowest
inserted line: "p']".  This also works for text that has been inserted.

Note: After deleting text, the start and end positions are the same, except
when using blockwise Visual mode.  These commands do not work when no change
was made yet in the current file.
Was this page helpful?
0 / 5 - 0 ratings

Related issues

st-schneider picture st-schneider  路  3Comments

ACollectionOfAtoms picture ACollectionOfAtoms  路  3Comments

jaredly picture jaredly  路  3Comments

liamdawson picture liamdawson  路  3Comments

orn688 picture orn688  路  3Comments