To set up a new computer, use some subset of the following:
apt-get install -y git cd ~ git clone https://github.com/philips/ghar.git export PATH=$PATH:`pwd`/ghar/bin/ cd ghar git clone https://github.com/stroxler/config.git cd ~ rm .bashrc ghar install ghar install --status ~/setup_vim.sh
The ghar install does not define your .bashrc, because it's a good place to put machine-specific environment variables and aliases. So you need to add the following line:
source $HOME/bash-source.sh
NOTE: the instructions above are a bit out of date; ghar was never updated for python3, so I wrote a small haskell tool that does something similar. You can check out how I currently do the setup in https://github.com/stroxler/confar-v0
A few vim notes, nowhere near complete.
The command to copy (t) or move (m) lines of text:
:[range]{t, m}[address]
For example:
:10t20
insert copy of line 10 on a new line after line 20:10m20
move line 10 to a new line after line 20:10t.
insert copy of line 10 on a new line after current line:10,13t20
insert copy of lines 10-13 on new lines after line 204:t$
insert copy of next 4 lines at end of file4:t0
insert copy of next 4 lines at top of file:t14
insert copy of current line after line 14
"A command using a motion, e.g., cw
, operates from the current cursor
position. A command using a text-object, e.g., ciw
operates on the whole
object regardless of the cursor position."
Text object commands have the form:
{command} {extent} {object}
where:
command | c (change), d (delete), v (select), y (yank), etc |
extent | i (inner), a (include enclosing quotes, parentheses, etc) |
object | w (word), s (sentence), p (paragraph), " , ) , etc
i is a new one, added by the indent-object plugin. |
Examples:
diw
delete current wordvaw
select current word plus trailing whitespace on one side of wordvip
select current paragraphvis
select current sentence (or block of code!)ci)
change everything between enclosing parentheses (or use"
,'
,]
, etc)ca)
same as above but include parentheses>ip
indent inner paragraph
Many text object commands have motion command equivalents. For example viw
is the same as bve
(or ve
if the cursor is already on the first
character of the word).
When using a command like ci"
the cursor does not have to be between the
quotes. It will change the text of the next quoted string on the current line.
I use a vim plugin to make indent objects that can be used to select text at
the current indentation level or higher. It is useful for treating Python code
in a if or for loop as a text object. For example, the command cii
changes all code that is indented as much as the current line or more.
<C-t>
insert one shiftwidth of indent at the start of current line<C-d>
delete one shiftwidth of indent at the start of current line<C-w>
delete word to the left of cursor (same as bash)<C-u>
delete back to start of line (same as bash)<C-r>0
paste yank register<C-r>"
paste unnamed register<C-r>=6*35<CR>
inserts 210
v/foo
select from cursor to "foo" (n
for next;v?foo
backwards)ev2B
select current WORD and previous word^2X
move current line two spaces left[n]H
move cursor to nth line of screenM
move cursor to middle line of screen[n]L
move cursor to nth line from bottom of screenzz
center screen on cursorgv
select last visual selection, enter visual modegp
,gP
same asp
,P
but leaves cursor at end1$
,2$
end of current, next line, etc.
:s/^/ /
move current line two spaces right:7pu
put yanked text on new line after line 7:7pu!
put yanked text on new line before line 74:
shorthand for range:.,.+3
<C-w>
delete word to the left of cursor (same as bash)<C-u>
delete back to start of line (same as bash)
gv
highlight last visual selection (useful b/c commands leave visual)o
go to other end of highlighted textu
,U
change selection to lower, upper caseI
,A
insert at start, end of selection (i
,a
don't work)p
replaces selection
""
unnamed, used byc
,d
,y
,x
,s
, etc."0
yank"-
deleted or changed text less than one line"+
system clipboard"*
last system-selected text".
last inserted text"{1-9}
most recent"1
, second most recent"2
, etc. delete
From 'Practical Vim' by Drew Neil:
``
position before the last jump within current file`.
location of last change`^
location of last insert`[
,`]
start, end of last change or yank`<
,`>
start, end of last visual selection
If you read this far then you wasted your time. You should have been reading 'Practical Vim' by Drew Neil.
<C-b>
,<C-f>
move backward, forward one character<C-a>
,<C-e>
go to start, end of line<M-b>
,<M-f>
move backward, forward one word (whitespace defined)<C-u>
,<C-k>
delete from cursor to beginning, end of line<C-w>
,<M-d>
delete from cursor to previous, next whitespace<C-y>
paste previous deletion<C-t>
,<M-t>
swap current character, word with previous