2016-12-18 5 views
0

私は、自動ラップ有効にする傾向がある:vimでオートラップを有効にしている間、文字列を引用符で囲むのを防ぐには?

:set textwidth=80 
:set formatoptions+=wt 

をしかし、それはエラーになりますので、私は、ときに私はCまたはJavaScriptでコーディング引用符で私が入力長い文字列ラップする必要はありません。 vim自動折り返し除外引用符は設定できますか?この行を折り返す前に または自動入力 '\'?

答えて

-1

キャリッジリターンを追加して行を折り返して設定しているため、コンパイル時に問題が発生します。

代わりにあなたが仮想ラップで、ラインには影響しませんwrapオプションを使用することができます:あなたは、私がコード化されたこの小さなスクリプトから起動するとするために、いくつかの改良を加えることができる

:set wrap 
:set textwidth=0 
:set wrapmargin=0 
+0

私は行に影響を与える実際のラップを使用したい!しかし、引用符の中に長すぎる文字列をラップしないでください。 – Sword

+0

あなたはラッピングが別の実線にあるとお考えですか? – Sabrina

+0

':global'と' substitution'とイベント 'autocmd'について読んだら、完全に理解すればこの問題を解決できます。 – Sabrina

0

をあなたのニーズに合う:

"""""the event that will trigger the wrap (leaving insert mode) 
au InsertLeave * call WrapLines() 
"""""highlight the column where the wrapping will be made 
set colorcolumn=30 
"""""WrapLines will be executed on lines 
function! WrapLines() 
execute ":%g/^/ call WrapFunction()" 
endfunction 

"""""check and wrap the line 
function! WrapFunction() 
    let l:line=getline(".") 
    let l:length=strlen(l:line) 
    let l:occurence=0 
    let l:i=0 
    let l:nb=30 
    for l:i in split(l:line,'\zs') 
     if matchstr(l:i,'"') != '' 
      let l:occurence+=1 
    let l:occurence=l:occurence % 2 
     endif 

    let l:nb-=1 
if l:nb == 0 
break 
endif 
    endfor 
    if l:length >= 30 
     if l:occurence == 0 
"""""to get ^M you need to type <ctrl-v><enter> buttons 
      normal! 30|i^M 
     endif 
    endif 
endfunction 

注:コードPLEで^Mを取得します(:ASEタイプCTRL + V

名を入力し、ファイルを保存しEXscript.vimをして、コマンドにより、その後それを呼び出すここで ":source script.vim"

は一例です30文字数 - 制限:):

enter image description here

関連する問題