aboutsummaryrefslogtreecommitdiff
path: root/posts/get_better_at_yanking_and_putting_in_vim.md
blob: 44f54f48ba094120f37e27f0a343b40c4954e12d (plain)
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
a couple of nifty tricks to help you copy-paste better:

1. reselecting previously selected text (i use this to fix botched selections):

    ```
    gv  " :h gv for more
        " you can use `o` in visual mode to go to the `Other` end of the selection
        " use a motion to fix the selection
    ```

2. reselecting previously yanked text:

    ```
    `[v`]
    `[         " marks the beginning of the previously yanked text   :h `[
    `]         " marks the end                                       :h `]
     v         " visual select everything in between

    nnoremap gb `[v`]    " "a quick map to perform the above
    ```

3. pasting and indenting text (in one go):

    ```
    ]p   " put (p) and adjust indent to current line
    ]P   " put the text before the cursor (P) and adjust indent to current line
    ```