:set nohlsearchが機能しない

:set nohlsearchが機能しない

VIMを使用して既存のセッションを開くと、set nohlsearch最後の設定は機能しません~/.vimrc。手動で実行する場合にのみ機能します。また、セッションにないファイルを開くと設定が~/.vimrc適用されることも確認しました。セッションからバッファに切り替えます:source $MYVIMRC

セッションを再作成しましたが、:mksession!役に立ちませんでした。 VIM 7.4を使用しています。

以下は次のとおりです~/.vimrc

" For pre-processing books
command! Book %s/\v([Tt])heyre/\1hey're/gec | %s/\v([Ww])ont/\1on't/gec | %s/\v([Yy])oud/\1ou'd/gec | %s/\v([Nn])eednt/\1eedn't/gec | %s/\v([Ss])houldnt/\1houldn't/gec | %s/\v([Hh])asnt/\1asn't/gec | %s/\v([Cc])ant/\1an't/gec | %s/\v([Tt])hats/\1hat's/gec | %s/\v([Yy])oull/\1ou'll/gec | %s/\v([Yy])oure/\1ou're/gec | %s/\v([Yy])ouve/\1ou've/gec | %s/\v([Ii])ts/\1t's/gec | %s/\v([Dd])ont/\1on't/gec | %s/\v([Aa])rent/\1ren't/gec | %s/\v([Dd])oesnt/\1oesn't/gec | %s/\v([Dd])idnt/\1idn't/gec | %s/\v([Ii])snt/\1sn't/gec | %s/\v([Hh])eres/\1ere's/gec | %s/IDEs\C/IDE's/gec | %s/\v([Nn])onfinal/\1on-final/gec | /\v\c^(chapter|item)|\[.+\]

" Write buffer and delete it afterwards
command! Wd write|bdelete
" Format current buffer that should be an XML document
"command! FormatXml %!xmllint --format -
" Format current selection that should be an XML document
command! -range FormatXml <line1>,<line2>!xmllint --format -

" Copy current buffer contents to the system clipboard (insertion with CTRL+v). Range can be used.
command! -range CopyToClipboard <line1>,<line2>w !xclip -selection clipboard
" Copy current buffer contents to the primary clipboard (insertion with mouse wheel click or with CTRL+SHIFT+INSERT). Range can be used.
command! -range CopyToPrimary <line1>,<line2>w !xclip

" Copy visual selection to the clipboard and pass it to 'eval'
command! -range Eval <line1>,<line2>w !xclip && eval "$(xclip -o)"

" Comment/uncomment shell script
command! -range CommentShellScript <line1>,<line2>s/^/#/g
command! -range UncommentShellScript <line1>,<line2>s/\v^\s*#(.*)/\1/g

" Creates a buffer containing the output of ':browse oldfiles' command at the top
" Move cursor to the path and press ENTER
" TODO: Doesn't open files with spaces in their paths
command! Browse new +setl\ buftype=nofile | 0put =v:oldfiles | nnoremap <buffer> <CR> :e <C-r>=getline('.')<CR><CR>

" If the current line contains a file path, the file will be opened in default program
command! OpenInDefaultProgram exec(":!xdg-open '".getline(".")."'")

" If the current line contains a URL, the URL will be opened in firefox
command! OpenUrlInFirefox exec(":!firefox '".getline(".")."'")

" Remove duplicate method calls. You just want to see which methods have been called and not interested in their call order
command! BtraceUniqMethodCalls %s/\v\(.*\)//g | %sort u | !%uniq 
" Remove duplicate classes. You just want to see which classes have been used during execution
command! BtraceUniqClasses %s/\v\.[^\.]{-}\(.*\)//ge | execute 'g/\v\$[0-9]+$/de' | %sort u | %!uniq
" Remove duplicate adjacent method calls. Methods call order is kept.
"command! BtraceRemoveAdjacentDuplicateMethods %s/\v\(.*\)//ge | %!uniq (no
"line numbers)
command! BtraceRemoveAdjacentDuplicateMethods %!awk 'BEGIN {method=""} match($0,/.*\(/) { if (length(method)) { if (index($0,method) == 0) { print $0 } } else { print $0 } method =substr($0, RSTART, RLENGTH-1) }'

set ignorecase
set smartcase
set hidden
set tabstop=2 "2 spaces will be inserted when pressing TAB in INSERT mode
"set softtabstop=0 noexpandtab
set shiftwidth=2 "2 spaces will be inserted when indenting
"set wildmode=longest,list
set history=200

"highlight normal ctermfg=white ctermbg=yellow

set nocompatible
filetype plugin on
filetype indent on

" 'matchit' plugin
"set nocompatible
"filetype plugin on
runtime macros/matchit.vim

" Disable arrow keys in NORMAL mode
noremap <Up> <Nop>
noremap <Down> <Nop>
noremap <Left> <Nop>
noremap <Right> <Nop>

:map <F8> <C-E>:sleep 3500m<CR>j<F8>

function! GotoJump()
  jumps
  let j = input("Please select your jump: ")
  if j != ''
    let pattern = '\v\c^\+'
    if j =~ pattern
      let j = substitute(j, pattern, '', 'g')
      execute "normal " . j . "\<c-i>"
    else
      execute "normal " . j . "\<c-o>"
    endif
  endif
endfunction

"if $TERM_PROGRAM =~ "iTerm" works also for KDE "Konsole"
"    let &t_SI = "\<Esc>]50;CursorShape=1\x7" " Vertical bar in insert mode
"    let &t_EI = "\<Esc>]50;CursorShape=1\x7" " Vertical bar in normal mode
 "   let &t_SI = "\<Esc>]50;CursorShape=0\x7" " Block in insert mode
  "  let &t_EI = "\<Esc>]50;CursorShape=0\x7" " Block in normal mode
"endif

set nohlsearch

ベストアンサー1

Windowsにすでにローカル設定()があるようですsetlocal hlsearch。グローバル変更はhlsearchここには影響しません。セッションを再作成すると、これらの設定のみが保存されます。

おそらく最も簡単な解決策は、セッションファイルを開き(セッションをロードせずにテキストファイルとして)、単にhlsearchを設定する行を削除することです。

おすすめ記事