1

.rbさまざまなバッファーと素晴らしい vim プラグインCtrlpを使用して、いくつかのファイルを喜んで編集 していました。ただし、特定のファイルを再度開いたとき、特にmicropost.rbすべての自動インデントと構文の強調表示が機能しません。

.micropost.rb.swp私はそれを開く前にVimに delete 、つまり対応するスワップファイルを削除させたという事実と関係があると確信しています。そして、スワップファイルからのある種の残り物があること。

今、私が1)ファイルをバックアップしたとしても、2)micropost.rb最初から書きます。.rbファイルの検出は行われません。

ただし、同じコードを新しいファイルに書き始めると、たとえばpicopost.rb、すべてが期待どおりに機能することに注意してください。

EDIT 1、これは私のもの.vimrcです:

execute pathogen#infect()
set runtimepath^=~/.vim/bundle/ctrlp.vim
syntax on
filetype plugin indent on
set number 

"" ADD A line to diferently indented blocks of code
set list lcs=tab:\|\ 

let mapleader=","
" Fast saving
nmap <leader>w :w!<cr>


"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text, tab and indent related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Use spaces instead of tabs
"set expandtab

" Be smart when using tabs ;)
set smarttab

" 1 tab == 4 spaces
set shiftwidth=4
set tabstop=4

" Linebreak on 500 characters
set lbr
set tw=500

set ai "Auto indent
set si "Smart indent
set wrap "Wrap lines


" a combination of spaces and tabs are used to simulate tab stops at a width
" other than the (hard)tabstop
set softtabstop=4


""CTRLP mappings
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'

"folding settings
set foldmethod=indent   "fold based on indent
set foldnestmax=10      "deepest fold is 10 levels
set nofoldenable        "dont fold by default
set foldlevel=1         "this is just what i use
hi Folded ctermbg=darkgrey
"Autosave folding state at quit
au BufWinLeave * mkview
au BufWinEnter * silent loadview

""""""""""""""""""""""""""""""
" => Status line
""""""""""""""""""""""""""""""
" Always show the status line
set laststatus=2

" Format the status line
"set statusline=\ %F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l
"set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l
"

"Splits configuration
set splitbelow  
set splitright


"Max out the height of the current split   ------  ctrl + w _
"Max out the width of the current split------ ctrl + w |
"Normalize all split sizes, which is very handy when resizing terminal-------- ctrl + w =
"Swap top/bottom or left/right split ------ Ctrl+W R
"Break out current window into a new tabview ---------- Ctrl+W T
"Close every window in the current tabview but the current one  -------  Ctrl+W o
4

2 に答える 2

1

あなた自身の答えにより、私はあなたの問題の原因を推測することができました。

バッファを終了するとビューを自動的に保存し、バッファに再度入るとビューを再度ロードする autocmd があるようです。

したがって、オプションに「オプション」が含まれている'viewoptions'場合、最初のロードでファイルタイププラグインから取得した後にファイルに手動で設定したオプションは、永久に記憶されます。

おそらく'filetype'、その 1 つのファイルのオプションを何らかの形でクリアしたため、ファイルをロードするたびに、ビュー ファイルから空のファイル タイプが復元されます。

考えられる解決策: 1. 現在のビュー ファイルを削除し、'viewoptions'設定から「オプション」を削除して、再度発生しないようにする 2. ファイル タイプを手動で設定し、ビュー ファイルに依存して、そのタイプの復元を永久に続行する

どのソリューションを選択するかはあなた次第であり、ファイルに設定したすべてのオプションを本当に永続化するかどうかによって異なります。

于 2013-10-11T21:16:31.203 に答える