Thursday, September 27, 2012

Re: vim cannot indent awk correctly

On Sep 27, 11:47 am, Ben Fritz <fritzophre...@gmail.com> wrote:
> On Thursday, September 27, 2012 10:59:50 AM UTC-5, Peng Yu wrote:
> > The following is the indented results of an awk file.
>
> > ~/linux/test/awk/lang/operator/[$ cat main.awk
>
> > BEGIN {
>
> > }
>
> > {
>
> > }
>
> > END {
>
> > }
>
> > I have the following vim installed (from MacVim). Is there a problem
>
> > with vim? Or there is some problem with my installation?
>
> > ~/linux/test/awk/lang/operator/[$ gvim --version
>
> > VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Sep 1 2012 18:08:47)
>
> > MacOS X (unix) version
>
> > Included patches: 1-646
>
> > Compiled by Bjorn Winckler <bjorn.winck...@gmail.com>
>
> > Huge version with MacVim GUI. Features included (+) or not (-):
>
> Your Vim version looks pretty recent. I'm going to assume the standard runtime plugins are also recent.
>
> Do you have any awk filetype plugins which you've manually installed?
>
> How did you achieve the indent you show (i.e. what commands did you execute to achieve that indent)? What are your indent options set to? These are:
>
> 'autoindent'
> 'smartindent'
> 'cindent'
> 'indentexpr'
>
> Do you have filetype-based indent turned on? I.e., do you have something like:
>
> filetype plugin indent on

I have the above line in my .vimrc. See my .vimrc below.

I have many plugins installed, I'm not sure how they can affect awk
files. But there are all the *.vim files in ~/.vim/. Please let me
know if there any more info needed to diagnose this problem. Thanks!

Regards,
Peng

$ cat ~/.vimrc
call pathogen#infect()

filetype plugin on
filetype indent on

set hidden

"delete whole word
map dW daW
map dw daw

"xml indent
"au FileType xml exe ":silent 1,$!xmllint --format --recover - 2>/dev/
null"
"let g:xml_syntax_folding=1
"au FileType xml setlocal foldmethod=syntax

" csv.vim comment
let g:csv_comment = '#'

" highlight spelling check in GUI
"hi SpellBad gui=NONE guibg=Red

" vim-pandoc
"let g:pandoc_no_spans=1
"enable the following to speed up
"let g:pandoc_no_empty_implicits=1
"let g:pandoc_no_folding=1

"LargeFile.vim
let g:LargeFile = 5

"set formatoptions-=ro

"json indentation
"http://visibletrap.blogspot.com/2010/05/vim-how-to-format-and-syntax-
highlight.html

"VIM - How to format and syntax highlight JSON file
map <leader>jt <Esc>:%!json_xs -f json -t json-pretty<CR>

"folding settings
set foldmethod=indent "fold based on indent
set foldnestmax=10 "deepest fold is 10 levels
set nofoldenable "dont fold by default
set foldlevel=1 "this is just what i use

" scons
au BufNewFile,BufRead SCons* set filetype=scons

" search program
set grepprg=findstr.py

" set make program
set makeprg=makepp\ -s

"R Plugin
"do not convert _ to <-
let g:vimrplugin_underscore = 0

"open file under cursor
"map <F8> :exe "below new ".expand("<cfile>")<CR>
map <F7> :exe "below new ".expand("<cfile>")<CR>
map <S-F7> :exe "new ".expand("<cfile>")<CR>

" My configurations
set nobackup
" set linebreak

" code style
"set equalprg=astyle

" do not go to line start
set nostartofline

set shiftwidth=2
set expandtab
set sts=2
set ts=2

"Set working directory to the current file
map ,cd :cd %:p:h<CR>

set incsearch "incremental search

set sm "When a bracket is inserted, briefly jump to the matching one.

set nu
"winpos 0 0
set bg=dark
highlight Normal guibg=Black guifg=White
syntax enable
set nohlsearch

" Like windo but restore the current window.
function! WinDo(command)
let currwin=winnr()
execute 'windo ' . a:command
execute currwin . 'wincmd w'
endfunction
com! -nargs=+ -complete=command Windo call WinDo(<q-args>)

" Like bufdo but restore the current buffer.
function! BufDo(command)
let currBuff=bufnr("%")
execute 'bufdo ' . a:command
execute 'buffer ' . currBuff
endfunction
com! -nargs=+ -complete=command Bufdo call BufDo(<q-args>)

" Like tabdo but restore the current tab.
function! TabDo(command)
let currTab=tabpagenr()
execute 'tabdo ' . a:command
execute 'tabn ' . currTab
endfunction
com! -nargs=+ -complete=command Tabdo call TabDo(<q-args>)

command! WA Bufdo w!

" The value of this option influences when the last window will have a
status line:
" 2: always
set laststatus=2

"filename completion with @
set isfname+=@-@

"for interprete .tex file as latex file
let g:tex_flavor='latex'

"Empty *.m files will automatically be presumed to be Matlab files
unless you have the following in your .vimrc:
let filetype_m = "mma"

" match < and >
set matchpairs+=<:>

" gf search path
"set path=.,$DFM/**
"Note the trailing semicolon - it enables upwards-recursive search of
tags file. For example, if your editing file src/dblayer/engine/
query.c and press C-] for some function, VIM will search the tags file
in the following order:
set tags=./tags;

