:set pasteThen paste the text. When you are done:
:set nopaste
:set pasteThen paste the text. When you are done:
:set nopaste
#!/bin/sh
# use vimdiff to view diffs
DIFF="/usr/bin/vim -d -R"
NUM=$# # number of arguments
LEFT=${6} # old file
RIGHT=${7} # new file
L_TITLE=${3} # actual name and revision of old file
R_TITLE=${5} # actual name and revision of new file
L_TITLE=`echo $L_TITLE | tr -s ' ' | sed 's/ /\\\\ /g'`
R_TITLE=`echo $R_TITLE | tr -s ' ' | sed 's/ /\\\\ /g'`
$DIFF $LEFT $RIGHT -c "setl stl=$L_TITLE | wincmd W | setl stl=$R_TITLE"
~/.vim/after/ftplugin create a file text.vim containing
" Vim filetype plugin file " Language: text " Maintainer: Alexander LobovThe main strings are" Last Change: 2014 Mar 27 " Only do this when not done yet for this buffer if exists("b:did_ftplugin") finish endif " Don't load another plugin for this buffer let b:did_ftplugin = 1 setlocal autoindent setlocal formatoptions=tcroqln
setlocal autoindent setlocal formatoptions=tcroqlnYou .vimrc file should have
filetype plugin indent online.
$ 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
: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.
"if &t_Co > 2 || has("gui_running")
" syntax on
" set hlsearch
"endif
or just
syntax off set bg=darkIf you want your gvim looking like vim in a terminal, try xterm16 colorscheme.
if has("gui_running")
colo xterm16
endif
I use this script for generate ctags and cscope tags. This MinGW version is to be run in source code directory.
#!/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 --c++-kinds=+p --fields=+iaS --extra=+q .
echo Generating cscope
cd /
find $workdir -name "*.cpp" -or -name "*.h" > $workdir/cscope/cscope.files
cd $workdir/cscope
cscope -bq
echo Complete
For running on Linux remove
workdir=${workdir/\/c/c:}
I use default vimrc file as a base for my own one. From vim you can get it with
:e $VIMRUNTIME/vimrc_example.vim
I always use tab expanding. So, usually a part of my .vimrc file looks like:
set tabstop=4 set shiftwidth=4 set expandtab set autoindent set textwidth=80Specific values for
tabstop, shiftwidth and textwidth depend on project.
It is useful, especially during code review, to see not expanded tabs and trailing spaces. Leaving trailing spaces in code is bad idea, because they often mess diffs. To print these characters:
set listchars=trail:~,tab:>- set list
Set colorschemes for GUI and console:
if has("gui_running")
colorscheme wombat
else
colorscheme wombat256
endif
Remove superfluous GUI elements
" remove toolbar set guioptions-=T " remove menu bar set go-=m " remove right-hand scroll bar set go-=r
You can use second key mapping and switch between keymaps with CTRL-^ in insert mode, for example:
" remove toolbar set guioptions-=T " remove menu bar set go-=m " remove right-hand scroll bar set go-=r
Set font for GUI:
set guifont=Ubuntu\ Mono\ 12I use Ubuntu Mono or Monospace on Linux and Consolas on Windows.
To use 256 colors in vim it is needed to correctly set $TERM variable. For gnome-terminal it is gnome-256color.
vim uses $TERM variable and terminfo files to determine terminal properties. To determine correct value of $TERM you can add to your .bashrc this code from vim.wikia.com:
if [ "$TERM" = "xterm" ] ; then
if [ -z "$COLORTERM" ] ; then
if [ -z "$XTERM_VERSION" ] ; then
echo "Warning: Terminal wrongly calling itself 'xterm'."
else
case "$XTERM_VERSION" in
"XTerm(256)") TERM="xterm-256color" ;;
"XTerm(88)") TERM="xterm-88color" ;;
"XTerm") ;;
*)
echo "Warning: Unrecognized XTERM_VERSION: $XTERM_VERSION"
;;
esac
fi
else
case "$COLORTERM" in
gnome-terminal)
# Those crafty Gnome folks require you to check COLORTERM,
# but don't allow you to just *favor* the setting over TERM.
# Instead you need to compare it and perform some guesses
# based upon the value. This is, perhaps, too simplistic.
TERM="gnome-256color"
;;
*)
echo "Warning: Unrecognized COLORTERM: $COLORTERM"
;;
esac
fi
fi
SCREEN_COLORS="`tput colors`"
if [ -z "$SCREEN_COLORS" ] ; then
case "$TERM" in
screen-*color-bce)
echo "Unknown terminal $TERM. Falling back to 'screen-bce'."
export TERM=screen-bce
;;
*-88color)
echo "Unknown terminal $TERM. Falling back to 'xterm-88color'."
export TERM=xterm-88color
;;
*-256color)
echo "Unknown terminal $TERM. Falling back to 'xterm-256color'."
export TERM=xterm-256color
;;
esac
SCREEN_COLORS=`tput colors`
fi
if [ -z "$SCREEN_COLORS" ] ; then
case "$TERM" in
gnome*|xterm*|konsole*|aterm|[Ee]term)
echo "Unknown terminal $TERM. Falling back to 'xterm'."
export TERM=xterm
;;
rxvt*)
echo "Unknown terminal $TERM. Falling back to 'rxvt'."
export TERM=rxvt
;;
screen*)
echo "Unknown terminal $TERM. Falling back to 'screen'."
export TERM=screen
;;
esac
SCREEN_COLORS=`tput colors`
fi
Also you have to have corresponding terminfo files. On Ubuntu you can install additional terminfo definitions:
sudo apt-get install ncurses-termNow you have
gnome-256color and other terminal definitions in /usr/share/terminfo (directory depends on system). You can use such themes as desert256, wombat256 etc.
To set colorscheme I use this code in my .vimrc:
if has("gui_running")
colorscheme wombat
else
colorscheme wombat256
endif
You can check how many colors are used inside vim by examining t_Co variable:
set t_Co t_Co=256I meet a difficulty with setting
$TERM on one of Solaris servers I use. I had not colors in vim at all on this server. tput colors said me -1. There are not any terminfo file like *-256color and I have not root priviledges to add needed terminfo files. $TERM was set to xterm. But I found xtermc in terminfo directory. After setting $TERM to xtermc tput colors gives 8, and I can use syntax highlighting in vim, although not 256 colors.