Find and replace

To replace all foo with bar within the current buffer


To search in the working directory:

:Ack foo

Or, search in the specified path:

:Ack foo /path/to/dir

Now, the quickfix window shows up with every result found. Delete the undesired result by typing dd.

To replace every result still present in the quickfix window:

:Acks /foo/bar/

Automatically regenerate PDF after saving Latex file

We execute pdflatex [current-file] after we saved the current .tex file in Vim:

autocmd BufWritePost *.tex silent! execute "!pdflatex % >/dev/null 2>&1" | redraw!

Notice that it outputs files to the current working directory.