2012-05-23 15 views
14

.{cpp,h} dosyasında tek satırlı bir yorumun sonunda yeni bir satıra başladığımda, vim otomatik olarak yorum yapıyor. Örneğin: Bu bir eklenti veya ayar olup olmadığından emin değilim. ~/.vimrc'umda yaptığım gibi görünen hiçbir şey göremiyorum ve yüklü eklentiler aşağıda listelenmiştir.Vim'deki yeni satırı yalnızca blok yorumları için yeni yorum

Ben /* */ tarzı satırlı yorumlar için bu, ama benim tek hat varsayılan olarak çoklu hatları üzerinden çalışan comments istemiyormuş gibi.

Bunu hangi ayar (veya eklenti) yapar ve bu yorum tipi için 'u kapatabilirim?

:scriptnames bu verir: {cpp, h} dosyalarında, blok yorum etkilemeden // için hile yapmak gerekir sizin vimrc olarak


    1: /Users/simont/.vimrc 
    2: /usr/local/share/vim/vim73/syntax/syntax.vim 
    3: /usr/local/share/vim/vim73/syntax/synload.vim 
    4: /usr/local/share/vim/vim73/syntax/syncolor.vim 
    5: /usr/local/share/vim/vim73/filetype.vim 
    6: /usr/local/share/vim/vim73/ftplugin.vim 
    7: /usr/local/share/vim/vim73/syntax/nosyntax.vim 
    8: /Users/simont/repositories/config-files/vim/colors/solarized.vim 
    9: /usr/local/share/vim/vim73/plugin/getscriptPlugin.vim 
10: /usr/local/share/vim/vim73/plugin/gzip.vim 
11: /usr/local/share/vim/vim73/plugin/matchparen.vim 
12: /usr/local/share/vim/vim73/plugin/netrwPlugin.vim 
13: /usr/local/share/vim/vim73/plugin/rrhelper.vim 
14: /usr/local/share/vim/vim73/plugin/spellfile.vim 
15: /usr/local/share/vim/vim73/plugin/tarPlugin.vim 
16: /usr/local/share/vim/vim73/plugin/tohtml.vim 
17: /usr/local/share/vim/vim73/plugin/vimballPlugin.vim 
18: /usr/local/share/vim/vim73/plugin/zipPlugin.vim 
19: /usr/local/share/vim/vim73/scripts.vim 
20: /usr/local/share/vim/vim73/ftplugin/vim.vim 
21: /usr/local/share/vim/vim73/syntax/vim.vim 

cevap

13
au FileType c,cpp setlocal comments-=:// comments+=f:// 

.

akım tampon kullanımda geçici denemek için:

:setlocal comments-=:// comments+=f:// 
+2

Yorumlar + = f: // 'do? –

5

yapılandırma Bu tür, yani belirli dosya türleri ile ilgilidir, normal olarak bir dosya tipi eklenti aracılığıyla ayarlanır. Vim ile birlikte gelen yaygın dosya türleri için (örneğin, .cpp gibi) bir çok dosya türü vardır. :set ft? ile arabellek için dosya türünü kontrol edebilirsiniz.

Yeni bir satır başlattıktan sonra devam yorumları için ayar, pb2q'nin belirttiği gibi 'comments' seçeneklerinden gelir. .{cpp,h} için varsayılan dosya türü 'cpp' dir ve 'comment' seçeneği cpp.vim aynı dizinde olduğundan $VIMRUNTIME/ftplugin/c.vim olarak ayarlanmıştır. c.vim Dosyadan:

" Set 'comments' to format dashed lists in comments. 
    setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,:// 

comments seçenek {flags}:{string} listesidir ve bayraklar f ve O önlemek comment yeni çizgiler uzanan. Vim FAQ itibaren

:

You can use an autocommand triggered on the FileType event: 

     au Filetype * set formatoptions=xyz 

    This should at least be after "filetype on" in your vimrc. Best is to put 
    it in your "myfiletypefile" file, so that it's always last. 


    If you want to override a setting for a particular filetype, then create a 
    file with the same name as the original filetype plugin in the 
    ~/.vim/after/ftplugin directory For example, to override a setting in the 
    c.vim filetype plugin, create a c.vim file in the ~/.vim/after/ftplugin 
    directory and add your preferences in this file. 

Yani sorunu çözmek gerekir

setlocal comments-=:// 
    setlocal comments+=fO:// 

dosyayı ~/.vim/after/ftplugin/c.vim oluşturun.

İlgili konular