" no bells wanted
set vb t_vb=
" must reset it again when the GUI starts
if has("gui")
autocmd GUIEnter * set t_vb=
endif

set wildmode=longest:list

function ToggleHLSearch()
if &hls
set nohls
else
set hls
endif
endfunction
nmap <silent> <C-n> :silent call ToggleHLSearch()<CR>

map <S-F4> <ESC>:wa<kEnter>:make o<kEnter>:cope<kEnter>
map <F4> <ESC>:w<kEnter>:make<kEnter>:cope<kEnter>
map <S-F6> <ESC>:!gnome-terminal &<kEnter>
map <F6> <ESC>:setlocal spell spelllang=en_us<kEnter>
"nnoremap <silent> <F7> :TlistToggle<CR>

"no space when joining
nnoremap gJ Jdiw

"fu! <SID>SwapWords(...) range
" if len(a:000)!= 2
" echomsg "SwapWords has to be called with 2 Arguments!"
" return
" elseif (search(a:1 ,'n') == 0 || search(a:2, 'n') == 0)
" echomsg "not both args found"
" return
" endif
"
" let pat=join(map(copy(a:000), '"\\%(" .v:val. "\\)"'), '\|')
" :exe a:firstline . ',' . a:lastline . 's/'.pat. '/
\=printf("%s",submatch(0)==a:1 ? a:2 : a:1 )/'
"endfu
"com! -nargs=+ -range=% Swap :<line1>,<line2>call <SID>SwapWords(<f-
args>)

"vim session
set
sessionoptions=blank,buffers,curdir,folds,help,resize,tabpages,winsize
map <c-q> :mksession! ~/.vim/.session <cr>
map <c-s> :source ~/.vim/.session <cr>

"full file indent
fun BenIndent()
let oldLine=line('.')
normal gg=G
execute ':' . oldLine
endfun
"map -- :call BenIndent()<Bar>normal zz<CR>
map -- :call BenIndent()<CR>

