Showing posts with label vim. Show all posts
Showing posts with label vim. Show all posts

[Vimdiff] cheat sheet

Sometimes I prefer using vimdiff especially when using it as a mergetool.  mattratleph has a handy cheatsheet.

git mergetool

In the middle file (future merged file), you can navigate between conflicts with ]c and [c.
Choose which version you want to keep with :diffget //2 or :diffget //3 (the //2 and //3 are unique identifiers for the target/master copy and the merge/branch copy file names).

:diffupdate (to remove leftover spacing issues)
:only (once you’re done reviewing all conflicts, this shows only the middle/merged file)
:wq (save and quit)
git add .
git commit -m “Merge resolved”

If you were trying to do a git pull when you ran into merge conflicts, type git rebase –continue.

vimdiff commands

]c :        - next difference
[c :        - previous difference
do          - diff obtain
dp          - diff put
zo          - open folded text
zc          - close folded text
:diffupdate - re-scan the files for differences
 

more vim

Useful stuff to put inside your ~/.vimrc file

" Set tab width
set tabstop=4
set softtabstop=4
set shiftwidth=4
set smarttab
set smartindent
set expandtab
set cursorline

" Show line numbers and cursor position
set ruler
set number

" Disable default splash screen
set shortmess+=I
set guioptions-=T

" Show tabs and trailing white spaces
set list listchars=tab:-»,trail:·,extends:»

" Don't generate backup files
set nobackup

" Set default color scheme to something
colorscheme something


If you don't have it, create a folder ~/.vim/colors and put the color scheme inside.

Color schemes are available here

emacs lightweight options and vim

I use emacs all of the time. However, the problem with emacs is that it is very heavy duty and usually not available on embedded targets.

Zile and mg and two light-weight options for emacs (sudo apt-get install mg zile )

Also, it is good to know how to use vim

Quick starter

Open file [Esc first] :e
Save & Exit - [Esc first] :wq
Save - [Esc first]:w
Don't save & Exit - [Esc first]:!q

Up - [Esc first] k or Up arrow
down - [Esc first] j or Down arrow
left - [Esc first] h or Left arrow
right - [Esc first] l or right arrow
start of line - [Esc first] ^
end of line - [Esc first] $
page up - cntrl+b
page down - cntrl+f
Goto line x - xG

undo - [Esc first] u
redo - [Esc First] Shift+r
delete char - [Esc First] x
delete word - [Esc First] dw
delete line - [Esc First] dd

search - [Esc first] /
next - n
prev - Shift+n

help - [Esc first]:help
or start from command line
$ vimtutor