我試圖在我的VIM中實現代碼摺疊。 我相信他們的標準命令是za,zc,zo等。 據我所知,人們不需要做任何特殊的事情來使這些命令起作用。 我主要是一個JS程序員。VIM中的摺疊代碼
但是,這些命令都沒有在我的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()
打開一個js文件,':set fdm?'的輸出是什麼? – Kent 2014-09-30 13:32:20
foldmethod失蹤..我把它設置爲首先縮進..沒有太多的JavaScript的幫助。我現在試圖加入基於語法的摺疊 – runtimeZero 2014-09-30 16:12:40