我试图在我的VIM中实现代码折叠。我相信它们的标准命令是za,zc,zo等。据我了解,使这些命令正常工作不需要做任何特殊的事情。我主要是JS程序员。
但是,这些命令在我的VIM中均不起作用。我正在使用VIM 7.2
以下是我的.vimrc文件。
我显示整个.vimrc文件的原因是因为我猜测可能正在使用一个插件,这可能导致折叠命令无法正常工作。
如果有人有什么想法,请在这里指出。
" Start pathogen plugins "
call pathogen#infect()
" Automatic syntax highlight on "
syntax on
" Necessary for NerdCommenter to Work "
filetype plugin indent on
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
" Replace tabs with spaces "
set expandtab
" Make tab 2 space wide
set tabstop=2
set shiftwidth=2
" If I am in an indented block of code, keep the indentation level when I "
" press enter "
set autoindent
" Stop vim from creating automatic backups "
set nobackup
set noswapfile
set nowb
set nowritebackup
" Show line numbers "
set number
" Shift+Tab unindents a line "
imap <S-Tab> <Esc><<i
nmap <S-tab> <<
" Remove trailing spaces when saving a file "
autocmd BufWritePre * :%s/\s\+$//e
" Highlight all occurances of search "
set hlsearch
" Ignore case during search
set ignorecase
" Show tabs and trailing spaces "
set list listchars=tab:.\ ,trail:·
" set colorscheme "
colorscheme desert
set background=dark
set ff=unix
set showtabline=2
set smarttab
set incsearch
" Store a history of commands "
set history=1000
" Number of undo levels "
set undolevels=1000
" Change title of tab "
set title
" Open nerdtree plugin when vim starts "
let g:nerdtree_tabs_open_on_console_startup=1
au BufNewFile,BufRead *.less set filetype=less
let g:DirDiffExcludes = ".svn,*.swp"
let Grep_Skip_Dirs = '.svn'
" smart way to move between windows
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" useful mappings for managing tabs
map <leader>tn :tabnew<cr>
map <leader>to :tabonly<cr>
map <leader>tc :tabclose<cr>
map <leader>tm :tabmove
set wrap linebreak nolist
nnoremap tp :tabprev<CR>
nnoremap tn :tabnext<CR>
nnoremap tf :tabfirst<CR>
nnoremap tl :tablast<CR>
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
function! TrimWhiteSpace()
%s/\s\+$//e
endfunction
autocmd BufWritePre *.* :call TrimWhiteSpace()
我相信,要使折叠命令起作用,您需要设置foldmethod选项。在我看来,最简单的开始就是“缩进”。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句