Vim 7.3 hanging on Win7 PC

54 views
Skip to first unread message

Waters, Bill

unread,
Nov 16, 2012, 5:35:17 PM11/16/12
to vim...@googlegroups.com
I have been using Vim for years, and this is a first. It is hanging on a Win7 PC. When it happens, the CPU gets pegged and I have to forcibly kill Vim.

With this code snippet, it always happens when I type the '=' at the end of the line below. (I blanked out my variables names in this code example. That doesn't have an effect on the problem.)

switch (P________e)
{
case P______________________a:
{
// Check for compatible Specification Revision
if (((1 << R_____________r->S___________________n) &
S___________________n.A_____________________s) =
{
// TODO
}

It doesn't always happen with an '=' at the end of a line, but when it does happen, it is when I type and '=' at the end of the line.

It does not happen when I change the code to this...

switch (P________e)
{
case P______________________a:
{
// Check for compatible Specification Revision
if (((1 << a->b) &
d.e) =
{
// TODO
}

Or this...

switch (P________e)
{
case P______________________a:
{
// Check for compatible Specification Revision
if (((1 << a->b) &
dddddd.eeee) =
{
// TODO
}

How do I start debugging/isolating the problem? Is there a way to debug once Vim is hung? Is there a way to get it un-hung?

I don't use many plugins, but I am using a few.

When it happens, and I press the red X-button on the Win7 window, it does ask if I want to save my changes. And the save is performed, and the window does close.

I attached my _vimrc file.

Thanks,
Bill Waters
_vimrc

Ben Fritz

unread,
Nov 16, 2012, 6:59:18 PM11/16/12
to vim...@googlegroups.com
On Friday, November 16, 2012 4:36:29 PM UTC-6, Bill Waters wrote:
> I have been using Vim for years, and this is a first. It is hanging on a Win7 PC. When it happens, the CPU gets pegged and I have to forcibly kill Vim.
>
>
>
> With this code snippet, it always happens when I type the '=' at the end of the line below. (I blanked out my variables names in this code example. That doesn't have an effect on the problem.)
>

Is this C code or something else?

Do you have your 'foldmethod' set to "syntax"? (I did not see an attachment).

Vim has problems with syntax folding taking a long time to update, especially while you type in insert mode, although I've not seen it "hang" Vim before. Try setting foldmethod to "manual" if it is currently set to "syntax" to see if the problem goes away. If so, try this:

http://vim.wikia.com/wiki/Keep_folds_closed_while_inserting_text

As for stopping it, if you have NOT mapped CTRL-C to something else (I sure hope you haven't), you can interrupt many actions simply by pressing CTRL-C.

Finally, if none of the above helps:

Can you reproduce without your _vimrc and customizations, by launching Vim with gvim -N -u NONE -i NONE -U NONE ?

Waters, Bill

unread,
Nov 19, 2012, 3:39:35 PM11/19/12
to vim...@googlegroups.com
>On Friday, November 16, 2012 4:36:29 PM UTC-6, Bill Waters wrote:
>> I have been using Vim for years, and this is a first. It is hanging on a
>> Win7 PC. When it happens, the CPU gets pegged and I have to forcibly kill
>> Vim.
>>
>>
>>
>> With this code snippet, it always happens when I type the '=' at the end
>> of the line below. (I blanked out my variables names in this code example.
>> That doesn't have an effect on the problem.)
>>
>
>Is this C code or something else?

This is C

>
>Do you have your 'foldmethod' set to "syntax"? (I did not see an attachment).
>

I don't have a 'foldmethod' setting in my _vimrc, and when I do a ":set
foldmethod" it says that it is set to "manual".


>Vim has problems with syntax folding taking a long time to update, especially
>> while you type in insert mode, although I've not seen it "hang" Vim before.
>> Try setting foldmethod to "manual" if it is currently set to "syntax" to see
>> if the problem goes away. If so, try this:
>
>http://vim.wikia.com/wiki/Keep_folds_closed_while_inserting_text
>
>As for stopping it, if you have NOT mapped CTRL-C to something else (I sure
>> hope you haven't), you can interrupt many actions simply by pressing CTRL-C.

CTRL-C does free it back up. I should have thought to try that.


>Finally, if none of the above helps:
>
>Can you reproduce without your _vimrc and customizations, by launching Vim
>> with gvim -N -u NONE -i NONE -U NONE ?


Below is my _vimrc.

Thanks!
Bill



"-------------------------------------------------------------------------------
" Standard _vimrc stuff
"-------------------------------------------------------------------------------
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin

set diffexpr=MyDiff()
function! MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
let eq = ''
if $VIMRUNTIME =~ ' '
if &sh =~ '\<cmd'
let cmd = '""' . $VIMRUNTIME . '\diff"'
let eq = '"'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
endif
else
let cmd = $VIMRUNTIME . '\diff'
endif
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
endfunction


" When vimrc is edited, reload it
autocmd! bufwritepost _vimrc source C:\Program Files\ (x86)\Vim\_vimrc


"-------------------------------------------------------------------------------
" Undo things from $VIMRUNTIME/vimrc_example.vim
"-------------------------------------------------------------------------------

set nobackup
set nowb
set noswapfile

" See C:\Program Files\ (x86)\Vim\vimfiles\plugin_not_in_use\savevers.vim
"" See C:\Program Files\ (x86)\Vim\vimfiles\plugin\savevers.vim
"set backup
"set backupdir=C:\\Program\ Files\ (x86)\\Vim\\_backup
"set patchmode=.save
"let savevers_dirs = &backupdir
""let savevers_max = 3


"-------------------------------------------------------------------------------
" Undo things from $VIMRUNTIME/mswin.vim
"-------------------------------------------------------------------------------

" restore the number increment function
unmap <C-A>

" restore the visual block function
unmap <C-V>

" restore the interrupt command function
unmap <C-C>


"-------------------------------------------------------------------------------
" Editor Appearance - lines, font, color scheme
"-------------------------------------------------------------------------------
colorscheme torte
"colorscheme _delek
set guifont=Courier
set lines=79

let my_cwd = getcwd()
if ((stridx(my_cwd, "\\Trojan") != -1) || (stridx(my_cwd, "\\USB_PD") != -1) || (stridx(my_cwd, "\\SMBus") != -1) || (stridx(my_cwd, "\\WP_TX") != -1) || (stridx(my_cwd, "\\MATLAB") != -1))
set columns=92
set textwidth=92
else
set columns=80
set textwidth=80
endif


"-------------------------------------------------------------------------------
" My Set
"-------------------------------------------------------------------------------
set autoindent
set shiftwidth=4
set expandtab
set tabstop=4

set hidden

" start gVIM without the toolbar
set guioptions-=T

" saves information about previous editing sessions to use again later
set viminfo='50,<250,s25,h,rA:,rB:

set shell=c:/cygwin/bin/bash.exe
set shellcmdflag=-c

" always list all completion option in command mode
"set wildmode=list

" auto-wrap comment lines
"set formatoptions=acroq

nnoremap <MouseUp> <C-MouseUp>
nnoremap <MouseDown> <C-MouseDown>


"-------------------------------------------------------------------------------
" Miscellaneous
"-------------------------------------------------------------------------------

" Open each buffer in its own tabpage
"au BufAdd,BufNewFile * nested tab sball

" For the mru.vim plugin
let MRU_File = 'C:\Users\a0207828\_vim_mru_files'


"-------------------------------------------------------------------------------
" Syntax Highlighting
"-------------------------------------------------------------------------------

" needed for GNU assembly file (.s) syntax highlighting
autocmd BufRead,BufNewFile *.s setfiletype asm

" needed for SREC file syntax highlighting
autocmd BufRead,BufNewFile *.srec setfiletype srec

" needed for SVF file syntax highlighting
autocmd BufRead,BufNewFile *.svf setfiletype svf
autocmd BufRead,BufNewFile *.cmp setfiletype svf

" needed for MSP430 assembly file (.s43) syntax highlighting
autocmd BufRead,BufNewFile *.inc setfiletype msp
autocmd BufRead,BufNewFile *.s43 setfiletype msp

" needed for Keil scatter file (.sct) syntax highlighting
autocmd BufRead,BufNewFile *.sct setfiletype sct

" needed for ARM assembly syntax highlighting
"let asmsyntax='armasm'
"let filetype_inc='armasm'
"autocmd BufRead,BufNewFile *.arm setfiletype armasm

" needed for system verilog syntax highlighting
"let asmsyntax='verilog'
"let filetype_inc='verilog'
"autocmd BufRead,BufNewFile *.sv setfiletype verilog


"-------------------------------------------------------------------------------
" My mappings - Normal Mode
"
" Note: Comments can not be on the same line as the map command.
"-------------------------------------------------------------------------------

"nnoremap t j0.
"nnoremap T j.
"nnoremap s n.
nnoremap <Tab> >>

" Leave insert mode whenever I hit an arrow key
"inoremap <up> <esc><up><right>
"inoremap <down> <esc><down><right>
"inoremap <left> <esc>
"inoremap <right> <esc><right><right>

" Redo one change which was undone.
nnoremap <F1> :redo<CR>

" Jump to previous window
nnoremap <F2> <C-W>p

" Open vertical split window
"nnoremap <F3> :vsplit<CR>:set columns=161<CR><C-W>=
nnoremap <F3> :vsplit<CR>:set columns=185<CR><C-W>=

" Close vertical split window
"nnoremap <F4> <C-W>q:set columns=80<CR>
nnoremap <F4> <C-W>q:set columns=92<CR>

" Move cursor down one row and perform the previous action again
"nnoremap <F2> j.

" Move cursor down one row, back to the first column, and perform the previous
" action again
"nnoremap <F3> j0.

" copy all to system (Windows) buffer
"nnoremap <F3> :%y+<CR>

" Update tag information
"nnoremap <F3> TlistUpdate<CR>

" Display tag information in a vertical-split window
"nnoremap <silent> <F4> :TlistToggle<CR>

" Repeat the last recorded macro
nnoremap <F5> @@

" Search and perform the previous action again
nnoremap <F6> n.

" Reformat a paragraph
"nnoremap <F6> gqap

" Duplicate a line and then join it to itself
"nnoremap <F7> yypkJj

" Turn off search highlighting
nnoremap <F8> :nohlsearch<CR>

" jump back to the previous file
"nnoremap <F9> <C-^>

" jump back to the first file
"nnoremap <F10> :first<CR>

" Compiling functions:
nnoremap <F9> :wa<CR>:cd build<CR>:make DEVICE_ID=UCD90120 RELEASE=1<CR>:cd ..<CR>
nnoremap <F10> :copen<CR>
nnoremap <F11> :cclose<CR>
nnoremap <F12> :cnext<CR>


" Map upper right mouse button to 'last file'
"nnoremap <X1Mouse> <C-^>

" Map upper right mouse button to 'jump back on level on the tag stack'
nnoremap <X1Mouse> <C-t>
"nnoremap <X1Mouse> :bd<CR>
"
" This does a <C-t> if returning to the current file, else it does a :bd
"nnoremap <X1Mouse> :let old=bufnr('%')<cr><c-t>
" \:let new=bufnr('%')<bar>
" \ if old != new<bar>
" \ exe "bdelete " . old<bar>
" \ endif<cr><cr>

" Map double-click left-mouse to jump to the tag under the cursor
"nnoremap <2-LeftMouse> :exe "tab stag" expand("<cword>")<CR>
"nnoremap <2-LeftMouse> :!start gvim -t <cword><CR>
nnoremap <2-LeftMouse> :exe "tag ". expand("<cword>")<CR>
nnoremap <C-CR> :exe "tag ". expand("<cword>")<CR>


" CSCOPE mappings (see ftplugin\c\cscope_maps.vim)
"
" 's' symbol: find all references to the token under cursor
" 'g' global: find global definition(s) of the token under cursor
" 'c' calls: find all calls to the function name under cursor
" 't' text: find all instances of the text under cursor
" 'e' egrep: egrep search for the word under cursor
" 'd' called: find functions that function under cursor calls
"
" The result of your cscope search will be displayed in the current window.
" You can use CTRL-T to go back to where you were before the search.
nnoremap <C-F1> :cs find s <C-R>=expand("<cword>")<CR><CR>
nnoremap <C-F2> :cs find g <C-R>=expand("<cword>")<CR><CR>
nnoremap <C-F3> :cs find c <C-R>=expand("<cword>")<CR><CR>
nnoremap <C-F4> :cs find t <C-R>=expand("<cword>")<CR><CR>
nnoremap <C-F5> :cs find e <C-R>=expand("<cword>")<CR><CR>
nnoremap <C-F6> :cs find d <C-R>=expand("<cword>")<CR><CR>
" Result displayed in the new horizontal-split window.
nnoremap <C-F7> :scs find d <C-R>=expand("<cword>")<CR><CR>
nnoremap <C-F8> :scs find e <C-R>=expand("<cword>")<CR><CR>
nnoremap <C-F9> :scs find t <C-R>=expand("<cword>")<CR><CR>
nnoremap <C-F10> :scs find c <C-R>=expand("<cword>")<CR><CR>
nnoremap <C-F11> :scs find g <C-R>=expand("<cword>")<CR><CR>
nnoremap <C-F12> :scs find s <C-R>=expand("<cword>")<CR><CR>


" Update cscope data base
if (stridx(my_cwd, "\\WP_TX") != -1)
nnoremap <S-F1> :wa<CR>:cscope kill 0<CR>
\ :!cscope -b -k *.c *.h "C:/ti/ccsv5/tools/compiler/msp430/include/*.h" "C:/ti/ccsv5/ccs_base/msp430/include/msp430g2553.h" "C:/ti/ccsv5/ccs_base/msp430/include/in430.h"; mkdir -p build; mv -f cscope.* build<CR>
\ :cscope add build\cscope.out<CR>
else
nnoremap <S-F1> :wa<CR>:cscope kill 0<CR>
\ :!cscope -b -k *.c *.h; mkdir -p build; mv -f cscope.* build<CR>
\ :cscope add build\cscope.out<CR>
endif

" Get rid of the ^M at the end of the lines and fix the file type
nnoremap <S-F2> :%s/\r//<CR>:set fileformat=dos<CR>:w<CR>

" Remove all tabs
"nnoremap <F7> 1G!Gpr -t -e<CR>''
nnoremap <S-F3> :%retab!<CR>

" Remove all white space at the end of a line
nnoremap <S-F4> :%s/\s\+$//<CR>

" Make a copy of the current line and increment the number on the copied line
nnoremap <S-F5> yyp0<C-A>

" Run indent on the entire file
nnoremap <silent> <S-F7> :%!indent<CR>

" Run indent on the visual selection
vnoremap <S-F8> :!indent<CR>

" Highlight C function declarations
"nnoremap <S-F9> /^[^ \t/{}*#].*(.*$<CR>
"nnoremap <S-F9> /^\s*[a-zA-Z0-9_* \t]\+([a-zA-Z0-9_* )\t,]\+$<CR>
"nnoremap <S-F9> /^\s*[^/]\w\+\s\+\w\+.*(.*\n\+\s*{<CR>
"
"NOTE: Does not match functions that are indented...
"nnoremap <S-F9> /^\([a-zA-Z0-9_*]\+\s*\)\+(.*[^;]$<CR>
"nnoremap <S-F9> /^[a-zA-Z_][a-zA-Z0-9_* \t]\+(.*[^;]$<CR>
nnoremap <S-F9> /^\h[a-zA-Z0-9_* \t]\+(.*[^;]$<CR>


" open my file that summarizes the plugins that I have installed
nnoremap <S-F11> :!start gvim "C:\Program\ Files\ (x86)\Vim\my_vim_docs\vim_plugins.txt"<CR><CR>

" open my vim tips file
nnoremap <S-F12> :!start gvim "C:\Program\ Files\ (x86)\Vim\my_vim_docs\vim_tips.txt"<CR><CR>


"-------------------------------------------------------------------------------
" My mappings - Insert Mode
"
" Note: Comments can not be on the same line as the map command.
"-------------------------------------------------------------------------------

" map Tab to word completion function
" Note: You can still get a tab char with <Shift>-<Tab>
inoremap <Tab>


"-------------------------------------------------------------------------------
" My mappings - Visual Mode
"
" Note: Comments can not be on the same line as the map command.
"-------------------------------------------------------------------------------

" Use the tab to shift text right and left in visual mode
vnoremap <Tab> >
vnoremap <S-Tab> <LT>

" allows * to work for more than a single word, any stuff up to a line's worth
vnoremap * y:exe 'norm! /' . escape(@@, '/*.\[$^~') . "\r"<cr>

" Alignment Tool mappings (:help align)
vmap <A-F1> \t=<CR> " =
vmap <A-F2> \t,<CR>:B s/\s\+,/,/<CR> " ,
vmap <A-F3> \tml<CR> " continue lines
vmap <A-F4> \t#<CR> " #

vmap <A-F5> \adec<CR> " declarations
vmap <A-F6> \t:<CR> " :
vmap <A-F7> \ascom<CR> " title and staggered comments
vmap <A-F8> \acom<CR> " comment

vmap <A-F9> \adef<CR> " definitions
vmap <A-F10> \a,<CR> " break up comma-separated declarations
vmap <A-F11> \tab<CR> " table
vmap <A-F12> \anum<CR> " numbers

Waters, Bill

unread,
Nov 19, 2012, 3:49:22 PM11/19/12
to vim...@googlegroups.com
>>As for stopping it, if you have NOT mapped CTRL-C to something else (I
>>sure
>>> hope you haven't), you can interrupt many actions simply by pressing CTRL-C.
>
>CTRL-C does free it back up. I should have thought to try that.
>

After I used CTRL-C to get around the hangup, my cursor acts differently in
normal mode. I can no freely scroll wherever I want - any column, even if it is
beyond the end of the text for a given line.

That seems like a clue??

Thanks,
Bill

Ben Fritz

unread,
Nov 19, 2012, 3:56:13 PM11/19/12
to vim...@googlegroups.com
On Monday, November 19, 2012 2:40:48 PM UTC-6, Bill Waters wrote:
> >
> >Do you have your 'foldmethod' set to "syntax"? (I did not see an attachment).
> >
>
> I don't have a 'foldmethod' setting in my _vimrc, and when I do a ":set
> foldmethod" it says that it is set to "manual".
>
> >
> >http://vim.wikia.com/wiki/Keep_folds_closed_while_inserting_text
> >
> >As for stopping it, if you have NOT mapped CTRL-C to something else (I sure
> > hope you haven't), you can interrupt many actions simply by pressing CTRL-C.
>
> CTRL-C does free it back up. I should have thought to try that.
>
> >Finally, if none of the above helps:
> >
> >Can you reproduce without your _vimrc and customizations, by launching Vim
> >> with gvim -N -u NONE -i NONE -U NONE ?
>
> Below is my _vimrc.
>

I don't see anything in your _vimrc that I think should cause a problem. Did you
try without your .vimrc and plugins as I suggested? What happened? There may
still be a plugin interfering even if it isn't the .vimrc. It may particularly
be a C filetype plugin, if you don't notice this sort of thing in other file
types.

While I didn't notice any obvious causes of this slowdown in your .vimrc, I am
curios why you have this:

> set nobackup
> set nowb
> set noswapfile

While setting nobackup makes sense if you're working on version controlled code,
and probably unnecessary if you've got persistent undo turned on, I don't know
of any good reason to turn off writebackup. swapfile is likewise a good option
to leave on, or else you lose out on data recovery if Vim crashes, or detection
of when you accidentally open the file in multiple Vim instances.

Are you editing a file on a network share, perchance?

Ben Fritz

unread,
Nov 19, 2012, 4:00:04 PM11/19/12
to vim...@googlegroups.com

That sounds like you have a plugin which set the virtualedit option, because I don't see this option being set in your .vimrc. If this plugin disables the option during insert actions for some reason, then re-enables it afterwards, interrupting the plugin will cause it to stay off. What does ":verobse set virtualedit?" show you?

Waters, Bill

unread,
Nov 19, 2012, 5:23:07 PM11/19/12
to vim...@googlegroups.com
Before the problem and the CTRL-C, I get this "virtualedit=". After, I get
this...

virtualedit=all
Last set from C:\Program Files (x86)\Vim\vimfiles\plugin\AutoAlign.vim

So, I got rid of AutoAlign and the problem went away. I tried the latest
version of AutoAlign (I was one version behind), and I still had the problem.

Thanks,
Bill

Ben Fritz

unread,
Nov 19, 2012, 7:12:05 PM11/19/12
to vim...@googlegroups.com, drc...@campbellfamily.biz
On Monday, November 19, 2012 4:24:16 PM UTC-6, Bill Waters wrote:
>
>
> virtualedit=all
>
> Last set from C:\Program Files (x86)\Vim\vimfiles\plugin\AutoAlign.vim
>
>
> So, I got rid of AutoAlign and the problem went away. I tried the latest
> version of AutoAlign (I was one version behind), and I still had the problem.

Your problem of very long waits was was occurring when you typed = in insert mode in a C file, so from the script name I suspect you downloaded http://www.vim.org/scripts/script.php?script_id=884 at some point. When you say you tried the "latest version", did you grab it from the vim.org page or from Dr. Chip's site?

Chip, do you know of any performance issues with AutoAlign.vim?

Waters, Bill

unread,
Nov 20, 2012, 6:02:57 PM11/20/12
to vim...@googlegroups.com, drc...@campbellfamily.biz
vim.org

I think this is related to Win7 somehow. I have had the same vim setup for a
couple of years. I never saw this on XP. I just recently switched to Win7. I
copied my vimfiles dir from my XP machine.

I wonder if it is a file permission thing - I am having all sorts of problems
with that in Win7.

I have a work-around for now, so I'm good. Thanks again.
Reply all
Reply to author
Forward
0 new messages