13. Basic usage
<program name> <program flags> [ arg1, arg2, … ]
$ grep -n TODO MyProject.java
23: // TODO is there an off-by-one error here?
131: // TODO document this function
340: // TODO make this more efficient
$
28. Stream Redirection
● > $ grep TODO MyProject.java > todo.txt
$ ls
MyProject.java todo.txt
$
29. Stream Redirection
● > $ grep TODO MyProject.java > todo.txt
$ ls
MyProject.java todo.txt
$ cat todo.txt
// TODO make this better
// TODO delete these
$
30. Stream Redirection
● >
>>
$ grep TODO MyProject.java > todo.txt
$ ls
MyProject.java todo.txt
$ cat todo.txt
// TODO make this better
// TODO delete these
$
59. vim Modes
● Normal
o insert a new line beneath the cursor, move to it,
and enter insert mode
$ move to the end of the line and remain in
normal mode
i enter insert mode at the cursor’s current
position
I move to the beginning of the line and enter
insert mode
dd cut the current line
62. vim Modes
● Normal
● Insert
● Command
:w write the buffer to the disk
:q quit vim; will stop you if the file has changed
since the last write
:q! quit vim and discard changes since last write
:wq write the buffer and quit vim
:x same as :wq
:<some number>
move the cursor to line <some number>
65. Typical vim Workflow
$ vim some-file.txt
until you’ve made all the desired changes:
navigate through the file in normal mode
66. Typical vim Workflow
$ vim some-file.txt
until you’ve made all the desired changes:
navigate through the file in normal mode
bounce between normal and insert until part is fixed
67. Typical vim Workflow
$ vim some-file.txt
until you’ve made all the desired changes:
navigate through the file in normal mode
bounce between normal and insert until part is fixed
enter normal mode and write the file with “:w”
68. Typical vim Workflow
$ vim some-file.txt
until you’ve made all the desired changes:
navigate through the file in normal mode
bounce between normal and insert until part is fixed
enter normal mode and write the file with “:w”
enter normal mode
69. Typical vim Workflow
$ vim some-file.txt
until you’ve made all the desired changes:
navigate through the file in normal mode
bounce between normal and insert until part is fixed
enter normal mode and write the file with “:w”
enter normal mode
write the file and quit vim with “:wq” or “:x”
71. vim Visual Mode
x cut the highlighted text and save it to vim’s
clipboard
y copy the highlighted text and save it to vim’s
clipboard
p (in normal mode)
paste the text in vim’s clipboard into the buffer
after the cursor
P (in normal mode)
paste the text in vim’s clipboard into the buffer
before the cursor