snipt

Ctrl+h for KB shortcuts

VimL

mapeamentos para contar ocorrências de palavra e buscar palavra sob o cursor

1
2
3
4
5
6
" contagem de ocorrências de uma palavra (case insensitive)
nmap <F4> <esc>mz:%s/\c\<\(<c-r>=expand("<cword>")<cr>\)\>//gn<cr>`z
nmap <s-F4> <esc>mz:%s/\c\(<c-r>=expand("<cword>")<cr>\)//gn<cr>`z

" mapeamento para colocar palavra sob o cursor na busca
nnoremap <Leader>s :%s/\<<C-r><C-w>\>/
https://snipt.net/embed/5f9e3f4b71c0bb53841d81e2176ca930/
/raw/5f9e3f4b71c0bb53841d81e2176ca930/
5f9e3f4b71c0bb53841d81e2176ca930
vim
VimL
7
2019-05-24T06:04:25
True
False
False
/api/public/snipt/5754/
mapeamentos-para-contar-ocorrencias-de-palavra-e-buscar-palavra-sob-o-cursor
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c">&quot; contagem de ocorrências de uma palavra (case insensitive)</span> </span><span id="L-2"><a name="L-2"></a>nmap <span class="p">&lt;</span>F4<span class="p">&gt;</span> <span class="p">&lt;</span>esc<span class="p">&gt;</span><span class="k">mz</span>:%s<span class="sr">/\c\&lt;\(&lt;c-r&gt;=expand(&quot;&lt;cword&gt;&quot;)&lt;cr&gt;\)\&gt;/</span>/gn<span class="p">&lt;</span><span class="k">cr</span><span class="p">&gt;</span>`z </span><span id="L-3"><a name="L-3"></a>nmap <span class="p">&lt;</span>s<span class="p">-</span>F4<span class="p">&gt;</span> <span class="p">&lt;</span>esc<span class="p">&gt;</span><span class="k">mz</span>:%s<span class="sr">/\c\(&lt;c-r&gt;=expand(&quot;&lt;cword&gt;&quot;)&lt;cr&gt;\)/</span>/gn<span class="p">&lt;</span><span class="k">cr</span><span class="p">&gt;</span>`z </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a><span class="c">&quot; mapeamento para colocar palavra sob o cursor na busca</span> </span><span id="L-6"><a name="L-6"></a><span class="nb">nnoremap</span> <span class="p">&lt;</span>Leader<span class="p">&gt;</span>s :%s<span class="sr">/\&lt;&lt;C-r&gt;&lt;C-w&gt;\&gt;/</span> </span></pre></div> </td></tr></table>
gvim, vim