Monday, December 26, 2011

Misc VIM Tips

1. opening multiple files in tabs
vim -p file1 file2...

2. moving tabs
:tabm N

3. highlighting
:set hlsearch
:nohlsearch

4. autocomplete (Ctrl-N)


Sunday, December 25, 2011

Side-by-Side Figures

# 1

\begin{figure*}
\centering
\subfigure[Page coverage due to migration]{
    \includegraphics[width=.3\textwidth]{figures/fig-migcoverage-reduced-prdc}
    \label{fig:migcoverage}
}
\subfigure[Effect of replenishment rates]{
    \includegraphics[width=.3\textwidth]{figures/fig-replenishrate-reduced-prdc}
    \label{fig:replenishrate}
}
\subfigure[Slowdown under overload]{
    \includegraphics[width=.3\textwidth]{figures/fig-overload-reduced-prdc}
    \label{fig:overload}
}
\caption{Effect of Migration, Replenishment Rates and Slowdown}
\end{figure*}
 
# 2
\usepackage{subfigure}

%\begin{figure}[h]%\centering
%\begin{minipage}{.3\textwidth}
%    \includegraphics[width=\textwidth]{figures/fig-migcoverage-reduced-prdc}
%    \caption{Page coverage due to migration}
%    \label{fig:migcoverage}
%\end{minipage}
%\begin{minipage}{.3\textwidth}
%    \includegraphics[width=\textwidth]{figures/fig-replenishrate-reduced-prdc}
%    \caption{Effect of replenishment rates}
%    \label{fig:replenishrate}
%\end{minipage}
%\begin{minipage}{.3\textwidth}
%    \includegraphics[width=\textwidth]{figures/fig-overload-reduced-prdc}
%    \caption{Slowdown under overload}
%    \label{fig:overload}
%\end{minipage}
%\end{figure}

Wednesday, November 23, 2011

Justifying a Block of Code

v - to select the block
< > - to move the block one tab left or right
. - repeat the previous command

Commenting/Uncommenting a block of text

Commenting:
Ctrl-v to select the first characters of the block.
Shft-i for insert mode
Put the %, then hit Esc

Uncommenting:
Ctrl-v to select the first characters and 'x' to delete them. 

Tuesday, November 15, 2011

Moving the cursor

w    goes word by word
b     goes back word by word
(      Move a sentence back
)      Move a sentence forward
{     Move a paragraph back
}     Move a paragraph forward
0     Move to the beginning of the line
$     Move to the end of the line
1G   Move to the first line of the file
G     Move to the last line of the file
nG   Move to nth line of the file


Friday, October 28, 2011

Mark, Search, Code Block

Marking
m{a-zA-Z} marks places
'{a-zA-Z} go back to mark

Searching
* to word under cursor

Code Block
% - go to matching brace

Delete Word or Sentence
dw dis dip






Thursday, October 13, 2011

cscope and ctags

* CScope: do a 'cscope -R -b' in the directory, then run vim to use cscope.out auto.

* CTags: do 'ctags --recurse=yes .' in the directory, run vim, use ctrl-] and ctrl-t
(install cscope and ctags before usage)

Tuesday, October 4, 2011

vim links

http://www.tuxfiles.org/linuxhelp/vimcheat.html

100 Vim commands every programmer should know
http://www.catswhocode.com/blog/100-vim-commands-every-programmer-should-know

Wednesday, September 28, 2011

pdf eps conversion and cropping

pdf -> eps: pdftops -eps input
crop eps: epstool --copy -b input output
eps -> pdf: epstopdf input --outfile=output

compiling python: pdflatex -escape-shell input

VIM tips

* spelling
:setlocal spell spelllang=en_us / :set nospell
]s move to next misspelled word, [s move to prev. misspelled word
z= suggests correctly spelled words under cursor,
1z= takes the first word from the suggestion list
^Xs does the same in insert mode.
:spellr repeats replacements done with z= for all matches

For more info about spellchecking in vim ->:h spell

* save all open buffers (and quit)
:wa " write (save) any changed files and keep working
:xa " write any changed files and exit

* double click open into vim in a terminal
/usr/bin/gnome-terminal -x /usr/bin/vim

* default tabstop in vim (in vimrc file)
set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab

* install plugin (in vimrc file)
filetype plugin on
source /usr/share/vim/addons/plugin/(plugin).vim
...
my file:
source /usr/share/vim/addons/plugin/cscope_macros.vim
source /usr/share/vim/addons/plugin/taglist.vim
source /usr/share/vim/addons/plugin/NERD_tree.vim
source /usr/share/vim/addons/plugin/exec_menuitem.vim
source /usr/share/vim/addons/plugin/fs_menu.vim
...

* global copy paste: "+y --> "+p (in vim) / ctrl-v (across any application)

* view filename: ctrl-g

Tuesday, September 27, 2011

install latex addon and packages in ubuntu

install addon:
make directory 'mypkgs' in /ur/share/texmf/tex/ or /usr/share/texmf/latex
copy the .sty file into mypkgs
run 'texhash'

drawing addons: 1. pgf/tikz, 2. pstricks, 3. Animate

needed packages in ubuntu:
1. use synaptic to install anything related to texlive, do a texhash
2. subfiles package
download from here
then: latex subfiles.ins
latex subfiles.dtx
3. same goes with algorithms package:
download from here

Monday, April 18, 2011

Latex Helpful Links

Albert's Academic Blog (link)

Not so frequently asked questions (link)

Double-Spacing in Latex

Add at the beginning:

\usepackage{setspace}

Then switch between different spacing options with:

\doublespacing
\singlespacing
\onehalfspacing

For other sizes use the \setstretch command like this:

\setstretch{1.8}

(more info)