map p p
map gp gp
map P P`[
map gP gP`[
" My configurations

" vim -b : edit binary using xxd-format!
augroup Binary
au!
au BufReadPre *.bin let &bin=1
au BufReadPost *.bin if &bin | %!xxd
au BufReadPost *.bin set ft=xxd | endif
au BufWritePre *.bin if &bin | %!xxd -r
au BufWritePre *.bin endif
au BufWritePost *.bin if &bin | %!xxd
au BufWritePost *.bin set nomod | endif
augroup END

" automatically load
set autoread

" do not notife swp file
augroup SwapClobber
au!
au SwapExists * let v:swapchoice='e'
augroup END

" From Bram:
" 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).
" DF - Also do not do this if the file resides in the $TEMP directory,
" chances are it is a different file with the same name.
" This comes from the $VIMRUNTIME/vimrc_example.vim file

" Suresh Govindachar, September 24, 2004 19:57
" I have made a modification: Do not open the fold in
" the special case of the cursor being on the edge of
" an increasing fold. So, the fold will not be opened
" in the following two cases:
"
" 1) cursor is on line 1
" 2) cursor is on the edge of a fold and the
" foldlevel of the previous line is smaller than
" that of the current line.
" I also created an augroup.
augroup JumpCursorOnEdit
au!
autocmd BufReadPost *
\ if expand("<afile>:p:h") !=? $TEMP |
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ let JumpCursorOnEdit_foo = line("'\"") |
\ let b:doopenfold = 1 |
\ if (foldlevel(JumpCursorOnEdit_foo) >
foldlevel(JumpCursorOnEdit_foo - 1)) |
\ let JumpCursorOnEdit_foo = JumpCursorOnEdit_foo - 1 |
\ let b:doopenfold = 2 |
\ endif |
\ exe JumpCursorOnEdit_foo |
\ endif |
\ endif
" Need to postpone using "zv" until after reading the modelines.
autocmd BufWinEnter *
\ if exists("b:doopenfold") |
\ exe "normal zv" |
\ if(b:doopenfold > 1) |
\ exe "+".1 |
\ endif |
\ unlet b:doopenfold |
\ endif
augroup END

"Tip 1554 Previous Next created April 18, 2008 · complexity
intermediate · author Paluh · version 7.0
"
"These two functions allow you to move window between tabs. Unlike
the :tabmove command, which moves an entire tab to a new position,
these functions will move a window in the current tab into another
existing tab (or a new tab if there are no other existing tabs).
"
"For example, assume you are editing files in three tabs: [1],[2],[3]
– where [] indicates a tab page, and the list of numbers inside
brackets shows the windows open in that tab (when there is more than
one window in one tab, the script splits it horizontally).
"
"Assume that we are in the first tab (so we are editing window with
buffer with file 1 – bold marks current window). After :call
MoveToNextTab() there will be [1,2],[3]. After the next :call
MoveToNextTab() the windows will be arranged thusly: [2][1,3]. And
after next one: [2],[3],[1].
"
"Of course MoveToPrevTab() works in opposite direction.

function MoveToPrevTab()
"there is only one window
if tabpagenr('$') == 1 && winnr('$') == 1
return
endif
"preparing new window
let l:tab_nr = tabpagenr('$')
let l:cur_buf = bufnr('%')
if tabpagenr() != 1
close!
if l:tab_nr == tabpagenr('$')
tabprev
endif
sp
else
close!
exe "0tabnew"
endif
"opening current buffer in new window
exe "b".l:cur_buf
endfunc

function MoveToNextTab()
"there is only one window
if tabpagenr('$') == 1 && winnr('$') == 1
return
endif
"preparing new window
let l:tab_nr = tabpagenr('$')
let l:cur_buf = bufnr('%')
if tabpagenr() < tab_nr
close!
if l:tab_nr == tabpagenr('$')
tabnext
endif
sp
else
close!
tabnew
endif
"opening current buffer in new window
exe "b".l:cur_buf
endfunc

nnoremap <A-.> :call MoveToNextTab()<CR>
nnoremap <A-,> :call MoveToPrevTab()<CR>

" Add a blank line below the cursor.
map <A-o> o<Up><Esc>
" Add a blank line above the cursor.
map <A-O> O<Down><Esc>

autocmd FileType r setlocal comments=b:#,b:##,b:###,b:#'
"vim-latex
let g:Tex_Menus = 0
let g:Tex_MathMenus = 0
"disable IMap
let g:Imap_FreezeImap = 1
"let g:Tex_SmartKeyQuote = 0

" http://vimcasts.org/episodes/show-invisibles/
" Shortcut to rapidly toggle `set list`
nmap <leader>l :set list!<CR>
" Use the same symbols as TextMate for tabstops and EOLs
set listchars=tab:▸\ ,eol:¬



