web-dev-qa-db-ja.com

.vimrcを検証するにはどうすればよいですか?

私の.vimrcファイルは機能しているようで、通常の操作中に目に見えるエラーは生成されません。最近Knifeを使い始めましたが、何かが原因で不正なコードで終了するため、Chefコンテンツを編集するためのエディターとしてVimを使用できないことがわかりました。 .vimrcファイルを削除するとKnifeが幸せになったので、.vimrcの何かが悪いと思います。

.vimrc自体にエラーがないかチェックするために使用できるコマンドやツールはありますか?

これは問題のvimrcです:

set nocompatible              " be iMproved, required
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()

" let Vundle manage Vundle, required
Bundle 'gmarik/vundle'
Bundle 'scrooloose/syntastic'
Bundle 'scrooloose/nerdtree'
Bundle 'michalbachowski/vim-wombat256mod'
Bundle 'spf13/vim-autoclose'
Bundle 'leshill/vim-json'
Bundle 'pangloss/vim-javascript'
Bundle 'hail2u/vim-css3-syntax'
Bundle 'tpope/vim-markdown'
Bundle 'beyondwords/vim-twig'
Bundle 'spf13/PIV'
Bundle 'othree/html5-syntax.vim'
Bundle 'vim-scripts/HTML-AutoCloseTag'
Bundle 'vim-scripts/indenthtml.vim'
Bundle 'Lokaltog/powerline'
" Keep bundle commands between here and filetype plugin indent on.



filetype plugin indent on     " required

" Brief help
" :BundleList          - list configured bundles
" :BundleInstall(!)    - install (update) bundles
" :BundleSearch(!) foo - search (or refresh cache first) for foo
" :BundleClean(!)      - confirm (or auto-approve) removal of unused bundles
"
" see :h vundle for more details or wiki for FAQ
" NOTE: comments after Bundle commands are not allowed.

" NERDTree config
map <C-n> :NERDTreeToggle<CR>
autocmd vimenter * if !argc() | NERDTree | endif

" enable paste mode
nnoremap <F2> :set invpaste paste?<CR>
set pastetoggle=<F2>
set showmode

" Set PHP debugger port to 9001
let g:debuggerPort = 9001

set t_Co=256
colorscheme wombat256mod
:syntax enable

python from powerline.vim import setup as powerline_setup
python powerline_setup()
python del powerline_setup
set rtp+=/Users/shane/.vim/bundle/powerline/powerline/bindings/vim

set number              " Enables line numbers
set cindent             " autoindent
set tabstop=4           " set tab distance
set shiftwidth=4
set expandtab           " force tabs into spaces
set ruler

let g:html_indent_script1 = "inc"
let g:html_indent_style1 = "inc"

autocmd BufNewFile,BufRead Gemfile set filetype=Ruby
autocmd BufNewFile,BufRead Vagrantfile set filetype=Ruby
2
shanethehat

それはいけません。ほとんどの(すべて?)インタープリター言語と同様に、実行できるのは構文の妥当性をチェックすることだけですが、書き留めた関数呼び出しなどがまったく意味をなさないかどうかは、特定のコードパスが実際にヒットしたときにのみ表示されます。

あなたができる唯一のことは、whatが「悪いコード」であり、それがあなたに伝えようとしていることを調べることによって問題を絞り込むことです。たとえば、問題の原因ではないかどうか完全に確信が持てないものすべてにコメントを付けて問題のデバッグを試み、Knifeがこの構成で機能するかどうかを試し、エラーが再度発生するまで前のコメントアウトされたコードを繰り返し有効にすることができます。

1
Andreas Wiese

編集中のファイルのステータスではなく、vimの終了コードであると確信していますか? :help 'backupcopy'の下に、vimを使用してcrontabファイルを編集する方法に関する段落があります。 :help crontabを使用すると、直接そこに到達できます(ただし、コンテキストは失われます)。

                 *crontab*
One situation where "no" and "auto" will cause problems: A program
that opens a file, invokes Vim to edit that file, and then tests if
the open file was changed (through the file descriptor) will check the
backup file instead of the newly created file.  "crontab -e" is an
example.

これがKnifeで起こっていることである可能性がある場合は、vimrcファイルに:set bkc=yesを追加してみてください。 vimrcファイルにいくらコメントアウトしても、vimはvimrcファイルを見つけるとすぐに'compatible'オプションをリセットし、これにより'backupcopy'が設定されるため、多くのテストを節約できます。 「自動」に。私のvimrcファイルには次のものがあります:

" When vim is called from "crontab -e" we need to set this option specially:
au BufEnter /private/tmp/crontab.* setl backupcopy=yes
0
benjifisher