vim.md 1.2 KB

Vim

Jovian cheat sheet for vim

Commands

Bookmark

mx to bookmark with letter x

`x 

to go to x

Case

gu and movement to lowercase

gU and movement to uppercase

Write with SUDO

On the fly fix

when you forgot to sudo with Vim ...

:w !sudo tee %

Beware, that is not recommanded to run a editor as Vim.

The right way

Use sudoedit

Regex

End of line

Catch with \n and put one with \r.

Diff

vimdiff basics

Configure git

git config --global diff.tool vimdiff git config --global merge.tool vimdiff

Trigger conflict resolution

git mergetool

Make contents identical

dp : diffput throws changement in the other window

do : diffget obtains changements from the other window

Jump between diffs

]c next

[c previous

Resolving a conflict

Three files : LOCAL | BASE | REMOTE

+--------------------------------+
| LOCAL  |     BASE     | REMOTE |
+--------------------------------+
|             MERGED             |
+--------------------------------+

Three commands : :diffget LO, :diffget BO, :diffget RE

Unfold

zo

Useful to see more context.