VIM
Generate a compilation database for YCM / ccls, ...
clang has built-in support for generating the compile_commands.json
Simply compile each file using the flag -MJ file.o.json
. E.g., when compiling
using a Makefile, add to the CFLAGS -MJ [email protected]
To coalesce all jsons file in a single compile_commands.json, use:
sed -e '1s/^/[\n/' -e '$s/,$/\n]/' output/**/*.o.json > compile_commands.json
Legacy:
bear
compiledb make ...
vimdiff
]c - advance to the next block with differences
[c - reverse search for the previous block with differences
do (diff obtain) - bring changes from the other file to the current file
dp (diff put) - send changes from the current file to the other file
zo - unfold/unhide text
zc - refold/rehide text
zr - unfold both files completely
zm - fold both files completely
Paste yanked into command mode
CTRL-r "
(CTRL-r will show ", pressing " will change " into the yanked value)
Save as sudo
:w !sudo tee %
Insert with Visual block mode ()
Use Shift+i
, type your stuff (will only edit one line),
Sroll keeping the cursor line on the same line
<C-e>
: scroll down
<C-y>
: scroll up
Jump to a tag
:ta TAG-NAME
(aka tag
): jump to a tag, same as CTRL-]
.
When there are many instances of the same tag and you need to pick one (e.g. function declaration and definition):
:ts TAG-NAME
(akatselect
):tj TAG-NAME
(akatjump
)g] TAG-NAME
Undoing to previous versions of a file unreachable with u and r
Pick a number from :undolist
, and undo with :undo {N}
.