Eric D. Schabell: Vim Hints
Showing posts with label Vim Hints. Show all posts
Showing posts with label Vim Hints. Show all posts

Friday, January 16, 2009

Vim hints: word completion or line completion

I often missed the IDE {word|command|line} completion short-cuts in vim until I found these:

" Line completion: in 'insert mode' it provides you with 
" a list of existing lines to choose from in your current 
" file. 
ctrl-x ctrl-l 

" Word completion: in 'insert mode' it provides you with
" a list of possible matching words starting with the 
" next word available in your current file.
ctrl-n

" Word completion: in 'insert mode' it provides you with
" a list of possible matching words going back from the 
" current word in your current file.
ctrl-p

" Searching a dictionary for word completion is done by 
" first setting the dictionary to search:
:set dictionary=/usr/share/dict/words

" Then try to match a word with:
ctrl-x ctrl-k

Wednesday, August 27, 2008

Vim hints: last file location

Using vim and want to re-enter the file at the same location you left it? Add this to your .vimrc file:

" jump to last position before save.
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal g'\"" | endif

Vim version is 7.1.138.

Vim hints: java setup

The simple startup is to add these to your .vimrc file and run the ctags as described below to allow for indexing of your source code:

set sm
set ai

" run on command line for tags setup : 
" ctags -f ~/.tags -R workspace/.../src $JAVA_HOME/src
"
set tags=~/.tags
set complete=.,w,b,u,t,i

" Java stuff.
syntax on

let java_highlight_all=1
let java_highlight_functions="style"
let java_allow_cpp_keywords=1

Now you can navigate in your java source code file by placing the cursor on a classname and hitting CTRL-]. To jump back and forwards while browsing your code, use CTRL-O and CTRL-I.

You can also view your jump list by using the cmd interface, :jumps.

Vim version is 7.1.138