~/.vim$ find . -name '*.vim'
./after/filetype.vim
./after/ftplugin/html.vim
./after/ftplugin/r.vim
./after/syntax/r.vim
./autoload/AnsiEsc.vim
./autoload/dbext.vim
./autoload/dbext_dbi.vim
./autoload/pathogen.vim
./autoload/rails.vim
./autoload/sqlcomplete.vim
./autoload/tabular.vim
./autoload/xquerycomplete.vim
./bundle/csv.vim
./bundle/html5.vim
./bundle-available/cmake-vim/ftdetect/cmake.vim
./bundle-available/cmake-vim/indent/cmake.vim
./bundle-available/cmake-vim/syntax/cmake.vim
./bundle-available/csv.vim
./bundle-available/csv.vim/ftdetect/csv.vim
./bundle-available/csv.vim/ftplugin/csv.vim
./bundle-available/csv.vim/plugin/csv.vim
./bundle-available/csv.vim/syntax/csv.vim
./bundle-available/html5.vim
./bundle-available/html5.vim/autoload/htmlcomplete.vim
./bundle-available/html5.vim/autoload/xml/aria.vim
./bundle-available/html5.vim/autoload/xml/html5.vim
./bundle-available/html5.vim/indent/html.vim
./bundle-available/html5.vim/syntax/html/aria.vim
./bundle-available/html5.vim/syntax/html/rdfa.vim
./bundle-available/html5.vim/syntax/html.vim
./bundle-available/html5.vim/syntax/javascript/html5.vim
./bundle-available/jade/ftdetect/jade.vim
./bundle-available/jade/ftplugin/jade.vim
./bundle-available/jade/indent/jade.vim
./bundle-available/jade/syntax/jade.vim
./bundle-available/matlab/compiler/mlint.vim
./bundle-available/matlab/ftplugin/matlab.vim
./bundle-available/matlab/indent/matlab.vim
./bundle-available/matlab/syntax/matlab.vim
./bundle-available/nerdtree/nerdtree_plugin/exec_menuitem.vim
./bundle-available/nerdtree/nerdtree_plugin/fs_menu.vim
./bundle-available/nerdtree/plugin/NERD_tree.vim
./bundle-available/nerdtree/syntax/nerdtree.vim
./bundle-available/RST-Tables/plugin/rst_table.vim
./bundle-available/vim-jade/ftdetect/jade.vim
./bundle-available/vim-jade/ftplugin/jade.vim
./bundle-available/vim-jade/indent/jade.vim
./bundle-available/vim-jade/syntax/jade.vim
./bundle-available/vim-javascript/ftdetect/javascript.vim
./bundle-available/vim-javascript/indent/javascript.vim
./bundle-available/vim-javascript/syntax/javascript.vim
./bundle-available/vim-jst/ftdetect/jst.vim
./bundle-available/vim-jst/indent/jst.vim
./bundle-available/vim-jst/syntax/jst.vim
./bundle-available/vim-latex-suite/compiler/tex.vim
./bundle-available/vim-latex-suite/ftplugin/bib_latexSuite.vim
./bundle-available/vim-latex-suite/ftplugin/latex-suite/bibtex.vim
./bundle-available/vim-latex-suite/ftplugin/latex-suite/brackets.vim
./bundle-available/vim-latex-suite/ftplugin/latex-suite/compiler.vim
./bundle-available/vim-latex-suite/ftplugin/latex-suite/
custommacros.vim
./bundle-available/vim-latex-suite/ftplugin/latex-suite/diacritics.vim
./bundle-available/vim-latex-suite/ftplugin/latex-suite/
elementmacros.vim
./bundle-available/vim-latex-suite/ftplugin/latex-suite/envmacros.vim
./bundle-available/vim-latex-suite/ftplugin/latex-suite/folding.vim
./bundle-available/vim-latex-suite/ftplugin/latex-suite/main.vim
./bundle-available/vim-latex-suite/ftplugin/latex-suite/mathmacros-
utf.vim
./bundle-available/vim-latex-suite/ftplugin/latex-suite/mathmacros.vim
./bundle-available/vim-latex-suite/ftplugin/latex-suite/
multicompile.vim
./bundle-available/vim-latex-suite/ftplugin/latex-suite/packages.vim
./bundle-available/vim-latex-suite/ftplugin/latex-suite/
projecttemplate.vim
./bundle-available/vim-latex-suite/ftplugin/latex-suite/smartspace.vim
./bundle-available/vim-latex-suite/ftplugin/latex-suite/templates.vim
./bundle-available/vim-latex-suite/ftplugin/latex-suite/
texmenuconf.vim
./bundle-available/vim-latex-suite/ftplugin/latex-suite/texproject.vim
./bundle-available/vim-latex-suite/ftplugin/latex-suite/texviewer.vim
./bundle-available/vim-latex-suite/ftplugin/latex-suite/version.vim
./bundle-available/vim-latex-suite/ftplugin/latex-suite/
wizardfuncs.vim
./bundle-available/vim-latex-suite/ftplugin/tex_latexSuite.vim
./bundle-available/vim-latex-suite/indent/tex.vim
./bundle-available/vim-latex-suite/plugin/filebrowser.vim
./bundle-available/vim-latex-suite/plugin/imaps.vim
./bundle-available/vim-latex-suite/plugin/libList.vim
./bundle-available/vim-latex-suite/plugin/remoteOpen.vim
./bundle-available/vim-latex-suite/plugin/SyntaxFolds.vim
./bundle-available/vim-pandoc/autoload/pandoc.vim
./bundle-available/vim-pandoc/autoload/pandoc_bib.vim
./bundle-available/vim-pandoc/autoload/pandoc_exec.vim
./bundle-available/vim-pandoc/autoload/pandoc_misc.vim
./bundle-available/vim-pandoc/ftdetect/pandoc.vim
./bundle-available/vim-pandoc/ftplugin/pandoc.vim
./bundle-available/vim-pandoc/plugin/pandoc.vim
./bundle-available/vim-pandoc/syntax/pandoc.vim
./bundle-available/vim-perl/ftplugin/perl.vim
./bundle-available/vim-perl/ftplugin/perl6.vim
./bundle-available/vim-perl/ftplugin/xs.vim
./bundle-available/vim-perl/indent/perl.vim
./bundle-available/vim-perl/indent/perl6.vim
./bundle-available/vim-perl/syntax/perl.vim
./bundle-available/vim-perl/syntax/perl6.vim
./bundle-available/vim-perl/syntax/pod.vim
./bundle-available/vim-perl/syntax/tt2.vim
./bundle-available/vim-perl/syntax/tt2html.vim
./bundle-available/vim-perl/syntax/xs.vim
./bundle-available/vim-perl/t/define_all.vim
./bundle-available/Vim-R-plugin/autoload/rcomplete.vim
./bundle-available/Vim-R-plugin/ftdetect/r.vim
./bundle-available/Vim-R-plugin/ftplugin/r.vim
./bundle-available/Vim-R-plugin/ftplugin/rbrowser.vim
./bundle-available/Vim-R-plugin/ftplugin/rdoc.vim
./bundle-available/Vim-R-plugin/ftplugin/rhelp.vim
./bundle-available/Vim-R-plugin/ftplugin/rnoweb.vim
./bundle-available/Vim-R-plugin/indent/r.vim
./bundle-available/Vim-R-plugin/indent/rhelp.vim
./bundle-available/Vim-R-plugin/indent/rnoweb.vim
./bundle-available/Vim-R-plugin/r-plugin/common_buffer.vim
./bundle-available/Vim-R-plugin/r-plugin/common_global.vim
./bundle-available/Vim-R-plugin/r-plugin/global_r_plugin.vim
./bundle-available/Vim-R-plugin/r-plugin/tex_indent.vim
./bundle-available/Vim-R-plugin/syntax/r.vim
./bundle-available/Vim-R-plugin/syntax/rbrowser.vim
./bundle-available/Vim-R-plugin/syntax/rdoc.vim
./bundle-available/Vim-R-plugin/syntax/rhelp.vim
./bundle-available/Vim-R-plugin/syntax/rout.vim
./bundle-available/vim-racket/ftdetect/racket.vim
./bundle-available/vim-racket/ftplugin/racket.vim
./bundle-available/vim-racket/indent/racket.vim
./bundle-available/vim-racket/syntax/racket.vim
./compiler/scons.vim
./filetype.vim
./ftdetect/bed.vim
./ftdetect/bug.vim
./ftdetect/jags.vim
./ftdetect/json.vim
./ftdetect/markdown.vim
./ftdetect/sam.vim
./ftplugin/bed.vim
./ftplugin/docbk.vim
./ftplugin/html.vim
./ftplugin/perl/pod-helper.vim
./ftplugin/perl.vim
./ftplugin/perl6.vim
./ftplugin/python.vim
./ftplugin/sam.vim
./ftplugin/xhtml.vim
./ftplugin/xml.vim
./ftplugin/xquery.vim
./ftplugin/xs.vim
./ftplugin/xsl.vim
./plugin/a.vim
./plugin/AnsiEscPlugin.vim
./plugin/cecutil.vim
./plugin/dbext.vim
./plugin/head.vim
./plugin/IndentAnything.vim
./plugin/LargeFile.vim
./plugin/matchit.vim
./plugin/pydoc.vim
./plugin/rails.vim
./plugin/Tabular.vim
./record/pod-helper.vim
./syntax/bug.vim
./syntax/jags.vim
./syntax/markdown.vim
./syntax/perl.vim
./syntax/perl6.vim
./syntax/pod.vim
./syntax/pyrex.vim
./syntax/python.vim
./syntax/scons.vim
./syntax/tt2.vim
./syntax/tt2html.vim
./syntax/xs.vim

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: