--- /dev/null
+\documentclass[aspectratio=169]{beamer}
+
+\usepackage{xltxtra}
+\defaultfontfeatures{Ligatures=TeX,Mapping=tex-text}
+\usepackage[russian]{babel}
+\usepackage[utf8]{inputenc}
+\usepackage[normalem]{ulem} % для \sout
+
+
+%\usepackage{tikz} % FIXME не уверен что все это тут надо
+%\usetikzlibrary{chains}
+
+ % Цвета для гиперссылок
+ \definecolor{linkcolor}{HTML}{799B03} % цвет ссылок
+ \definecolor{urlcolor}{HTML}{6633FF} % цвет гиперссылок
+
+ \hypersetup{pdfstartview=FitH, linkcolor=linkcolor,urlcolor=urlcolor, colorlinks=true}
+
+\title{Git and vim for PostgreSQL developers}
+\author{Nikolay Shaplov}
+
+\makeatletter
+% Добавляем подпапку к пути поиска .sty/.tex
+\def\input@path{{./theme.nonfree}}
+\makeatother
+
+
+\usetheme{PgPro}
+\input{elements/code.tex}
+
+\begin{document}
+
+\begin{frame}
+\titlepage
+\end{frame}
+
+% FIXME introduction page
+
+% FIXME QR-code link to slides
+
+
+\begin{frame}{General topic}
+
+ If you want to write well, you should read a lot.
+ And you'd better read best samples you can find.
+
+ PostgreSQL is one of the finest C\text{-}driven project one can get.
+
+ In this talk we will learn how to use git and vim to read and explore PostgreSQL code right in the console.
+
+\end{frame}
+
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+{\setbeamertemplate{background}{
+ \begin{tikzpicture}
+ \node[anchor=south west, inner sep=0] at (0,0) {\includegraphics[width=\the\paperwidth, height=\the\paperheight]{theme.nonfree/bgpics/pgpro_title_bg2.png}};
+ \node[anchor=east] at(\textwidth+1cm,0.5cm) {\color{white}\tiny\insertframenumber};
+ \end{tikzpicture}
+ }
+ \setbeamercolor{normal text}{fg=white}\usebeamercolor*{normal text}
+ \setbeamerfont{normal text}{size*={32pt}{1},family=\sffamily}\usebeamerfont*{normal text}
+ \begin{frame}
+ \vskip1cm
+ Git
+ \end{frame}
+}
+
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\begin{frame}[fragile, shrink=10]{Git, fetching the source code}
+
+ In order to get latest snapshot of PostgreSQL code you should run command:
+
+ \begin{lstlisting}[linewidth=0.9\textwidth, literate={\$}{{\textdollar}}1]
+$ git clone https://git.postgresql.org/git/postgresql.git \end{lstlisting}
+
+If that command does not work for you, may be you just need to install `git` package
+
+ \begin{lstlisting}[linewidth=0.9\textwidth, literate={\$}{{\textdollar}}1]
+$ sudo apt-get install git\end{lstlisting}
+
+\end{frame}
+
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+{\setbeamertemplate{background}{
+ \begin{tikzpicture}
+ \node[anchor=south west, inner sep=0] at (0,0) {\includegraphics[width=\the\paperwidth, height=\the\paperheight]{theme.nonfree/bgpics/pgpro_title_bg2.png}};
+ \node[anchor=east] at(\textwidth+1cm,0.5cm) {\color{white}\tiny\insertframenumber};
+ \end{tikzpicture}
+ }
+ \setbeamercolor{normal text}{fg=white}\usebeamercolor*{normal text}
+ \setbeamerfont{normal text}{size*={32pt}{1},family=\sffamily}\usebeamerfont*{normal text}
+ \begin{frame}
+ \vskip1cm
+ Vim
+ \end{frame}
+}
+
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+\begin{frame}[fragile, shrink=10]{Why vim?}
+ \begin{itemize}
+ \item Masterclass is when expert shows how he works. And I work with vim
+ \item We will need complex navigation methods to browse the code, that is not provided by simple editors
+ \item If you work with the console, you are much closer to system level than in modern IDE
+ \item You may consider this as an excursion into history
+ \item Vim is actually a professional tool providing very high speed of coding
+ \item Most students find vim very useful as soon as they learn how to do basic things
+ \end{itemize}
+\end{frame}
+
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+{\setbeamertemplate{background}{
+ \begin{tikzpicture}
+ \node[anchor=south west, inner sep=0] at (0,0) {\includegraphics[width=\the\paperwidth, height=\the\paperheight]{theme.nonfree/bgpics/pgpro_title_bg2.png}};
+ \node[anchor=east] at(\textwidth+1cm,0.5cm) {\color{white}\tiny\insertframenumber};
+ \end{tikzpicture}
+ }
+ \setbeamercolor{normal text}{fg=white}\usebeamercolor*{normal text}
+ \setbeamerfont{normal text}{size*={32pt}{1},family=\sffamily}\usebeamerfont*{normal text}
+ \begin{frame}
+ \vskip1cm
+ Vim myths
+ \end{frame}
+}
+
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\begin{frame}[fragile, shrink=10]{Vim myths}
+ \begin{itemize}
+ \item There are two main modes in vim:
+ \begin{itemize}
+ \item Beep
+ \item Mess everything up
+ \end{itemize}
+ \end{itemize}
+% \emph{~~~ No, this is one mode}
+% \begin{itemize}
+% \item \sout{You can't quit vim}
+% \end{itemize}
+% \emph{~~~ No. Vim is \underline{not} Hotel California.}
+
+% \emph{~~~ I may assure you, you will be expert in quitting vim when these talks are finished.}
+% \begin{itemize}
+% \item \sout{One need MIDI Foot Controller Pedal to properly work with vim}
+% \end{itemize}
+
+% \emph{~~~ No. MIDI Foot Pedal is for Emacs users only}
+\end{frame}
+
+
+\begin{frame}[fragile, shrink=10]{Vim myths}
+ \begin{itemize}
+ \item \sout{There are two main modes in vim:}
+ \begin{itemize}
+ \item \sout{Beep}
+ \item \sout{Mess everything up}
+ \end{itemize}
+ \end{itemize}
+ \emph{~~~ No, this is one mode}
+% \begin{itemize}
+% \item \sout{You can't quit vim}
+% \end{itemize}
+% \emph{~~~ No. Vim is \underline{not} Hotel California.}
+
+% \emph{~~~ I may assure you, you will be expert in quitting vim when these talks are finished.}
+% \begin{itemize}
+% \item \sout{One need MIDI Foot Controller Pedal to properly work with vim}
+% \end{itemize}
+
+% \emph{~~~ No. MIDI Foot Pedal is for Emacs users only}
+\end{frame}
+
+
+\begin{frame}[fragile, shrink=10]{Vim myths}
+ \begin{itemize}
+ \item \sout{There are two main modes in vim:}
+ \begin{itemize}
+ \item \sout{Beep}
+ \item \sout{Mess everything up}
+ \end{itemize}
+ \end{itemize}
+ \emph{~~~ No, this is one mode}
+ \begin{itemize}
+ \item You can't quit vim
+ \end{itemize}
+% \emph{~~~ No. Vim is \underline{not} Hotel California.}
+
+% \emph{~~~ I may assure you, you will be expert in quitting vim when these talks are finished.}
+% \begin{itemize}
+% \item \sout{One need MIDI Foot Controller Pedal to properly work with vim}
+% \end{itemize}
+% \emph{~~~ No. MIDI Foot Pedal is for Emacs users only}
+\end{frame}
+
+
+
+\begin{frame}[fragile, shrink=10]{Vim myths}
+ \begin{itemize}
+ \item \sout{There are two main modes in vim:}
+ \begin{itemize}
+ \item \sout{Beep}
+ \item \sout{Mess everything up}
+ \end{itemize}
+ \end{itemize}
+ \emph{~~~ No, this is one mode}
+ \begin{itemize}
+ \item \sout{You can't quit vim}
+ \end{itemize}
+ \emph{~~~ No. Vim is \underline{not} Hotel California.}
+
+% \emph{~~~ I may assure you, you will be expert in quitting vim when these talks are finished.}
+% \begin{itemize}
+% \item \sout{One need MIDI Foot Controller Pedal to properly work with vim}
+% \end{itemize}
+% \emph{~~~ No. MIDI Foot Pedal is for Emacs users only}
+\end{frame}
+
+
+\begin{frame}[fragile, shrink=10]{Vim myths}
+ \begin{itemize}
+ \item \sout{There are two main modes in vim:}
+ \begin{itemize}
+ \item \sout{Beep}
+ \item \sout{Mess everything up}
+ \end{itemize}
+ \end{itemize}
+ \emph{~~~ No, this is one mode}
+ \begin{itemize}
+ \item \sout{You can't quit vim}
+ \end{itemize}
+ \emph{~~~ No. Vim is \underline{not} Hotel California.}
+
+ \emph{~~~ I may assure you, you will be expert in quitting vim when these talks are finished.}
+% \begin{itemize}
+% \item \sout{One need MIDI Foot Controller Pedal to properly work with vim}
+% \end{itemize}
+% \emph{~~~ No. MIDI Foot Pedal is for Emacs users only}
+\end{frame}
+
+\begin{frame}[fragile, shrink=10]{Vim myths}
+ \begin{itemize}
+ \item \sout{There are two main modes in vim:}
+ \begin{itemize}
+ \item \sout{Beep}
+ \item \sout{Mess everything up}
+ \end{itemize}
+ \end{itemize}
+ \emph{~~~ No, this is one mode}
+ \begin{itemize}
+ \item \sout{You can't quit vim}
+ \end{itemize}
+ \emph{~~~ No. Vim is \underline{not} Hotel California.}
+
+ \emph{~~~ I may assure you, you will be expert in quitting vim when these talks are finished.}
+ \begin{itemize}
+ \item One need MIDI Foot Controller Pedal to properly work with vim
+ \end{itemize}
+% \emph{~~~ No. MIDI Foot Pedal is for Emacs users only}
+\end{frame}
+
+\begin{frame}[fragile, shrink=10]{Vim myths}
+ \begin{itemize}
+ \item \sout{There are two main modes in vim:}
+ \begin{itemize}
+ \item \sout{Beep}
+ \item \sout{Mess everything up}
+ \end{itemize}
+ \end{itemize}
+ \emph{~~~ No, this is one mode}
+ \begin{itemize}
+ \item \sout{You can't quit vim}
+ \end{itemize}
+ \emph{~~~ No. Vim is \underline{not} Hotel California.}
+
+ \emph{~~~ I may assure you, you will be expert in quitting vim when these talks are finished.}
+ \begin{itemize}
+ \item \sout{One need MIDI Foot Controller Pedal to properly work with vim}
+ \end{itemize}
+ \emph{~~~ No. MIDI Foot Pedal is for Emacs users only}
+\end{frame}
+
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\input{elements/diag.tex}
+
+\begin{frame}{Vim modes}
+ \resizebox{0.8\textwidth}{!}{
+ \begin{tikzpicture}[start chain=going below, node distance=12mm and 32mm] % начало цепочки
+ \node (insert_mode)[Rectangle]{Insert mode};
+ \node (command_mode)[Rectangle]{Command mode};
+ \node (search_mode)[Rectangle]{Search mode}; % FIXME убедиться, что режим поиска -- правильное название.
+
+ \node (normal_mode)[Rectangle, left=of command_mode]{Normal mode};
+ \end{tikzpicture} % конец блока
+ }
+\end{frame}
+
+
+\usetikzlibrary{arrows.meta}
+
+\begin{frame}{Vim modes}
+ \resizebox{0.8\textwidth}{!}{
+ \begin{tikzpicture}[start chain=going below, node distance=12mm and 32mm, >={Stealth[scale=1.5]} ] % начало цепочки
+ \node (insert_mode)[Rectangle]{Insert mode};
+ \node (command_mode)[Rectangle]{Command mode};
+ \node (search_mode)[Rectangle]{Search mode}; % FIXME убедиться, что режим поиска -- правильное название.
+
+ \node (normal_mode)[Rectangle, left=of command_mode]{Normal mode};
+
+ \path[->] (normal_mode.east) edge node[midway, above, sloped, yshift=32pt]{ i / Ins } (insert_mode.west);
+ \path[->] (normal_mode.east) edge node[midway, above, sloped, yshift=32pt]{ : } (command_mode.west);
+ \path[->] (normal_mode.east) edge node[midway, below, yshift=32pt]{ / } (search_mode.west);
+
+ \end{tikzpicture} % конец блока
+ }
+\end{frame}
+
+\begin{frame}{Vim modes}
+ \resizebox{0.8\textwidth}{!}{
+ \begin{tikzpicture}[start chain=going below, node distance=12mm and 32mm, >={Stealth[scale=1.5]} ] % начало цепочки
+ \node (insert_mode)[Rectangle]{Insert mode};
+ \node (command_mode)[Rectangle]{Command mode};
+ \node (search_mode)[Rectangle]{Search mode}; % FIXME убедиться, что режим поиска -- правильное название.
+
+ \node (normal_mode)[Rectangle, left=of command_mode]{Normal mode};
+
+ \path[->] (insert_mode.west) edge node[midway, above, sloped, yshift=32pt]{ Esc } (normal_mode.east);
+ \path[->] (command_mode.west) edge node[pos=0.38, above, sloped, yshift=32pt]{ Esc / Enter } (normal_mode.east);
+ \path[->] (search_mode.west) edge node[pos=0.40, below, sloped, yshift=36pt]{ Esc / Enter } (normal_mode.east);
+
+ \end{tikzpicture} % конец блока
+ }
+\end{frame}
+
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+\begin{frame}[fragile, shrink=10]{Commands of the command-line mode}
+ \begin{itemize}
+ \item \textbf{:q} --- quit vim
+ \item \textbf{:q!} --- quit without saving
+ \item \textbf{:w} --- save (\textbf{:wq} --- save and quit)
+ \item \textbf{:123} --- go to line 123
+ \item \textbf{:set number} --- show line numbers
+ \item \textbf{:set nonumber} --- hide line numbers
+ \end{itemize}
+ Use \textbf{up} and \textbf{down} arrows to scroll through commands history
+
+ \textbf{Tab} is for autocompletion
+\end{frame}
+
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\begin{frame}[fragile, shrink=10]{Normal mode commands}
+ \begin{itemize}
+ \item \textbf{dd} --- delete line;
+ \item \textbf{u} --- undo;
+ \item \textbf{Ctrl + r} --- redo.
+ \end{itemize}
+
+Copy and past commands
+
+ \begin{itemize}
+ \item \textbf{v} / \textbf{V} --- text selection mode
+ \item \textbf{d} --- delete selected text into buffer
+ \item \textbf{y} --- copy (yank) selected text into buffer
+ \item \textbf{p} / \textbf{P} --- insert text from buffer in/after cursor position
+ \end{itemize}
+\end{frame}
+
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\begin{frame}[fragile, shrink=10]{Search mode commands}
+ \begin{itemize}
+ \item \textbf{/abc} --- search text for substring `abc`;
+ \item \textbf{/} --- search again.
+ \end{itemize}
+
+Use \textbf{up} and \textbf{down} arrows to scroll through search history
+
+You can also use regular expressions here.
+
+\end{frame}
+
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+{\setbeamertemplate{background}{
+ \begin{tikzpicture}
+ \node[anchor=south west, inner sep=0] at (0,0) {\includegraphics[width=\the\paperwidth, height=\the\paperheight]{theme.nonfree/bgpics/pgpro_title_bg2.png}};
+ \node[anchor=east] at(\textwidth+1cm,0.5cm) {\color{white}\tiny\insertframenumber};
+ \end{tikzpicture}
+ }
+ \setbeamercolor{normal text}{fg=white}\usebeamercolor*{normal text}
+ \setbeamerfont{normal text}{size*={32pt}{1},family=\sffamily}\usebeamerfont*{normal text}
+ \begin{frame}
+ \vskip1cm
+ Navigating through code using tags in vim
+ \end{frame}
+}
+
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+\begin{frame}[fragile, shrink=10]{Tags lists}
+
+Tags are an ancient way for navigating the code, for jumping from symbol's usage to it's definition.
+
+In this technique you use some script for generating list of symbols defined in your project (tags) and your editor uses them for navigating through the code.
+
+For C code of PostgreSQL tags are generated with `ctags` program from `exuberant-ctags` package.
+
+\end{frame}
+
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+\begin{frame}[fragile, shrink=10]{Building tags list}
+
+
+To build tags list you should install `exuberant-ctags` package:
+
+ \begin{lstlisting}[linewidth=0.9\textwidth, literate={\$}{{\textdollar}}1]
+$ sudo apt-get install exuberant-ctags \end{lstlisting}
+
+And then run \texttt{make\_ctags} script provided by PostgreSQL developers from the root of PostgreSQL source tree
+
+ \begin{lstlisting}[linewidth=0.9\textwidth, literate={\$}{{\textdollar}}1]
+$ src/tools/make_ctags \end{lstlisting}
+
+You will get a bunch of \texttt{tags} files in each directory of source tree.
+You can copy it to your extension dir, so you can jump to postgres code function definitions while editing your code.
+
+\end{frame}
+
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\begin{frame}[fragile, shrink=10]{Using tags in vim}
+
+Let's open some file from PostgreSQL source code
+
+ \begin{lstlisting}[linewidth=0.9\textwidth, literate={\$}{{\textdollar}}1]
+$ vim src/backend/postmaster/postmaster.c \end{lstlisting}
+
+and find some symbol that most probably defined inside PosgreSQL code.
+I found \texttt{BACKEND\_NUM\_TYPES} on 145th line.
+
+You can move cursor to that symbol, and press \textbf{Ctrl + \rbrack} to jump to the place where this symbol is defined.
+
+In order to go back, press \textbf{Ctrl + t}
+\end{frame}
+
+
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\begin{frame}[fragile, shrink=10]{Hiding \texttt{tags} from git}
+
+\texttt{tags} files are not ignored by by git version control system.
+You can see that by running command
+
+\begin{lstlisting}[linewidth=0.9\textwidth, literate={\$}{{\textdollar}}1]
+$ git status \end{lstlisting}
+
+Theoretically you cat add \texttt{tags} into \texttt{.girignore} file, but you will have to track this change manually, make sure it is not committed, and so on.
+Less known solution is to add \texttt{tags} into local .\texttt{git/info/exclude} file, that will do same trick.
+
+Run again
+
+\begin{lstlisting}[linewidth=0.9\textwidth, literate={\$}{{\textdollar}}1]
+$ git status \end{lstlisting}
+
+and you will see that \texttt{tags} files are now ignored.
+
+\end{frame}
+
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\begin{frame}[fragile, shrink=10]{Open file on certain position}
+
+If you, for some reason need to open file on certain position, for example you get an error message from a compiler, that specify certain line number, you can specify this line number as an extra option with "plus" prefix in front of it:
+
+\begin{lstlisting}[linewidth=0.9\textwidth, literate={\$}{{\textdollar}}1]
+$ vim src/backend/access/common/reloptions.c +1234 \end{lstlisting}
+
+This command will open \texttt{reloptions.c} file in vim, and move cursor to line number 1234.
+
+\end{frame}
+
+
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\begin{frame}[fragile, shrink=10]{\texttt{grep}ing for function definition}
+
+If you know function name (from compiler error message) and would like to find it's definition, most probably you will try to use \texttt{grep} utility.
+But you will not success, as multiple \texttt{tags} files will also contain this function name.
+You should use `git grep` command instead, as it will ignore files that are not part of git repository
+
+\begin{lstlisting}[linewidth=0.9\textwidth, literate={\$}{{\textdollar}}1]
+$ git grep ^tsvectorin \end{lstlisting}
+
+This command uses the convention that, in a C program, the function name is specified starting from the first character of the line.
+This allow to find only function definition, and ignore all other occurrences.
+
+\begin{lstlisting}[linewidth=0.9\textwidth, literate={\$}{{\textdollar}}1]
+int
+my_function(char * str, bool is_cool) \end{lstlisting}
+
+\end{frame}
+
+
+
+{\setbeamertemplate{background}{
+ \begin{tikzpicture}
+ \node[anchor=south west, inner sep=0] at (0,0) {\includegraphics[width=\the\paperwidth, height=\the\paperheight]{theme.nonfree/bgpics/pgpro_thanks_bg.png}};
+ \node[anchor=east] at(\textwidth+1cm,0.5cm) {\color{white}\tiny\insertframenumber};
+ \end{tikzpicture}
+ }
+ \begin{frame}
+ \end{frame}
+}
+\end{document}