: definir nohlsearch não funciona

0

Quando abro uma sessão existente com o VIM, a configuração set nohlsearch no final de ~/.vimrc não tem efeito. Só tem efeito quando eu o executar manualmente. Também notei que, se eu abrir um arquivo que não esteja na sessão, a configuração em ~/.vimrc terá efeito. A configuração também funciona se eu mudar para um buffer na sessão e executar :source $MYVIMRC .

Eu recriou a sessão com :mksession! , mas isso não ajudou. Estou usando o VIM 7.4.

Abaixo está o ~/.vimrc :

" For pre-processing books
command! Book %s/\v([Tt])heyre/hey're/gec | %s/\v([Ww])ont/on't/gec | %s/\v([Yy])oud/ou'd/gec | %s/\v([Nn])eednt/eedn't/gec | %s/\v([Ss])houldnt/houldn't/gec | %s/\v([Hh])asnt/asn't/gec | %s/\v([Cc])ant/an't/gec | %s/\v([Tt])hats/hat's/gec | %s/\v([Yy])oull/ou'll/gec | %s/\v([Yy])oure/ou're/gec | %s/\v([Yy])ouve/ou've/gec | %s/\v([Ii])ts/t's/gec | %s/\v([Dd])ont/on't/gec | %s/\v([Aa])rent/ren't/gec | %s/\v([Dd])oesnt/oesn't/gec | %s/\v([Dd])idnt/idn't/gec | %s/\v([Ii])snt/sn't/gec | %s/\v([Hh])eres/ere's/gec | %s/IDEs\C/IDE's/gec | %s/\v([Nn])onfinal/on-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*#(.*)//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
    
por ka3ak 08.02.2018 / 08:17

1 resposta

0

Parece que suas janelas já possuem configurações locais ( setlocal hlsearch ). Alterar o hlsearch global não afetará isso, e recriar a sessão apenas armazenará essas configurações novamente.

Provavelmente, a solução mais fácil é abrir o arquivo da sessão (como um arquivo de texto, não carregar a sessão) e simplesmente excluir as linhas que definem o hlsearch.

    
por 08.02.2018 / 11:05

Tags