Lisp indentation in vim

Some time ago, I started (re)learning Lisp, and being used to work with vim (and not with emacs), I googled for "lisp vim" and of the first results was Limp (http://mikael.jansson.be/hacking/limp/docs/)). The problem is that when I indent code, it gets like this:
(defun combinations (elts)
(dolist (val elts) ; verify that only atoms are given
(if (or (not (atom val)) (null val))
(progn (format t "List must contain only atoms")
(abort))))
(format t "Number of diferent arrangement: ~D" (factorial (length elts)))
(do-combinations elts))
(defun do-combinations (elts)
(if (= (length elts) 2) ; base case
(list elts (reverse elts))
(let ((res ()) (aux ()))
(dolist (obj elts)
(setf aux (do-combinations (remove obj elts)))
(dolist (obj1 aux)
(setf res (append res (list (append (list obj) obj1))))))
res)))
;;; borrowed from wikipedia... http://en.wikipedia.org/wiki/Lisp_programming_language
(defun factorial (n &optional (acc 1))
(if (<= n 1)
acc
(factorial (- n 1) (* acc n))))
EDIT: while trying to fix the indentation in the post to show how vim really indents the code, I accidentally clicked the Submit button instead of Preview. I manually fixed only the first function (combinations) to show the problem: from what I've read about Lisp indenting, the first "if" should be indented with two spaces in relation to the previous "dolist", instead of aligned with "dolist" argument list. Right?
(the other two functions are not shown as vim indents them, because of copy/paste problems...)
Last edited by gauthma (2010-02-16 20:16:13)

Peasantoid wrote:
:set lisp
is probably what you're looking for?
That didn't work, but then I tried the same thing removing Limp, and yes it does the trick. Well now I know where lies the problem. Thanks for the idea!

Similar Messages

  • [Solved] vim, indent and hash

    I know this isn't strictly a programming problem, but bear with me...
    To make a long story short, I have a Perl file in which some comment lines start with the hash(#) as the first character of the line, i.e. before the # there's nothing, not even spaces. The problem is that trying to indent this line with == does not work. Now, with my current vim setup, when *insert* a new line that starts with an #, indentation is done properly. Also, if there is space before the #, but the indentation is wrong, == correctly indents it. The problem is when the # is the very first character of the line, and (it goes without saying) the indentation is wrong, == does nothing.
    I've googled and read all about disabling smartindent, cindent, and whatnot, and nothing seems to work. I'm really grasping at the straws with this one, so all ideas are welcome...
    Last edited by gauthma (2010-10-26 16:22:11)

    For future reference of whomever might encouter this problem... the file /usr/share/vim/vim73/indent/perl.vim has, in line 55 and following, the, erm, following:
    " Don't reindent coments on first column
    if cline =~ '^#.'
    return 0
    endif
    Commenting those out solved the problem. Of course I now wonder why would those lines be there in the first place, but I digress...

  • SOLVED Vim indent (Groovy)

    Hi people!
    I try to use this script http://www.vim.org/scripts/script.php?script_id=2961 . I copy this file in /usr/share/vim/vim73/indent
    but I have this error when open a file *.groovy
    Error detected while processing /usr/share/vim/vim73/indent/groovy.vim:
    line    5:
    E492: Not an editor command: ^M
    line    7:
    E15: Invalid expression: exists("b:did_indent")^M
    line  164:
    E171: Missing :endif
    Press ENTER or type command to continue
    The script looks ok. I can't figure out what's going on.
    Thanks in advance.
    Last edited by Horris (2010-09-30 02:08:59)

    '^M' are end-of-line marks for dos - remove them: http://www.tech-recipes.com/rx/150/remo … nes-in-vi/
    Last edited by karol (2010-09-30 02:02:04)

  • Vim with limp [SOLVED]

    i've yaourted limp and i'm looking at the docs:
    http://mikael.jansson.be/hacking/limp/docs/
    however, other than putting stuff in /usr/share/vim/ftplugin/lisp/vim nothing much is happening.
    looking at limp.vim i see:
    runtime ftplugin/lisp/limp/cursor.vim
    runtime ftplugin/lisp/limp/highlight.vim
    runtime ftplugin/lisp/limp/sexp.vim
    runtime ftplugin/lisp/limp/bridge.vim
    runtime ftplugin/lisp/limp/autoclose.vim
    runtime ftplugin/lisp/limp/keys.vim
    runtime ftplugin/lisp/limp/mode.vim
    so i put a softlink in the ftplugin/lisp/ dir to vim, but that didn't accomplish anything either.
    anyone know how to get limp working with vim?
    (of course, i installed sbcl)
    Last edited by pradtf (2010-09-26 17:10:11)

    ok some progress has just been made!
    by putting a softlink in .vim/ftplugin/lisp -> /usr/share/vim/ftplugin/lisp
    it comes on.
    now to try to figure out what to do with it as per mikael's doc.
    <F12> works but it doesn't seem to start a limp connection hanging on Booting ... indefinitely.
    now this document provides some idea:
    https://bugs.archlinux.org/task/17774
    but i'm not sure how to proceed since changing
    LIMPDIR=${LIMPRUNTIME:-/usr/local/limp/$VERSION}
    to
    LIMPDIR=${LIMPRUNTIME:-/usr}
    did zilch.
    no wait actually it works but i have to start lisp manually after changing the LIMPDIR:
    lisp.sh test -b
    then i can (g)vim into the program and <F12> and follow mikael's doc.
    this discussion was what provided the info:
    http://www.lispforum.com/viewtopic.php?f=17&t=3
    so we'll see where this goes, but at least this much is working now.
    Last edited by pradtf (2010-09-26 06:51:49)

  • [Solved] How to disable vim filetype indentation.

    Hello. I want to start using vim, but there is only that problem with that. In gedit I always use tabs 4 spaces wide for indentation, and I want to do something similar in vim. So in my .vimrc I used tabstop=4 and set autoindent. If I write a plain text file, it works correctly, for example, if I press tab in a new line, and the press enter, the following lines preserve the tab as indentation.
    The problem starts when writing code in common lisp or python. In lisp tab is replaced by two spaces and does some weird things, and in python tab is replaced by 4 spaces. I tried including "filetype indent off" in my vimrc, or writing ":filetype indent off" directly in console, but that doesn't have any effect. The only thing that somewhat works is to disable autodinent, but then I have to manually indent every line. What can I do?
    Last edited by Serge2702 (2014-11-06 20:57:54)

    I keep a skeleton vimrc file to use when I have a question similar to Serge2702's.  My barebones.vim:
    set nocompatible
    filetype plugin on
    set t_co=256 " Optional, you may comment this out.
    syntax on
    Start vim, using the alternate vimrc file with the command, say, for a lisp file: vim -u barebones.vim file_to_edit.lisp.
    Seems most filetypes default to a tab with a width of eight spaces here.  To see the tabs, you can use these two commands from within vim:
    :set list
    :set listchars=tab:_T
    Then you can try all the different setting combinations to figure out a comfortable tab width.
    And there are quite a few settings that affect the width of tabs and indentation besides tabstop. There's autoindent to repeat the previous line's indentation, but this is modified if you use cindent or smartindent to set the indent according to syntax. Then there are the expandtab and smarttab settings to use spaces for tabs, and shiftwidth and softtabstop also set indentation width. I don't see why anyone has trouble figuring it out.;)

  • [SOLVED] How can I turn off the annoying auto indent tabs in VIM?

    I'm coding in Python and VIM is auto-tabbing each new line.  It's a real buzz kill.
    When I hit enter at the left margine, even when there is nothing on the line above the cursor, it shoots out a tab and three spaces.  I've switched to nano but feel lost without VIM.  I've never seen this behavior before.  I've turned off all of the auto indentation options I can think of.
    ***** begin .vimrc *****
    set noautoindent
    set nosmartindent
    set noindentexpr
    set nocindent
    ***** end .vimrc *****
    Thanks!
    [UPDATE]
    I wish I could delete this post.  ... anyway...  the solution was:
    set indentexpr=''
    Last edited by TomB17 (2009-09-03 16:41:07)

    Unfortunately, I have to do a ":set indexexpr='' " each time I start VIM.  I've got it in the .vimrc but it seems to be ignored.
    I'm used to Ubuntu and this feels really weird.  It's like profiles aren't processed.
    I would appreciate it if somoeone would point me in the correct direction.
    Last edited by TomB17 (2009-09-03 21:03:20)

  • Vim mode in Emacs (no editor war)

    I've been using vim for some time now and I really appreciate the different modes and key bindings. I've experimented a little with emacs and I really like it as a development environment and its flexibility and extensibility, but so far I don't really like it as a text editor (I'm not interested in starting a discussion about vim vs. emacs / editor war).
    Of course I might need to get more familiar with emacs to appreciate and get used to its text editing "paradigm". I've been thinking about using one of the vim modes for emacs (viper-moder, evil-mode...) to be able to use emacs as a development environment, and vim as the editor, but some people seem to believe that it's better to learn the emacs way of doing text editing.
    Why would I not want to use a vim mode in emacs if I like the way of editing text in vim? What are the downsides compared to using emacs alone?
    I basically want to keep vim as my text editor, but have the ability to use it with emacs when doing more than just simply editing text. Is this worth the trouble of using a vim emulator? Any other users doing this?
    Thank you

    Trilby wrote:I'm curious what additional behavior / features you want that vim can't provide.  I only very briefly dabbled in emacs, and also ask only out of pure curiosity: I've been amazed at how much I can extend vim's behavior and I'm wondering if there is either 1) something useful I am missing, or 2) something useful that could be scripted into vim.
    lol, I totally agree with that statement. 
    As for what could be scripted into vim, a built-in compiler or at least a compiler-command resolver would be nice.
    NOTE: by compiler-command resolver, I mean that if you're working on a 'file.c' then when you run something magical like this:
    :compile
    it would send the following to the shell
    gcc -Wall -O3 file.c -o file
    akh wrote:I've experimented a little with emacs and I really like it as a development environment and its flexibility and extensibility, but so far I don't really like it as a text editor (I'm not interested in starting a discussion about vim vs. emacs / editor war).
    I've also found that Emacs is really nice for certain development-esque tasks.  Like, I used to use Emacs, back when I first started using Arch, to edit openbox's config files and I have always fondly remembered it being super-cool at working with the xml.  Like it would even highlight mistakes and was always pristinely consistent with syntax highlighting and indenting from what I can remember.  (Honestly, I kind of miss using it to edit XML, lol, xD I've developed an emotional attachment to a text-editor. )  I still occasionally use Emacs for when I'm having a hard time getting a certain lisp function or what-have-you to work (see lispbox) and then only when I'm tired of how awkward my setup of vim-slimv is--I've been needed to amend some aspects of it for quite a while, but I haven't been using it lately, so--naturally--I've haven't bothered to do so. 
    And I agree with you 135% on not liking much for text editing; I prefer a more modal environment. 
    As for editor wars, I honestly don't understand where the glory of dying in battle for your favorite text-editor is... maybe behind the couch or wherever the potato chips are
    in my opinion, they're a waste of time for the participants; as for the readers, I actually find it a bit amusing to read them, or of them.  Honestly, though, I don't understand why we can't all just enjoy having an editor that we adore and love no matter what that editor is. 
    EDIT: Take a look at this forum post vim vs. emacs, I only glanced at it, but it seemed to be talking about ways to make emacs better for just plain text editing.
    Last edited by lspci (2013-03-13 04:37:06)

  • Vim Ctrl + Tab for Tabs navigation

    :noremap <silent> <c-Tab> :tabn<CR>
    noremap! <silent> <C-Tab> :tabn<CR>
    This doesn't work for me - any idea why? Ctrl-tab just doesn't shift tabs... I've definitely not bound the combination elsewhere in my .vimrc either.
    - KD
    Last edited by KomodoDave (2007-05-02 02:38:33)

    mosor wrote:
    Here are my tab related settings (that work):
    set showtabline=2 " File tabs allways visible
    :nmap <C-S-tab> :tabprevious<cr>
    :nmap <C-tab> :tabnext<cr>
    :nmap <C-t> :tabnew<cr>
    :map <C-t> :tabnew<cr>
    :map <C-S-tab> :tabprevious<cr>
    :map <C-tab> :tabnext<cr>
    :map <C-w> :tabclose<cr>
    :imap <C-S-tab> <ESC>:tabprevious<cr>i
    :imap <C-tab> <ESC>:tabnext<cr>i
    :imap <C-t> <ESC>:tabnew<cr>
    Thanks for posting, mosor! Sadly your command lines don't work for me either...
    Here's my .vimrc, much of which was cloned from phrakture's :
    """""""""" general options """"""""""
    set nocompatible " Use Vim settings, rather then Vi settings (much better!).
    " This must be first, because it changes other options as a side effect.
    "syntax enable " enable syntax highlighting and keep current colour settings
    syntax on " enable syntax highlighting and override current colour settings
    behave xterm " mouse and selection xterm behaviour
    filetype plugin indent on " filetype dependent indenting and plugins
    set autoindent " indents line relative to the line above it
    set autowrite " automatically write contents of file where sensible
    set backspace=indent,eol,start " allow backspacing over eevrything in insert mode
    set backup backupdir=$HOME/.vim/backup " set backup directory
    set cinoptions=g0,:0,l1,(0,t0 " C indentation options
    set clipboard=unnamed " yank and paste in visual mode without prepending "*
    set cmdheight=1 " cmdline height
    set complete=.,t,i,b,w,k " keyword completion configuration
    set encoding=utf-8 " encoding
    set expandtab " insert spaces instead of tab character
    set formatoptions+=l " add format option preventing lines longer than 'textwidth' being broken
    set guioptions-=T " no toolbar
    set hidden " don't have to save when switching buffers
    set history=100 " cmdline history table size
    "set ignorecase " search is case insensitive when search term is all lower case
    set incsearch " live search while typing search expression
    set laststatus=2 " always display the status line
    set nohlsearch " no highlighting when performing search
    set nowrap " don't wrap visible lines
    set number " precede line with line number when printing
    set pastetoggle=<F9> " toggle paste mode
    set previewheight=5 " preview window size
    "set ruler " show line and column in status line
    set shell=/bin/sh " set the shell to be used
    set shiftwidth=4 " number of spaces used for (auto)indent
    set showcmd " show partial command in status line
    set showmode " show whether in insert, visual mode etc
    set showmatch " indicate matching parentheses, braces etc
    set showtabline=2 " File tabs allways visible
    set shortmess=a " abbreviate file messages
    set smartcase
    set smartindent
    set softtabstop=4 " tab defaults to 4 spaces while performing editing operations
    set splitbelow " split creates new window below current one
    set statusline=%-3.3n\ %f\ %r%#Error#%m%#Statusline#\ (%l/%L,\ %c)\ %P%=%h%w\ %y\ [%{&encoding}:%{&fileformat}]\ \ "status line settings
    set tabstop=4 " tab defaults to 4 spaces
    set textwidth=80 " maximum column width of inserted text - longer lines are broken after whitespace
    set ttyfast " for fast terminals - smoother (apparently)
    set termencoding=utf-8
    set whichwrap=h,l,<,>,[,] " allow line-wrapped navigation
    set wildchar=<Tab> " type tab in cmdline to start wildcard expansion
    set wildmenu " enhanced cmdline completion
    set wildmode=longest:full,full " cmdline completion mode settings
    set writebackup " make a file backup before overwriting it
    " Convenient command to see the difference between the current buffer and the
    " file it was loaded from, thus the changes you made.
    command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
    \ | wincmd p | diffthis
    """""""""" keyboard mappings """"""""""
    " Dvorak caret navigation
    :noremap t <Up>
    :noremap h <Down>
    :noremap d <Left>
    :noremap n <Right>
    :noremap k d
    :noremap l n
    :noremap j t
    " Window split and navigation
    :noremap <C-w><S-s> :vsplit<CR>
    :noremap <C-w>t <C-w><Up>
    :noremap <C-w>h <C-w><Down>
    :noremap <C-w>d <C-w><Left>
    :noremap <C-w>n <C-w><Right>
    " Ctrl-s saves
    :inoremap <C-s> <Esc>:w<CR>a
    :nnoremap <C-s> :w<CR>
    " Tab manipulation
    ":noremap <silent> <C-t> :tabnew<cr>
    ":noremap <silent> <C-x> :tabc<cr>
    ":noremap <silent> <C-tab> :tabn<cr>
    ":noremap <silent> <C-s-tab> :tabp<cr>
    "noremap! <silent> <C-t> :tabnew<cr>
    "noremap! <silent> <C-x> :tabc<cr>
    "noremap! <silent> <C-tab> :tabn<cr>
    "noremap! <silent> <C-s-tab> :tabp<cr>
    :nmap <C-S-tab> :tabprevious<cr>
    :nmap <C-tab> :tabnext<cr>
    :nmap <C-t> :tabnew<cr>
    :map <C-t> :tabnew<cr>
    :map <C-S-tab> :tabprevious<cr>
    :map <C-tab> :tabnext<cr>
    :map <C-x> :tabclose<cr>
    :imap <C-S-tab> <ESC>:tabprevious<cr>i
    :imap <C-tab> <ESC>:tabnext<cr>i
    :imap <C-t> <ESC>:tabnew<cr>
    "Key bindings
    noremap <silent> <F1> :Tlist<cr>
    noremap <silent> <F2> :VSBufExplore<cr>
    "noremap <silent> <F3> :Make<cr>
    noremap <silent> <F3> <c-o>:Project<cr>
    noremap <silent> <F6> :set spell!<cr>
    noremap! <silent> <F1> <c-o>:Tlist<cr>
    noremap! <silent> <F2> <c-o>:VSBufExplore<cr>
    "noremap! <silent> <F3> <c-o>:Make<cr>
    noremap! <silent> <F3> <c-o>:Project<cr>
    noremap! <silent> <F6> <c-o>:set spell!<cr>
    " I never use these anyway
    noremap ( :bprev<cr>
    noremap ) :bnext<cr>
    ":inoremap ^] ^[A
    ":inoremap ð ^N
    " Don't use Ex mode, use Q for formatting
    "map Q gq
    """""""""" autocommand stuff """"""""""
    " Only do this part when compiled with support for autocommands.
    if has("autocmd")
    " Enable file type detection.
    " Use the default filetype settings, so that mail gets 'tw' set to 72,
    " 'cindent' is on in C files, etc.
    " Also load indent files, to automatically do language-dependent indenting.
    filetype plugin indent on
    " Put these in an autocmd group, so that we can delete them easily.
    augroup vimrcEx
    au!
    " For all text files set 'textwidth' to 78 characters.
    autocmd FileType text setlocal textwidth=78
    " When editing a file, always jump to the last known cursor position.
    " Don't do it when the position is invalid or when inside an event handler
    " (happens when dropping a file on gvim).
    autocmd BufReadPost *
    \ if line("'\"") > 0 && line("'\"") <= line("$") |
    \ exe "normal! g`\"" |
    \ endif
    augroup END
    else
    set autoindent " always set autoindenting on
    endif " has("autocmd")
    " if autocmd is on
    if has("autocmd")
    " read Ex commands from file if syntax matches
    au Syntax {cpp,c,idl} runtime syntax/doxygen.vim
    au Syntax {cpp,c,lisp,scheme} runtime plugin/RainbowParenthesis.vim
    au FileType qf if &buftype == "quickfix" |
    \ setlocal statusline=%-3.3n\ %0*[quickfix]%=%2*\ %<%P |
    \endif
    au FileType mail setlocal spell
    au FileType cvs setlocal spell
    au FileType help setlocal statusline=%-3.3n\ [help]%=\ %<%P
    " for all files enable cursorline upon entering a window, and disable when
    " leaving
    "au WinEnter * setlocal cursorline
    "au WinLeave * setlocal nocursorline
    au BufReadPost * if line("'\"")>0 && line("'\"")<=line("$")|exe "normal g`\""|endif
    " syntax highlighting for html that permits embedded javascript
    au BufRead *.html set filetype=htmlm4
    " when a PKGBUILD is loaded into a buffer, trigger all sh filetype autocommands
    " this occurs before modelines are read
    au BufRead,BufNewFile PKGBUILD set ft=sh
    " when a .as file is loaded into a buffer,, trigger all actionscript
    " filetype autocommands, and use C indenting rules
    " this occurs before modelines are read
    au BufRead,BufNewFile *.as setlocal ft=actionscript cindent
    " omni functionality
    au FileType css setlocal ofu=csscomplete#CompleteCSS
    au Filetype * if exists('&ofu') && &ofu == "" |
    \ set ofu=syntaxcomplete#Complete |
    \endif
    endif
    """""""""" abbreviations and remaps """"""""""
    ":abbreviate #! #!/usr/bin/env python
    """""""""" other stuff """"""""""
    " vim.org tip 867: get help on python in vim, eg :Pyhelp os
    :command -nargs=+ Pyhelp :call ShowPydoc("<args>")
    function ShowPydoc(module, ...)
    let fPath = "/tmp/pyHelp_" . a:module . ".pydoc"
    :execute ":!pydoc " . a:module . " > " . fPath
    :execute ":sp ".fPath
    endfunction
    "bracket autocompletion
    inoremap ( ()<ESC>i
    inoremap [ []<ESC>i
    inoremap { {<CR>}<ESC>O
    autocmd Syntax html,vim inoremap < <lt>><ESC>i| inoremap > <c-r>=ClosePair('>')<CR>
    inoremap ) <c-r>=ClosePair(')')<CR>
    inoremap ] <c-r>=ClosePair(']')<CR>
    inoremap } <c-r>=CloseBracket()<CR>
    inoremap " <c-r>=QuoteDelim('"')<CR>
    inoremap ' <c-r>=QuoteDelim("'")<CR>
    function ClosePair(char)
    if getline('.')[col('.') - 1] == a:char
    return "\<Right>"
    else
    return a:char
    endif
    endf
    function CloseBracket()
    if match(getline(line('.') + 1), '\s*}') < 0
    return "\<CR>}"
    else
    return "\<ESC>j0f}a"
    endif
    endf
    function QuoteDelim(char)
    let line = getline('.')
    let col = col('.')
    if line[col - 2] == "\\"
    "Inserting a quoted quotation mark into the string
    return a:char
    elseif line[col - 1] == a:char
    "Escaping out of the string
    return "\<Right>"
    else
    "Starting a string
    return a:char.a:char."\<ESC>i"
    endif
    endf
    "folding options
    if has("folding")
    " enable folds
    set foldenable
    " {{{ markers indicate folds
    set foldmethod=marker
    " leave all/most folds open
    set foldlevel=100
    endif
    " if using gvim
    if has('gui_running')
    " allow pasting into other applications after visual selection
    set guioptions+=a
    " use console dialogs instead of popups
    set guioptions+=c
    " don't add tab pages
    set guioptions-=e
    " don't include toolbar
    set guioptions-=T
    " set color scheme
    colors zenburn
    " if running under windows
    if has('win32')
    " set number of columns and lines
    set columns=120
    set lines=60
    " select font
    set guifont=Bitstream_Vera_Sans_Mono:h8:cANSI
    else
    " select font
    set guifont=Bitstream\ Vera\ Sans\ Mono\ 8
    endif
    " if we're in a linux console
    elseif (&term == 'screen.linux') || (&term =~ '^linux')
    " use 8 bit colour
    set t_Co=8
    " set color scheme
    colors desert
    " if we're in xterm, urxvt or screen with 256 colours
    elseif (&term == 'rxvt-unicode') || (&term =~ '^xterm') || (&term =~ '^screen-256')
    " allow mouse in all editing modes
    set mouse=a
    " use xterm mouse behaviour
    set ttymouse=xterm
    " set encoding to uft-8
    set termencoding=utf-8
    " set color scheme
    colors desert256-transparent
    " if we're in a different terminal
    else
    " set color scheme
    colors desert
    endif
    " if we're in screen and autocmd is enabled
    if &term =~ "^screen" && has("autocmd")
    " this fixes background artifacting when leaving vim inside screen
    autocmd VimLeave * :set term=screen
    endif
    let mapleader = "`"
    " cd includes current directory, as well as $HOME and projects folders
    let &cdpath=','.expand("$HOME").','.expand("$HOME").'/projects'
    " if vim version is >= 7
    if v:version >= 700
    " display cursor line
    set cursorline
    " Insert mode completion options
    set completeopt=menu,menuone,longest,preview
    " spellchecker language is US
    set spelllang=en_us
    " spelling suggestions operate on 'fast' mode with max 20 suggestions
    set spellsuggest=fast,20
    " use min 1 column for line number
    set numberwidth=1
    " imma commnt with missspellings, use me tu tesst
    endif
    "set dictionary=/usr/share/dict/words
    " typing q: == :q
    nmap q: :q<cr>
    " typing :Q == :q
    nmap :Q :q<cr>
    " man-page autoreturn after view
    nmap K K<cr>
    iab NDB Author: N David Brown
    "tags files search for a project
    " :FindTags('~/projects/something')
    "command! -nargs=1 -complete=dir FindTags :call ProjectTags(<args>)
    "function! ProjectTags(projectbase)
    "let tfiles = glob("$(find ".a:projectbase." -name tags -print)")
    "let &tags = substitute(tfiles, "\n", ",", "g")
    "endfunction
    "command! -nargs=* Make :call SilentMake(<f-args>)
    "function! SilentMake()
    "let oldsp=&shellpipe
    "setlocal shellpipe=>%s\ 2>&1
    "exe 'silent make '.string(a:000)
    "cwindow
    "set shellpipe=&oldsp
    "redraw! "this screws up the screen sometimes, fix that
    "endfunction
    "Project
    let g:proj_flags = "ibmstg"
    let g:proj_window_width = 35
    "TODO get this working better
    "TagsParser
    "let g:TagsParserLastPositionJump = 1
    "let g:TagsParserCurrentFileCWD = 1
    let g:TagsParserWindowSize = 30
    "let g:TagsParserAutoOpenClose = 1
    "let g:TagsParserSingleClick = 1
    "let g:TagsParserHighlightCurrentTag = 1
    "let g:TagsParserSortType = "line"
    "let g:TagsParserFileReadTag = 1
    "let g:TagsParserFileReadDeleteTag = 1
    "enable the Vim 7.0 options
    if v:version >= 700
    let g:TagsParserCtrlTabUsage = 'tabs'
    "Configure the projects - These have been renamed because the projects I work
    "on at work are not really what is important, but rather the way they are configured.
    let g:TagsParserProjectConfig = {}
    let g:TagsParserProjectConfig['/home/griff/devel/pacman-lib/'] = { 'tagsPath' : '/home/griff/devel/pacman-lib/lib/libalpm/,/home/griff/devel/pacman-lib/src/pacman/' }
    endif
    "TagList
    "let Tlist_Display_Tag_Scope = 1 "ugh...
    let g:Tlist_Display_Prototype = 1
    let g:Tlist_Use_Right_Window = 1
    let g:Tlist_Exit_OnlyWindow = 1
    let g:Tlist_Enable_Fold_Column = 0
    let g:Tlist_Sort_Type = "name"
    let g:Tlist_Compact_Format = 0
    let g:Tlist_File_Fold_Auto_Close = 0
    let g:Tlist_WinWidth = 50
    "VTreeExplorer
    let g:treeExplVertical = 1
    let g:treeExplWinSize = 35
    let g:treeExplDirSort = 1
    "NetRW
    let g:netrw_keepdir = 1
    let g:netrw_winsize = 40
    let g:netrw_alto = 1
    "BufExplorer
    let g:bufExplorerOpenMode=1
    let g:bufExplorerSortBy='mru'
    let g:bufExplorerSplitType='v'
    let g:bufExplorerSplitVertSize = 35
    let g:bufExplorerShowDirectories=1
    "Valgrind
    let g:valgrind_arguments = "--leak-check=yes --num-callers=5000 --time-stamp=yes"
    let g:valgrind_use_horizontal_window = 1
    let g:valgrind_win_height = 7
    "DoxygenToolkit
    let g:DoxygenToolkit_authorName = "Aaron Griffin"
    let g:DoxygenToolkit_briefTag_funcName = "yes"
    "ShowMarks
    let g:showmarks_enable = 0
    let g:showmarks_ignore_type="hmpqr"
    "Buftabs
    let g:buftabs_only_basename = 1
    "Lisp syntax
    "let g:lisp_rainbow = 1
    - KD
    Last edited by KomodoDave (2007-05-04 13:34:16)

  • [Solved] The one thing I hate about Vim

    Hi,
    I've started using Vim some time ago and I now understand why everyone loves it.
    There's one thing, though, that is driving me nuts; a little but very irritating behaviour.
    I hope to be understandable enough so that someone can help me.
    Basically when editing (deleting or inserting characters)  a long line containing many words separated by spaces, Vim automatically moves  part of the line to a new line, creating a new paragraph.
    Do you see what I mean? I just don't want Vim to create new paragraphs when editing a line.
    I'm sure other Vim users already experienced this behaviour... how can I fix it?
    Here's my .vimrc, it may be involved somehow:
    " All system-wide defaults are set in $VIMRUNTIME/archlinux.vim (usually just
    " /usr/share/vim/vimfiles/archlinux.vim) and sourced by the call to :runtime
    " you can find below. If you wish to change any of those settings, you should
    " do it in this file (/etc/vimrc), since archlinux.vim will be overwritten
    " everytime an upgrade of the vim packages is performed. It is recommended to
    " make changes after sourcing archlinux.vim since it alters the value of the
    " 'compatible' option.
    " This line should not be removed as it ensures that various options are
    " properly set to work with the Vim-related packages available in Debian.
    runtime! archlinux.vim
    " If you prefer the old-style vim functionalty, add 'runtime! vimrc_example.vim'
    " Or better yet, read /usr/share/vim/vim72/vimrc_example.vim or the vim manual
    " and configure vim to your own liking!
    " no vi compatibility
    set nocompatible
    " directory
    set directory=/home/enrico/.vim
    " disable backups (and swap)
    set nobackup
    set nowritebackup
    set noswapfile
    " wrap searches
    set wrapscan
    " tab and indentation
    set tabstop=4
    set noexpandtab
    set smarttab
    set shiftwidth=4
    set backspace=indent,eol,start
    set autoindent
    set smartindent
    " show commands
    set showcmd
    " show line and column position of cursor
    set ruler
    " status bar
    set statusline=\ \%f%m%r%h%w\ ::\ %y\ [%{&ff}]\%=\ [%p%%:\ %l/%L]\
    set laststatus=2
    set cmdheight=1
    " textwidth
    set textwidth=79
    " formatting options
    set formatoptions=c,q,r,t
    " line numbers
    set number
    " match bracklets
    "set showmatch
    " search
    set hlsearch
    set incsearch
    set ignorecase
    set smartcase
    " syntax highlighting
    filetype plugin on
    syntax on
    " background
    set background=dark
    " enable mouse
    set mouse=a
    " set colorscheme
    colorscheme miromiro
    "colorscheme dante
    "colorscheme molokai
    "allows sudo with :w!!
    cmap w!! %!sudo tee > /dev/null %
    " mutt tricks (F1 through F3 re-wraps paragraphs)
    augroup MUTT
    au BufRead ~/.mutt/temp/mutt* set tw=72
    au BufRead ~/.mutt/temp/mutt* set spell " <-- vim 7 required
    au BufRead ~/.mutt/temp/mutt* nmap <F1> gqap
    au BufRead ~/.mutt/temp/mutt* nmap <F2> gqqj
    au BufRead ~/.mutt/temp/mutt* nmap <F3> kgqj
    au BufRead ~/.mutt/temp/mutt* map! <F1> <ESC>gqapi
    au BufRead ~/.mutt/temp/mutt* map! <F2> <ESC>gqqji
    au BufRead ~/.mutt/temp/mutt* map! <F3> <ESC>kgqji
    augroup END
    Thanks!
    Last edited by rent0n (2010-07-31 10:45:23)

    bernarcher wrote:
    This will suppress breaking the lines.
    " textwidth
    set textwidth=0
    See ":help textwidth" and ":help ins-textwidth" for more.
    BTW: "nowrap" does only influence how the text will be displayed. it doesn't change the text in the buffer.
    Thanks bernarcher, 'textwidth' was the option I was looking for!
    Wrapping is another thing and I like to keep it enabled.
    @quigybo: I will look through 'formatoptions', thanks. I already use augroup for mutt and is very handy indeed!
    Last edited by rent0n (2010-07-31 10:45:06)

  • [solved] vim ftplugin vim-latexsuite doesn't load changes with chars

    Hello!
    I'd like to use some european characters and I found this thread.
    Unfortunately I still get "/mathbf{}" when I type the ã. (My problem is the ö but I think if I manage to have the ã it will work with ö...)
    The second problem is that I have to press escape twice to go to normal mode in a .tex file.
    (In the other files one press is enough.)
    All these troubles happen only on my x86_64 desktop.
    I have vim-latexsuit-svn 1106-1 on both laptop and desktop from the AUR.
    On my i686 laptop everything works fine with the 'default' .vimrc advised in the vim-latexsuite-manual.
    There is also a different mapleader for compiling by default. (Which is not as annoying as the ö problem.)
    I also get the ö-trouble when I log in from the laptop to my desktop.
    Why are there so much differences?
    I only remember having put some "set winaltkeys=no" in the wrong files on my laptop before I understood where is the right place.
    (Where everything works fine.)
    Here's my .vimrc
    1 set tabstop=2
    2 set number
    3
    4 syntax on
    5 filetype plugin on
    6 filetype indent on
    7 set grepprg=grep\ -nH\ $*
    8 let g:tex_flavor = "latex"
    9 set runtimepath=~/.vim,/usr/share/vim/vimfiles,/usr/share/vim/vim72,/usr/share/vim/vimfiles/after,~/.vim/after
    10 "To solve the propleme with vim-latexsuite has with ã and â
    11 imap <buffer> <silent> <M-C> <Plug>Tex_MathCal
    12 imap <buffer> <silent> <M-B> <Plug>Tex_MathBF
    13 imap <buffer> <leader>it <Plug>Tex_InsertItemOnThisLine
    14 imap <buffer> <silent> <M-A> <Plug>Tex_InsertItem
    15 "imap <buffer> <silent> <M-E> <Plug>Tex_InsertItem
    16 "imap <buffer> <silent> <M-e> <Plug>Tex_InsertItemOnThisLine
    17 imap <buffer> <silent> <Plug>Traditional <Plug>Traditional
    18 map <buffer> <silent> é é
    19 map <buffer> <silent> á á
    20 map <buffer> <silent> ã ã
    21 "imap ã <Plug>Tex_MathCal
    22 "imap é <Plug>Traditional
    ~/.vim/ftplugin/tex.vim
    1 set winaltkeys=no
    2
    3 let g:Tex_AdvancedMath = 0
    4 let g:Tex_SmartKeyQuote = 0
    5 let g:Tex_SmartKeyQuote = 0
    6
    7 imap <C-b> <Plug>Tex_MathBF
    8 imap <C-c> <Plug>Tex_MathCal
    9 imap <C-l> <Plug>Tex_LeftRight
    ~/.vim/after/ftplugin/tex.vim
    (The macros of call IMAP work well. When I type `ö I also get a \mathbf)
    1 call IMAP('`w', '\omega', 'tex')
    2 call IMAP('`j', '\cdot', 'tex')
    3 call IMAP('`A', '\forall', 'tex')
    4 call IMAP('`E', '\exists', 'tex')
    5 call IMAP('`ö', 'ö', 'tex')
    6
    7 let g:Tex_AdvancedMath = 0
    8 imap <C-b> <Plug>Tex_MathBF
    9 imap <C-c> <Plug>Tex_MathCal
    10 imap <C-l> <Plug>Tex_LeftRight
    runtimepath:
    runtimepath=~/.vim,/usr/share/vim/vimfiles,/usr/share/vim/vim72,/usr/share/vim/vimfiles/after,~/.vim/after
    Last edited by Maximalminimalist (2010-05-30 17:00:03)

    I just removed vim, vim-auctex (didn't remember there was this...) and vim-latexsuite and reinstalled vim and vim-latexsuite.
    I was obviously using a vim-auctex macro and I didn't know it... (This was a memorable lesson for removing packages you don't need. )
    I realized that the Esc-issue happens if a placeholder is still active. Is it possible to change this behaviour? (I won't really care about that. => [solved])
    Last edited by Maximalminimalist (2010-05-30 16:59:32)

  • Vim reasonable defaults for all users.

    now the vim package keeps a less-than-minimal set of default settings. So keeping the old default as starting point I made what I think is a reasonable default:
    " Use Vim settings, rather then Vi settings (much better!).
    " This must be first, because it changes other options as a side effect.
    set nocompatible
    " allow backspacing over everything in insert mode
    set backspace=indent,eol,start
    set history=50 " keep 50 lines of command line history
    set ruler " show the cursor position all the time
    set showcmd " display incomplete commands
    set incsearch " do incremental searching
    set listchars=tab:˛\ ,trail:┈ " show trail spaces and tabs
    set list
    set wildmode=list:longest,full " use the new menus
    set wildmenu
    set background=dark " who uses white terminals anyway?
    "statusline: filename, filetype, mod, rw, help, preview,
    set statusline=%t\ %y\ %m%r%h%w
    "statusline: separation between lef and right aligned items
    set statusline+=%=
    "statusline: lines number, column number, percent
    set statusline+=[L:\ %l/%L]\ [C:\ %v]\ [%p%%]
    set laststatus=2 " always show status line
    set highlight+=sn
    " Don't use Ex mode, use Q for formatting
    map Q gq
    " Use space and backspace to scroll the document
    map <space> <c-d>
    map <bs> <c-u>
    " Disable f1, if you need help use `:help'
    map <f1> <nop>
    map ; :
    " CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
    " so that you can undo CTRL-U after inserting a line break.
    inoremap <C-U> <C-G>u<C-U>
    " In many terminal emulators the mouse works just fine, thus enable it.
    if has('mouse')
    set mouse=a
    endif
    " Switch syntax highlighting on, when the terminal has colors
    " Also switch on highlighting the last used search pattern.
    if &t_Co > 2 || has("gui_running")
    syntax on
    set hlsearch
    endif
    " Only do this part when compiled with support for autocommands.
    if has("autocmd")
    " Enable file type detection.
    " Use the default filetype settings, so that mail gets 'tw' set to 72,
    " 'cindent' is on in C files, etc.
    " Also load indent files, to automatically do language-dependent indenting.
    filetype plugin indent on
    " Put these in an autocmd group, so that we can delete them easily.
    augroup vimrcEx
    au!
    " For all text files set 'textwidth' to 78 characters.
    autocmd FileType text setlocal textwidth=78
    " When editing a file, always jump to the last known cursor position.
    " Don't do it when the position is invalid or when inside an event handler
    " (happens when dropping a file on gvim).
    " Also don't do it when the mark is in the first line, that is the default
    " position when opening a file.
    autocmd BufReadPost *
    \ if line("'\"") > 1 && line("'\"") <= line("$") |
    \ exe "normal! g`\"" |
    \ endif
    augroup END
    else
    set autoindent " always set autoindenting on
    endif " has("autocmd")
    " Convenient command to see the difference between the current buffer and the
    " file it was loaded from, thus the changes you made.
    " Only define it when not defined already.
    if !exists(":DiffOrig")
    command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
    \ | wincmd p | diffthis
    endif
    I put it here hoping it helps you or yours users' vim experience. Please leave any comment.
    Last edited by ezzetabi (2009-09-30 13:53:47)

    Hi, I think this is not a bad idea. I do like using listchars to show tabs and trailing spaces like that, but I think that using commoly used characters like _ is confusing. If you go into vim and use the :digraph command you can see lots of special characters which are useful IMO for listchars. I use set listchars=tab:→,trail:¸, but I don't know if they'd be best for everyone. But I think it is clearer than using normal keyboard characters.

  • [SOLVED] `Vim/Gvim: set mouse=a works only in Gvim?

    I'm diving into the world of (g)vim this weekend and although I'm starting to get the hang of things, I seem to be having a problem with the mouse functionality.  I have set mouse=a specified in my .vimrc and gvim respects it, but when I run vi in a terminal session (urxvt) I have to explicitly type :set mouse=a in ex mode before it will work.  Am I missing something?
    Here's what I've got in my .vimrc (linked also ~/.gvimrc) so far:
    " (G)vim settings
    set nocompatible " use gVim defaults
    colorscheme wombat " define syntax color scheme
    syntax on " enable syntax highlighting
    set mouse=a " make sure mouse is used in all cases.
    set backspace=2 " full backspacing capabilities
    set nocindent " set C style indenting off
    set cmdheight=2 " command line height
    set ignorecase " ignore case in search patterns
    set laststatus=2 " occasions to show status line, 2=always.
    set ruler " ruler display in status line
    set showmode " show mode at bottom of screen
    set number " toggle line numbers
    set nobackup " disable backup files (filename~)
    set hlsearch " highlight all search results
    set showmatch " show matching brackets (),{},[]
    " Gvim Settings
    set guioptions-=T " disable toolbar icons
    set guifont=Consolas\ 8 " backslash any spaces
    SOLVED: Silly me I was running 'vi' which has no X support... pacman -S vim fixed it fine.
    Last edited by thayer.w (2007-09-04 00:02:49)

    I just had an issue with no sound after recent updates.  Not sure it's the same problem you are having. 
    I found I had to open Audio Mixer, select Sound card: HDA Intel PCH (Alsa mixer), Select Controls, check box for Speaker and check box for Headphones.  After doing this I found the Speaker volume was set at minimum (although Master and PCM were already set at maximum).  Adjusted Speaker volume up and I finally had sound again.

  • Vim latex-suite and auto completion

    Hi,
    according to this introduction you have to hit <enter> to chose a bib entry after pressing F9 in \cite{ :
    My problem is that I see the bib entries but when I hit enter the windows close and I'm back in my tex file with no entry in the \cite bracket. When I typed in the first letters of the bib key these are also erased.
    Any ideas?
    Here's my .vimrc
    " Use Vim settings, rather then Vi settings (much better!).
    " This must be first, because it changes other options as a side effect.
    set nocompatible
    filetype plugin on
    filetype indent on
    set grepprg=grep\ -nH\ $*
    let g:tex_flavor = "latex"
    " switch on syntax highlighting
    syntax on
    let g:Tex_DefaultTargetFormat = 'pdf'
    let g:Tex_CompileRule_pdf = 'latexmk -pdf -pv -g'
    set runtimepath=~/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,~/.vim/after
    " A clean-looking font for gvim
    set guifont="DejaVu\ Sans\ Mono\ 8"
    " allow backspacing over everything in insert mode
    set backspace=indent,eol,start
    set history=100 " keep 100 lines of command line history
    set ruler " show the cursor position all the time
    set showcmd " display incomplete commands
    " set mouse -=a
    set shortmess+=I " disable the welcome screen
    " line numbering
    set nu
    " wrap like other editors
    set wrap " word wrap
    set textwidth=0 "
    set lbr " line break
    set display=lastline " don't display @ with long paragraphs
    " searching
    set hlsearch " highlight all search results
    set incsearch " increment search
    set ignorecase " case-insensitive search
    set smartcase " upper-case sensitive search
    " nice colours
    set t_Co=256
    " colorscheme twigight
    " colorscheme desert256
    " colorscheme tlvb
    " colorscheme zenburn
    colorscheme ir_black
    " scroll one screen line regardless of editor line length
    :noremap <Up> gk
    :noremap! <Up> <C-O>gk
    :noremap <Down> gj
    :noremap! <Down> <C-O>gj
    :noremap k gk
    :noremap j gj
    set enc=utf-8
    " Scrollbars
    set sidescrolloff=2
    set numberwidth=4

    Hi davvil,
    thanks for your reply. There are no whitespaces. The only thing I've noticed is, that the indention of the entries is different (INCOLLECTION, BOOK, etc isn't idented, though).
    My bib was partly created by JabRef and by entries made by me. I'll check if the problem also occurs with a new bib made from scratch.

  • Questions about tabs, spaces and indenting

    I tried to find some information about this in the forum, but I didn't succeed (perhaps I failed at the search). My apologies if this a trivial topic, but as I'm in the learning process of programming (I started with Python and php myself, and Pascal at college) this is a new world to me.
    Yesterday I was editing a txt file in Vim, and I encounter a few issues trying to print it. That's when I learned that tabbing all the way thought to format some text maybe is not a good idea. Then a guy in #Vim directed me to use spaces instead of tabs for indenting and formating the text / programs that I write, as the tab indenting is -almost- only needed by makefiles. Also he showed me than in Python programming it is suggested to use spaces as well.
    I googled a bit and I found sites like this, with pros and cons about both styles. Also I found a Vim plugin (Smart Tabs) that at first sight seems quite nice, like it have the best of both worlds.
    So my question here is: what should I do? Choose one style and stick with it for ever? Choose according the language? Mix up both? Without any experience on this subject it's hard to know the right way, as it seems that both styles have (strong) advantages and disadvantages.
    Also, if is not too much no ask, what tab size should I work with? 8 seems a bit large, although seems to be pretty standard for some languages.
    Currently I've this on my .vimrc (the relevant part, of course):
    set tabstop=4
    set shiftwidth=4
    set softtabstop=4
    set expandtab
    set autoindent
    set smartindent
    Thanks in advance for any advice.

    Yes, I think to "choose one style and stick with it" is the most important thing.
    I always use two spaces to indent because I like the way it looks. Besides makefiles, I don't use any language that forces me to use either tabs or spaces, so that's not a problem.
    I really like this quote:
    Linus Torvalds wrote:If you need more than 3 levels of indentation, you're screwed anyway, and should fix your program.
    (from Wikiquote) After reading that, I don't think about indentation as much anymore.
    Sorry for my English. Feel free to point my errors.
    "Sorry for my English. Feel free to point out my errors." ^_^

  • Vim newbie question about formatting code

    I just started learning vim and am wondering how I can get it to auto format some code.  For example:
    check() {
    for i in $nodes; do
    ping -c 1 $i > /dev/null
    if [ $? -eq 0 ]; then
    echo "Looks like $i is up so initializing the cluster on it."
    ssh $i "\$HOME/bin/cluster-setup.sh"
    fi
    done
    I have tabstop=3 in my ~/.vimrc and I'd just like to apply formatting to that code block so it looks like:
    check() {
    for i in $nodes; do
    ping -c 1 $i > /dev/null
    if [ $? -eq 0 ]; then
    echo "Looks like $i is up so initializing the cluster on it."
    ssh $i "\$HOME/bin/cluster-setup.sh"
    fi
    done
    I read about =i{ but it has no effect for me.
    Thanks!
    Last edited by graysky (2011-06-18 14:32:18)

    graysky,
    If you want vim to autoindent while typing, customize your ~/.vimrc file. I posted mine here: http://linuxandsuch.wordpress.com/2011/06/19/my-vimrc/ a few days back. I recommend all the options.
    However, if you want to indent an already existing file use the indent program. Install with
    sudo pacman -S indent
    And then, to indent your file, run:
    indent myfile.c
    I'd recommend reading the manpage for indent to learn to tweak it to your coding style though .

Maybe you are looking for

  • Parsing XML In UDF

    Hello all,         I am getting a complete XML file as a string in a single element of a input message . can anyone please provide me the code template of how to parse this XML  in UDF . Thanks, Keith

  • Cannot open microsoft word in yosemite

    Downloaded Yosemite Now, cannot open microsoft word

  • Services are in stop condition

    Hi, We installed Dev & Quality systems for PI/XI-7.0 on same host, We are taking central SLD on Dev for Quality system, We are following note-940309,regarding this note we have to change the client for the following services 1) AI_DIRECTORY_<sid> 2)

  • Editing forms in version 9 problem

    All prior to 9 versions of Acrobat Pro allowed to use "select all" command for one kind of fields, for example all text fields or all check mark fields, allowing to apply changes (like size of font for example) to all selected text fields at once or

  • Bridge CS4 with very large image archves

    I have just catalogued 420,000 images from 3TB of my photographic collection. For those interested, the master cache files became quite large and took about 9 days of continuous processing: cache size: 140 gb file count: 991,000 folder count: 3000 Al