back home

This is the primary configuration file for vim. Basically it comes down to some various tweaks that make vim behave more like a word processor then a source code editor. Such is the beauty of vim. Some bells and whistles I have added are hot keys to the 'dict' program (a text mode dictionary), this allows me to look words I can't manage to spell and aren't autocorrected. I've also added some hot keys to search a file populated with character's names, so I can just type a few letters, hit tab and get a list of characters to chose from. Also, a hot key to Language Tool, a java program that will look for certain grammatical problems and flag them for me. (Lookup function is shamlessly stolen from Swaroop's plugin.)

au BufRead,BufNewFile *.txt set filetype=txt
au! Syntax txt source ~/txt.vim
colorscheme evening
set encoding=utf-8
set formatoptions=l
set lbr 
set spell spelllang=en_us spellfile=~/spellfile.add 
set hlsearch
set incsearch
set dictionary+=~/chars
set complete=.,w,k
set infercase
set textwidth=79
set backup
set keywordprg=dict
set undolevels=100
set virtualedit=all
set makeprg=~/fiction/notes/atdtool\ %
set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<
nmap = z=
imap  gk
imap  gj
nmap  gk
nmap  gj
vmap  gk
vmap  gj
imap  g^
imap  g$
nmap  g^
nmap  g$
vmap  g^
vmap  g$
let g:languagetool_jar=$HOME . '/lt/LanguageTool.jar'

if has("autocmd")
  au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif

autocmd InsertEnter * syn clear EOLWS | syn match EOLWS excludenl /\s\+\%#\@!$/
autocmd InsertLeave * syn clear EOLWS | syn match EOLWS excludenl /\s\+$/
highlight EOLWS ctermbg=red guibg=red

" lookup.vim - :Lookup the word in a dictionary
" Author: Swaroop C H 
" Version: 2
" Uses: Dict protocol (
" Uses: dict:// server

if &cp || (exists("g:loaded_lookup") && g:loaded_lookup)
let g:loaded_lookup = 1

function! s:isPythonInstalled()
    if !has('python')
        echoerr "lookup.vim requires vim compiled with +python"

    return has('python')

function! s:DefPython()

    if !s:isPythonInstalled()

python << PYTHONEOF

import vim
# Download, 'tar -xvzf dictclient_1.0.1.tar.gz' and run 'python install'.
import dictclient

def safequotes(string):
    return string.replace('"', "'")

def lookup(word):
    output = ''

    conn = dictclient.Connection('')

    output += "\n".join([d.getdefstr() for d in conn.define('wn', word)]) # WordNet
    output += "\n\n"
    output += "\n".join([d.getdefstr() for d in conn.define('moby-thes', word)])

    if len(output.strip()) == 0:
        output = "Sorry, couldn't find anything"

    vim.command('silent let g:lookup_meaning = "%s"' % safequotes(output))


call s:DefPython()

function! Lookup()

    if !s:isPythonInstalled()

    let word = expand("")
    execute "python lookup('" . word . "')"
    echohl WarningMsg
    echo g:lookup_meaning
    echohl None


command Lookup call Lookup()

source ~/autocorrect.vim