Tuesday, October 22, 2013

ctag and csope for java

The same script as in this post, but for Java:
$ cat ~/bin/javatags
#!/bin/sh
workdir=`pwd`
workdir=${workdir/\/c/c:}
echo Work directory: $workdir

if [ ! -d cscope ]
then
   echo Creating cscope directory
   mkdir cscope
fi

echo Generating ctags
cd $workdir
ctags -R --language-force=java .

echo Generating cscope
cd /
find $workdir -name "*.java" > $workdir/cscope/cscope.files
cd $workdir/cscope
cscope -bq

echo Complete

Sunday, October 20, 2013

Use :tjump instead of :tag in vim

Often when you press CTRL-] in vim there are several options to jump on. By default CTRL-] is mapped to :tag command, and you need to use :tselect after CTRL-] to see all alternatives. It is more convenient to see the list right away after pressing CTRL-]. vim already has such a command: :tjump. You just need to remap CTRL-] to :tjump instead of :tag:
nnoremap <c-]> g<c-]>
vnoremap <c-]> g<c-]>

nnoremap g<c-]> <c-]>
vnoremap g<c-]> <c-]>
Source.

Saturday, October 19, 2013

Not using of syntax highlighting

About a month ago I turned off syntax highlighting in vim. And it turns out that syntax highlighting does not matter. The code has not lost any readability. Moreover, nothing distracts me and I can concentrate on the code, not on the highlighting. So bravely remove or comment out the following lines from your .vimrc:
"if &t_Co > 2 || has("gui_running")
  " syntax on
  " set hlsearch
"endif
or just
syntax off
set bg=dark
If you want your gvim looking like vim in a terminal, try xterm16 colorscheme.
if has("gui_running")
    colo xterm16
endif

Sunday, October 13, 2013

Limiting the width of Wikipedia pages

To limit the width of Wikipedia pages custom CSS can be used. Preferences -> Appearance -> Custom CSS
body {
    max-width: 65em;
    margin-left: auto;
    margin-right: auto;
    position: relative;
    float: none; 
}
Source.

Monday, September 30, 2013

Text overlapping in bash terminal

One time I had an issue with text overlapping in my bash terminal. When I printed a long line of text the letters began to be displayed from the beginning of the same line, not from the new line. The cause was some wrong character sequence in commmands that setup color in my PS1 variable. Example of correct color commands that do not cause the issue:

// excerpt from .bashrc
function set_prompt {
   local YELLOW="\[\033[0;33m\]"
   local GREEN="\[\033[0;32m\]"
   local ENDCOLOR="\[\033[00m\]"
   export PS1="$GREEN\u@\h $YELLOW\w> $ENDCOLOR"
}
set_prompt

git cheatsheet

git commit
   -a # Commit all changes skipping the Staging Area
   -v # See in the editor also the 'git diff' output

git log
   -p, --patch              # Generate patch
   --stat
   --pretty=format:"%h %s"
   --graph