macvim无法折叠代码“ E490:找不到折叠”

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了macvim无法折叠代码“ E490:找不到折叠”相关的知识,希望对你有一定的参考价值。

我无法在macvim中折叠我的代码

我的环境和设置在要点链接https://gist.github.com/poc7667/7035979

有什么想法吗?

hi  Comment  ctermfg=6



"function SetCafeOptions()
    "CoffeeCompile
    ":set nonu
    ":res -24
    ":res +24
"endfunction

set encoding=utf-8 
set fileencoding=utf-8 

colorscheme elflord            
set smartindent
set tabstop=4
set expandtab  
set shiftwidth=4

"make it autoreload
set autoread 

"auto move it last time the position you viewed
"make vim save and load the folding of the document each time it loads"
""also places the cursor in the last place that it was left."

"try to set show ansi color
if &term=="ansi" 
    set t_Co=0 
endif

"set expandtab

filetype on

if has("cscope")
    set csprg=/usr/bin/cscope
    set csto=0
    set cst
    set nocsverb
    " add any database in current directory
    if filereadable("cscope.out")
        cs add cscope.out
        " else add database pointed to by environment
    elseif $CSCOPE_DB != ""
        cs add $CSCOPE_DB
    endif
    set csverb
    set cscopetag
    set cscopequickfix=s-,g-,c-,d-,t-,e-,f-,i-
endif

"let Tlist can close windows at one time
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1

" Key map
" Presee F4 and you can open the NERDTree
nnoremap <silent> <F4> :NERDTree<CR>  
"nnoremap <silent> <F3> :!/usr/bin/env python %<CR>
" Show function List with Tlist 
nnoremap <F12> :TlistToggle<CR>

" Map ctrl+q to ctrlw+ctrlw
"
"nnoremap <silent> <C-q>  :<C-w><C-w>

"switch in splitted window
map <c-d> <c-w>l
map <c-a> <c-w>h

"set highlight
set hlsearch

"set autocomplet 
"autocmd BufNewFile,BufRead *.html.erb set filetype=html.eruby
autocmd BufNewFile,BufRead *.html.erb set filetype=erb.html.eruby
filetype plugin on

"auto import python template
autocmd bufnewfile *.py 0r ~/common_lib/python/tmpl.py


map gn :bn<cr>
map gp :bp<cr>
map ff :CtrlP<cr>
map gt :buffers<cr>
"set NerdTreeSize
let g:NERDTreeWinSize=12
"auto close the nerdtress window whe you open new file
let g:ctrlp_dont_split = 'nerdtree'


set nocompatible " explictly get out of vi-compatible mode

set background=dark " we plan to use a dark background

syntax on " syntax highlighting on

set number " turn on line numbers
set wildignore+=*/test/*,*/tmp/*,*.so,*.swp,*.zip     " MacOSX/Linux

set ruler "always show current position along the bottom

set incsearch " do highlight as you type you search phrase

set ignorecase " case insensitive by default

set smartcase " if there are caps, go case-sensitive


"Rope vim
let $PYTHONPATH .= ":~/install/ropehg/rope:~/install/ropehg/ropemode:~/install/ropehg/ropevim"
source ~/install/ropehg/ropevim/ropevim.vim
let g:pymode_rope_goto_def_newwin = "new"
let ropevim_vim_completion=1
"Use Ctrl + ] . to autocomple
inoremap <C-]> <C-R>=RopeCodeAssistInsertMode()<CR>
map <leader>j :RopeGotoDefinition<CR>
map <leader>r :RopeRename<CR>

" Load the whole plugin
 let g:pymode = 1
" Load run code plugin
 let g:pymode_run = 1

"add ctrlp.vim setting
""
let g:ctrlp_custom_ignore = 'tmp$\|\.git$\|\.hg$\|\.svn$\|.rvm$'
let g:ctrlp_working_path_mode = 'ra'
let g:ctrlp_match_window_bottom=1
let g:ctrlp_max_height=15
let g:ctrlp_match_window_reversed=0
let g:ctrlp_mruf_max=500
let g:ctrlp_follow_symlinks=1


"Vundle
 set rtp+=~/.vim/bundle/vundle/
 call vundle#rc()
 Bundle 'gmarik/vundle'
 Bundle 'tpope/vim-surround'
 Bundle 'Raimondi/delimitMate'
"coffee script"
 Bundle 'kchmck/vim-coffee-script'
 Bundle 'ack.vim'
 Bundle 'matchit.zip'
 "Markdown"
 "Bundle 'plasticboy/vim-markdown'
 ""Vim-scripts repo
 Bundle 'The-NERD-Commenter'
 Bundle 'pep8'
 ""Bundle 'AutoClose'
 filetype plugin indent on

 nmap <leader>a <Esc>:Ack ""

 "folding code
 nnoremap <space> za
 vnoremap <space> zf

" pep8
let g:pep8_map='<leader>8'

"coffee script"
call pathogen#infect()


"make vim save and load the folding of the document each time it loads"
""also places the cursor in the last place that it was left."
au BufWinLeave *.* mkview
au BufWinEnter *.* silent loadview

let Tlist_Use_Right_Window   = 1

"autocmd BufEnter * if &filetype == "" | setlocal ft=python | endif

"markdown https://github.com/plasticboy/vim-markdown/wiki"
"let g:vim_markdown_folding_disabled=1

"auto exec ruby and coffee script with F5 , remeber to save file before launching
autocmd FileType python map <leader>p :!python %<cr>
autocmd FileType ruby,rb map <leader>5 :w!<cr>:!ruby %<cr>
autocmd FileType * map <leader>e :qa!<cr>
"autocmd FileType coffee nmap <F5> :CoffeeCompile<cr>
"autocmd FileType coffee map <F5> :call SetCafeOptions()<cr>

so ~/.vim/snippets/support_functions.vim
答案

您的.vimrc实际上并未在任何地方启用折叠功能。默认情况下不启用折叠功能。您需要告诉Vim使用哪种方法来折叠代码。

您使用哪种方法可能取决于您正在编辑的代码类型。一些语法高亮文件定义了基于语法的折叠。其他语法文件则没有。如果您的代码是支持基于语法的折叠的类型,则可以在加载文件后单击:setlocal foldmethod=syntax。您可以根据需要在.vimrc中的autocmd中执行此操作,例如autocmd FileType c setlocal foldmethod=syntax,也可以手动执行。

其他自动折叠方法包括“标记”,“ expr”和“缩进”。默认情况下,fold方法是“ manual”,并且必须首先使用zf创建折叠,才能使用折叠命令。

请参阅http://vim.wikia.com/wiki/Folding以进行更详细的讨论。

另一答案

删除这些行为我解决了折叠问题:

au BufWinLeave *.* mkview
au BufWinEnter *.* silent loadview

以上是关于macvim无法折叠代码“ E490:找不到折叠”的主要内容,如果未能解决你的问题,请参考以下文章

如何从终端运行 mvim (MacVim)?

macvim:如何多次粘贴同一个被抽出的单词?

简单解决IDEA java注释整块代码后无法折叠注释代码

MacVim - 如何正确设置 vimdiff 以使用 SourceTree?

用于 CS 的 MacVIM 语法文件

macvim的配置