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-06-16T23:05:37
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

VimL

how get char under cursor an put in cmd 's' on vim

"ayl ................. copia para o registro 'a' o caractere sob o cursor
:%s/<c-r>a/"/g ....... substitui o conteúdo do registro a por aspas simples
https://snipt.net/embed/5ce3aaad6db9d314a66427b677a24978/
/raw/5ce3aaad6db9d314a66427b677a24978/
5ce3aaad6db9d314a66427b677a24978
vim
VimL
2
2019-06-24T14:01:25
True
False
False
/api/public/snipt/5071/
how-get-char-under-cursor-an-put-in-cmd-s-on-vim
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</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;ayl ................. copia para o registro &#39;a&#39; o caractere sob o cursor</span> </span><span id="L-2"><a name="L-2"></a><span class="p">:</span>%s<span class="sr">/&lt;c-r&gt;a/</span>&quot;/<span class="k">g</span> ....... substitui <span class="k">o</span> conteúdo <span class="k">do</span> registro <span class="k">a</span> por aspas simples </span></pre></div> </td></tr></table>
gvim, vim