qid int64 4 8.14M | question stringlengths 20 48.3k | answers list | date stringlengths 10 10 | metadata list | input stringlengths 12 45k | output stringlengths 2 31.8k |
|---|---|---|---|---|---|---|
34,330 | <p>Occasionally I want to move all lines in a file to the top of that file. <code>:g/PATTERN/m0</code> almost does what I want, but because <code>:g</code> operates one line at a time in order, it will also reverse the affected lines.</p>
<hr />
<p>Example:</p>
<p>Consider this file. Say I want to separate lines contai... | [
{
"answer_id": 34331,
"author": "Mass",
"author_id": 13728,
"author_profile": "https://vi.stackexchange.com/users/13728",
"pm_score": 5,
"selected": true,
"text": "<p>Instead of moving the target lines up (and reversing them), move all the non-target lines down. Since lines are processe... | 2021/09/02 | [
"https://vi.stackexchange.com/questions/34330",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/37727/"
] | Occasionally I want to move all lines in a file to the top of that file. `:g/PATTERN/m0` almost does what I want, but because `:g` operates one line at a time in order, it will also reverse the affected lines.
---
Example:
Consider this file. Say I want to separate lines containing a number and move them to the top ... | Instead of moving the target lines up (and reversing them), move all the non-target lines down. Since lines are processed top-to-bottom, the order of non-target lines will be preserved. Also, the target lines will remain in order at the top of the buffer.
```
:v/\d/m$
```
`:v` is the opposite of `:g`, it applies to ... |
34,343 | <p><code>:files</code> is nice, but I want to delete a bunch of buffers at once. I know about <code>:bd n1 n2 ...</code> and <code>:m,nbd</code>, but it'd be nice to manipulate the list (e.g. to delete buffers) in a 'regular' window.</p>
<p>Is there any way to do this with vanilla Vim? Or are the <code>:bd</code> comma... | [
{
"answer_id": 34363,
"author": "Maxim Kim",
"author_id": 9333,
"author_profile": "https://vi.stackexchange.com/users/9333",
"pm_score": 2,
"selected": false,
"text": "<p>Here is the proof of concept.</p>\n<p>Create a function that deletes a buffer out of a line that has a buffer info:</... | 2021/09/02 | [
"https://vi.stackexchange.com/questions/34343",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/2629/"
] | `:files` is nice, but I want to delete a bunch of buffers at once. I know about `:bd n1 n2 ...` and `:m,nbd`, but it'd be nice to manipulate the list (e.g. to delete buffers) in a 'regular' window.
Is there any way to do this with vanilla Vim? Or are the `:bd` commands about as good as it gets?
This is definitely rel... | Here is the proof of concept.
Create a function that deletes a buffer out of a line that has a buffer info:
```
func! DeleteBuffer() abort
let bnr = matchstr(getline('.'), '^\s*\zs\d\+')
exe "confirm bd" . bnr
endfunc
noremap <space>de :call DeleteBuffer()<CR>
```
Basically if you have a lines like:
```
... |
34,370 | <p>Consider a window layout as this (which I've set up esentially at random).</p>
<pre class="lang-none prettyprint-override"><code>βββββββββ¬ββββββββ¬ββββββββ¬βββββββββ
β β β β β
β x β y β z β β
β β β β β
βββββββββ΄ββββββββ΄ββββββββ€ β
β ... | [
{
"answer_id": 34372,
"author": "Yegappan Lakshmanan",
"author_id": 29827,
"author_profile": "https://vi.stackexchange.com/users/29827",
"pm_score": 3,
"selected": true,
"text": "<p>You can use the <a href=\"https://vimhelp.org/eval.txt.html#winlayout%28%29\" rel=\"nofollow noreferrer\">... | 2021/09/04 | [
"https://vi.stackexchange.com/questions/34370",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/6498/"
] | Consider a window layout as this (which I've set up esentially at random).
```none
βββββββββ¬ββββββββ¬ββββββββ¬βββββββββ
β β β β β
β x β y β z β β
β β β β β
βββββββββ΄ββββββββ΄ββββββββ€ β
β β β
β u β ... | You can use the [winlayout()](https://vimhelp.org/eval.txt.html#winlayout%28%29) function to get information about the layout of the windows (rows and columns).
With the above window layout, this function will return (something similar to the following):
>
> ['col', [['row', [['col', [['row', [['leaf', 1007], ['leaf... |
34,371 | <p>(Related to <a href="https://vi.stackexchange.com/q/34370/6498">this other question of mine</a>.)</p>
<p>Is there a concrete reason to why rotating the windows <code>u</code>, <code>v</code>, and <code>[x,y,z]</code> is not allowed?</p>
<p>Or is it just a limitation that could be lifted in future versions of Vim?</p... | [
{
"answer_id": 34375,
"author": "Yegappan Lakshmanan",
"author_id": 29827,
"author_profile": "https://vi.stackexchange.com/users/29827",
"pm_score": 0,
"selected": false,
"text": "<p>As mentioned in the help for <a href=\"https://vimhelp.org/windows.txt.html#CTRL-W_r\" rel=\"nofollow nor... | 2021/09/04 | [
"https://vi.stackexchange.com/questions/34371",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/6498/"
] | (Related to [this other question of mine](https://vi.stackexchange.com/q/34370/6498).)
Is there a concrete reason to why rotating the windows `u`, `v`, and `[x,y,z]` is not allowed?
Or is it just a limitation that could be lifted in future versions of Vim?
```none
βββββββββ¬ββββββββ¬ββββββββ¬βββββββββ
β β β... | I see no technical reason this could not be achieved, so I'm going to speculate the answer is oversight and/or other priorities. It does rather complicate things, so it was simply not gotten around to. One immediate issue with relaxing this restriction is it becomes ambiguous whether `ctrl-w r` will move your window up... |
34,388 | <p>My init.vim code</p>
<pre><code>autocmd FileType cpp nnoremap <F4> :RunWithFile ~/Downloads/ > output.txt && cat output.txt
</code></pre>
<p><strong>I want my cursor position to be exact</strong> <code>31 times <left></code> in command line. <br>
or after <code>~/Downloads/</code> <br></p>
<p>... | [
{
"answer_id": 34389,
"author": "Matt",
"author_id": 22797,
"author_profile": "https://vi.stackexchange.com/users/22797",
"pm_score": 1,
"selected": false,
"text": "<ol>\n<li>Normally prefer <code>:h ftplugin</code> over <code>autocmd FileType</code>. If still want <code>autocmd</code>, ... | 2021/09/05 | [
"https://vi.stackexchange.com/questions/34388",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/36876/"
] | My init.vim code
```
autocmd FileType cpp nnoremap <F4> :RunWithFile ~/Downloads/ > output.txt && cat output.txt
```
**I want my cursor position to be exact** `31 times <left>` in command line.
or after `~/Downloads/`
Like this
[](https:... | There is no straightforward way to tell vim to land the cursor at a particular place in the cmdline during a map, but there are a number of workarounds.
1. Direct positioning
```
autocmd FileType cpp nnoremap <F4> :RunWithFile ~/Downloads/ > output.txt && cat output.txt<c-r>=setcmdpos(getcmdpos()-31)[1]<cr>
```
You... |
34,401 | <h4>Problem specification</h4>
<p>I would love to have a medical spell dictionary in <code>vim</code>.
Currently, I have a lot of medical terms in my own personal English dictionary right now. However, using an official medical dictionary would be a superior solution.</p>
<h3>What I tried</h3>
<p>So I tried adding the ... | [
{
"answer_id": 34402,
"author": "Bram Moolenaar",
"author_id": 37795,
"author_profile": "https://vi.stackexchange.com/users/37795",
"pm_score": 7,
"selected": true,
"text": "<p>The "medical" spell file does not exist, it is just an example of a name that is longer than two char... | 2021/09/06 | [
"https://vi.stackexchange.com/questions/34401",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/26536/"
] | #### Problem specification
I would love to have a medical spell dictionary in `vim`.
Currently, I have a lot of medical terms in my own personal English dictionary right now. However, using an official medical dictionary would be a superior solution.
### What I tried
So I tried adding the following to my `vimrc`:
`... | The "medical" spell file does not exist, it is just an example of a name that is longer than two characters. You would have to generate one yourself. |
34,433 | <p>If your cursor is on top of a "<code>{</code>", pressing <code>%</code> will send it to its matching "<code>}</code>". I like that behaviour.</p>
<p>However, if your cursor is <em>behind</em> a "<code>{</code>", pressing <code>%</code> will "look ahead", and also send the curs... | [
{
"answer_id": 34434,
"author": "Maxim Kim",
"author_id": 9333,
"author_profile": "https://vi.stackexchange.com/users/9333",
"pm_score": 2,
"selected": false,
"text": "<p>The only way I can see is to create your own mapping that should do what you want, for example:</p>\n<pre><code>nnore... | 2021/09/10 | [
"https://vi.stackexchange.com/questions/34433",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/34059/"
] | If your cursor is on top of a "`{`", pressing `%` will send it to its matching "`}`". I like that behaviour.
However, if your cursor is *behind* a "`{`", pressing `%` will "look ahead", and also send the cursor to its matching "`}`".
I'd prefer if vim only considered what was immediately under the cursor, and didn't ... | Since a comment under the question mentions that OP is using the plugin [vim-matchup](https://github.com/andymass/vim-matchup/), I'll give the match-up specific solution. The plugin provides `matchup#custom#define_motion` to facilitate such customization. This motion boils down to checking if there is a delimiter at th... |
34,449 | <p>I'm trying to make Vim reload its vimrc when I save a file. I have found different solutions, but none of them works for me for some reason.</p>
<p>Vim version: 8.2.2824, OS: Windows 7.</p>
<p>My vimrc:</p>
<pre><code>" I start Vim, type foo, save a buffer as test.txt,
" change colorcolumn to 20, type bar ... | [
{
"answer_id": 34450,
"author": "Maxim Kim",
"author_id": 9333,
"author_profile": "https://vi.stackexchange.com/users/9333",
"pm_score": 3,
"selected": true,
"text": "<p>Following works for me:</p>\n<pre><code>augroup reload_vimrc | au!\n au BufWritePost $MYVIMRC source $MYVIMRC\naugr... | 2021/09/11 | [
"https://vi.stackexchange.com/questions/34449",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/7169/"
] | I'm trying to make Vim reload its vimrc when I save a file. I have found different solutions, but none of them works for me for some reason.
Vim version: 8.2.2824, OS: Windows 7.
My vimrc:
```
" I start Vim, type foo, save a buffer as test.txt,
" change colorcolumn to 20, type bar in test.txt, and save it again.
" T... | Following works for me:
```
augroup reload_vimrc | au!
au BufWritePost $MYVIMRC source $MYVIMRC
augroup END
```
>
> " version 1
> " autocmd! BufWritePost $MYVIMRC execute "normal! :source $MYVIMRC"
>
>
>
This is a bit awkward way to `source $MYVIMRC`
>
> " version 2
> " autocmd! BufWritePost $MYVIMRC sour... |
34,473 | <h3>Requirements</h3>
<p>In a <strong>batch</strong> manner, i.e., with <code>ex</code>, <code>vim -e</code> or <code>vim -E</code>, I want to print all lines between line <strong>b1</strong> and line <strong>b2</strong>, boundaries included.</p>
<p><strong>b1</strong> is:</p>
<ul>
<li>The first line with a "sta&q... | [
{
"answer_id": 34475,
"author": "B Layer",
"author_id": 11054,
"author_profile": "https://vi.stackexchange.com/users/11054",
"pm_score": 2,
"selected": true,
"text": "<p>Those requirements make relying solely on pattern-ranges tricky...perhaps even impossible though I didn't spend too mu... | 2021/09/13 | [
"https://vi.stackexchange.com/questions/34473",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/30440/"
] | ### Requirements
In a **batch** manner, i.e., with `ex`, `vim -e` or `vim -E`, I want to print all lines between line **b1** and line **b2**, boundaries included.
**b1** is:
* The first line with a "sta" match, if present.
* The first line of the file, otherwise.
**b2** is:
* The last line with an "end" match, if ... | Those requirements make relying solely on pattern-ranges tricky...perhaps even impossible though I didn't spend too much time thinking about it. Instead I figured I'd go the KISS route and use a search and mark approach and then use the marks as a range to be printed.
I'll lay it all out on individual lines:
* `call ... |
34,476 | <p>I have a mapping for <code>m</code> and a mapping for <code>m/</code> in the same buffer, in Normal mode.</p>
<p>If I type <code>m</code>, is there a way to tell Vim to stop waiting for the 2nd character, and to just submit the current command as-typed?</p>
<p>I don't want to shorten the timeout or change any other ... | [
{
"answer_id": 34475,
"author": "B Layer",
"author_id": 11054,
"author_profile": "https://vi.stackexchange.com/users/11054",
"pm_score": 2,
"selected": true,
"text": "<p>Those requirements make relying solely on pattern-ranges tricky...perhaps even impossible though I didn't spend too mu... | 2021/09/14 | [
"https://vi.stackexchange.com/questions/34476",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4674/"
] | I have a mapping for `m` and a mapping for `m/` in the same buffer, in Normal mode.
If I type `m`, is there a way to tell Vim to stop waiting for the 2nd character, and to just submit the current command as-typed?
I don't want to shorten the timeout or change any other "global" behavior. I just want to have the abili... | Those requirements make relying solely on pattern-ranges tricky...perhaps even impossible though I didn't spend too much time thinking about it. Instead I figured I'd go the KISS route and use a search and mark approach and then use the marks as a range to be printed.
I'll lay it all out on individual lines:
* `call ... |
34,497 | <p>jedi-vim appears to prevent mapping [[ to # and ]] to *</p>
<p>mapping does not alter behaviour produced by [[ or ]] in .py files when jedi-vim in bundle folder (and does alter behaviour in .py files otherwise). Mapping succeeds in altering behaviour on other filetypes (tex files), but not on files with no suffix, w... | [
{
"answer_id": 34475,
"author": "B Layer",
"author_id": 11054,
"author_profile": "https://vi.stackexchange.com/users/11054",
"pm_score": 2,
"selected": true,
"text": "<p>Those requirements make relying solely on pattern-ranges tricky...perhaps even impossible though I didn't spend too mu... | 2021/09/14 | [
"https://vi.stackexchange.com/questions/34497",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/37934/"
] | jedi-vim appears to prevent mapping [[ to # and ]] to \*
mapping does not alter behaviour produced by [[ or ]] in .py files when jedi-vim in bundle folder (and does alter behaviour in .py files otherwise). Mapping succeeds in altering behaviour on other filetypes (tex files), but not on files with no suffix, whether o... | Those requirements make relying solely on pattern-ranges tricky...perhaps even impossible though I didn't spend too much time thinking about it. Instead I figured I'd go the KISS route and use a search and mark approach and then use the marks as a range to be printed.
I'll lay it all out on individual lines:
* `call ... |
34,504 | <p>Capital <code>A</code> in Vim takes me to the last character in insert mode, but can I go to the nth-to-last character in insert mode (or append mode) in vim?</p>
<p>Example:</p>
<pre><code>this is some t|ext
</code></pre>
<p>how to go specifically to the location of the <code>|</code> in insert mode, I would imagin... | [
{
"answer_id": 34507,
"author": "Drek",
"author_id": 37949,
"author_profile": "https://vi.stackexchange.com/users/37949",
"pm_score": 0,
"selected": false,
"text": "<p><code><ALT-$> [count] hi</code> where <code>[count]</code> is a number</p>\n<ol>\n<li>the Alt key to enter command... | 2021/09/15 | [
"https://vi.stackexchange.com/questions/34504",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/37947/"
] | Capital `A` in Vim takes me to the last character in insert mode, but can I go to the nth-to-last character in insert mode (or append mode) in vim?
Example:
```
this is some t|ext
```
how to go specifically to the location of the `|` in insert mode, I would imagine something like `<n>+A` where `n` is an integer. I ... | I concocted a script that does what you want. I think it handles most corner cases, however you might find some bugs down the road if you decide to use it.
```
function! AWithCount(count) abort
" default behaviour (no count)
if !a:count
"append to end of line, like `A`
startinsert!
return
endif
" ... |
34,505 | <p>I have different templates in this directory <code>~/Documents/Library/</code> <br>
like: Template.cpp, normal.cpp, advanced.cpp</p>
<p>Normally I use this:</p>
<pre><code>autocmd BufNewFile *.cpp 0r ~/Documents/Library/Template.cpp
</code></pre>
<p>I want to add <strong>an option "choose template"</strong... | [
{
"answer_id": 34567,
"author": "D. Ben Knoble",
"author_id": 10604,
"author_profile": "https://vi.stackexchange.com/users/10604",
"pm_score": 1,
"selected": false,
"text": "<p>A rough sketch with lots of bugs, probably. The function names could use some work, too.</p>\n<pre><code>functi... | 2021/09/15 | [
"https://vi.stackexchange.com/questions/34505",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/36876/"
] | I have different templates in this directory `~/Documents/Library/`
like: Template.cpp, normal.cpp, advanced.cpp
Normally I use this:
```
autocmd BufNewFile *.cpp 0r ~/Documents/Library/Template.cpp
```
I want to add **an option "choose template"** for new files that I create via `vim file.cpp` or `vim -p file1... | A rough sketch with lots of bugs, probably. The function names could use some work, too.
```
function Templates(ext) abort
return glob(printf('~/Documents/Library/**/*.%s', a:ext), v:false, v:true)
endfunction
function ChooseTemplateAll() abort
const ext = fnamemodify(@%, ':e')
call popup_menu(Templates(ext), #... |
34,510 | <p>I have a custom command for stamping time in my log files. However, I would like that format to match the one of bash command <code>date</code>.</p>
<p>For example, I use this command:</p>
<pre><code>:command InLog pu=strftime(\"\n***** IN: %c\n\n\n\") | startinsert
</code></pre>
<p>which prints:</p>
<p><... | [
{
"answer_id": 34512,
"author": "Ralf",
"author_id": 19763,
"author_profile": "https://vi.stackexchange.com/users/19763",
"pm_score": 3,
"selected": true,
"text": "<p>While Christian Brabandt already gave the correct answer in a comment:</p>\n<pre><code>:echo strftime('%a %b %d %T %Z %Y'... | 2021/09/16 | [
"https://vi.stackexchange.com/questions/34510",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/36810/"
] | I have a custom command for stamping time in my log files. However, I would like that format to match the one of bash command `date`.
For example, I use this command:
```
:command InLog pu=strftime(\"\n***** IN: %c\n\n\n\") | startinsert
```
which prints:
**\*\*\*\*\* IN: Thu Sep 16 01:51:47 2021**
However, I ... | While Christian Brabandt already gave the correct answer in a comment:
```
:echo strftime('%a %b %d %T %Z %Y')
```
I would like to add a few words.
The most important part from the help documentation:
>
> The accepted {format} depends on your system, thus this is not portable!
> See the manual page of the C funct... |
34,528 | <p>I am trying to autogenerate an output every time I save the file with :update or with :w. This is what I got so far:</p>
<pre><code>augroup renderRmd | au!
autocmd BufWritePost *.rmd !'Rscript -e "rmarkdown::render(<afile>:p:S)"'
augroup end
</code></pre>
<p>But I get:</p>
<pre><code>:!'Rscript -... | [
{
"answer_id": 34536,
"author": "lf_araujo",
"author_id": 33341,
"author_profile": "https://vi.stackexchange.com/users/33341",
"pm_score": 1,
"selected": false,
"text": "<p>Although an async alternative would be better, this one is pretty neat. The problem as comments pointed out was the... | 2021/09/18 | [
"https://vi.stackexchange.com/questions/34528",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/33341/"
] | I am trying to autogenerate an output every time I save the file with :update or with :w. This is what I got so far:
```
augroup renderRmd | au!
autocmd BufWritePost *.rmd !'Rscript -e "rmarkdown::render(<afile>:p:S)"'
augroup end
```
But I get:
```
:!'Rscript -e "rmarkdown::render('/home/luis/Documents/2020-Ca... | With <https://github.com/tpope/vim-dispatch> installed, I would do something like the following
```
" with appropriate augroup, of course
autocmd BufWritePost *.Rmd Dispatch Rscript -e "rmarkdown::render(<afile>:p:S)"
```
You could use other commands from that plugin depending on how background/foreground you want t... |
34,532 | <p>I want to source a file in the same shell process vim was started, from within vim as an ex command. As far as I know, vim creates a new subshell and run commands. <s>In addition to that, If I source a file, and then start vim, vim does not detect the recently added environment variables.</s> (VIm Actually do detect... | [
{
"answer_id": 34536,
"author": "lf_araujo",
"author_id": 33341,
"author_profile": "https://vi.stackexchange.com/users/33341",
"pm_score": 1,
"selected": false,
"text": "<p>Although an async alternative would be better, this one is pretty neat. The problem as comments pointed out was the... | 2021/09/19 | [
"https://vi.stackexchange.com/questions/34532",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/30665/"
] | I want to source a file in the same shell process vim was started, from within vim as an ex command. As far as I know, vim creates a new subshell and run commands. ~~In addition to that, If I source a file, and then start vim, vim does not detect the recently added environment variables.~~ (VIm Actually do detect recen... | With <https://github.com/tpope/vim-dispatch> installed, I would do something like the following
```
" with appropriate augroup, of course
autocmd BufWritePost *.Rmd Dispatch Rscript -e "rmarkdown::render(<afile>:p:S)"
```
You could use other commands from that plugin depending on how background/foreground you want t... |
34,538 | <p>By using the following code...</p>
<pre class="lang-lua prettyprint-override"><code>vim.fn.termopen("foo")
</code></pre>
<p>I can open a terminal with a certain command. What I want to do is run a Lua function from a plugin upon exiting the terminal.</p>
<p>Pseudo Code:</p>
<pre><code>vim.fn.termopen("... | [
{
"answer_id": 34541,
"author": "InsertSON",
"author_id": 34428,
"author_profile": "https://vi.stackexchange.com/users/34428",
"pm_score": 1,
"selected": false,
"text": "<p>After a bit of research, I found that there are two autocommands I can use that suit my needs</p>\n<pre><code>au Te... | 2021/09/19 | [
"https://vi.stackexchange.com/questions/34538",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/34428/"
] | By using the following code...
```lua
vim.fn.termopen("foo")
```
I can open a terminal with a certain command. What I want to do is run a Lua function from a plugin upon exiting the terminal.
Pseudo Code:
```
vim.fn.termopen("foo", run "lua require('my-plugin').someFunction()" upon exiting)
```
Is this possible? | After a bit of research, I found that there are two autocommands I can use that suit my needs
```
au TermClose * lua require('my-plugin').someFunction()
or
au TermLeave * lua require('my-plugin').someFunction()
```
The first one works better for me because I only want to run my function once the terminal is killed... |
34,574 | <p>After going through the renaming guides from the doc folder in vim I found a way to replace text with the input <code>:%s/frompattern/topattern/g</code>.
Reaching the renaming files with the file browser tutorial/guide I managed to learn the MR and R method stated in the netrw-R help file.</p>
<p>Then I tried to use... | [
{
"answer_id": 34575,
"author": "Maxim Kim",
"author_id": 9333,
"author_profile": "https://vi.stackexchange.com/users/9333",
"pm_score": 1,
"selected": false,
"text": "<p>Netrw doesn't support file renames based on buffer changes (the way emacs dired does it).</p>\n<p>There are external ... | 2021/09/23 | [
"https://vi.stackexchange.com/questions/34574",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/38051/"
] | After going through the renaming guides from the doc folder in vim I found a way to replace text with the input `:%s/frompattern/topattern/g`.
Reaching the renaming files with the file browser tutorial/guide I managed to learn the MR and R method stated in the netrw-R help file.
Then I tried to use the text replacing ... | Netrw doesn't support file renames based on buffer changes (the way emacs dired does it).
There are external tools like `vidir` and `qmv` that runs vim (to be precise `EDITOR`) with directory contents where you can change filenames to be renamed "en masse".
It looks like this:
[ thus it does it eating space of other splits.
So back to your reques... |
34,630 | <p>I would like to jump through specific syntax elements in a file. For example, quickly navigate to the next string element. In a <code>.vim</code> file strings are defined as <em>vimString</em> syntax elements. For clarification, the syntax element under the cursor can be found with the following command:</p>
<pre><c... | [
{
"answer_id": 34641,
"author": "Sakari Cajanus",
"author_id": 1672,
"author_profile": "https://vi.stackexchange.com/users/1672",
"pm_score": 0,
"selected": false,
"text": "<p>With Neovim, you can use <a href=\"https://github.com/nvim-treesitter/nvim-treesitter\" rel=\"nofollow noreferre... | 2021/09/27 | [
"https://vi.stackexchange.com/questions/34630",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/31814/"
] | I would like to jump through specific syntax elements in a file. For example, quickly navigate to the next string element. In a `.vim` file strings are defined as *vimString* syntax elements. For clarification, the syntax element under the cursor can be found with the following command:
```
synIDattr(synID(line('.'), ... | In recent versions of vim (around patch 8.2.0915), `search` takes a skip argument which can be used to create a move forward/backward to syntax group motion. Here is a rudimentary implementation:
```
function! SynMatches(syn) abort
return synIDattr(synID(line('.'), col('.'), 1), "name") =~# a:syn
endfunction
functi... |
34,631 | <p>I don't know very well how to work with vimscript... Because of that, I'd like to find a way where I can easily test what I'm trying to accomplish on my vimrc file, with some prints like on other programming languages.</p>
<p>To demonstrate what I'd like to do, I'll give some examples with other programming language... | [
{
"answer_id": 39547,
"author": "Dan Piponi",
"author_id": 2160,
"author_profile": "https://vi.stackexchange.com/users/2160",
"pm_score": 1,
"selected": false,
"text": "<p>This is implied by the comments but I think it'd be useful to have it as a self-contained answer. Use <code>vim --cm... | 2021/09/27 | [
"https://vi.stackexchange.com/questions/34631",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/32434/"
] | I don't know very well how to work with vimscript... Because of that, I'd like to find a way where I can easily test what I'm trying to accomplish on my vimrc file, with some prints like on other programming languages.
To demonstrate what I'd like to do, I'll give some examples with other programming languages...
In ... | This is implied by the comments but I think it'd be useful to have it as a self-contained answer. Use `vim --cmd ":source <filename>"`.
Eg. when `test.vim` contains
```
echo "Hello, world!"
quit!
```
and I type `vim --cmd "source test.vim"` the output is
```
Hello, world!
```
I think this is what you want. Alter... |
34,658 | <p>I am editing tab-delimited data in a plaintext file (that was originally a spreadsheet) and I'd like to quickly jump forward to the next entry, the character after the next "tab" character.</p>
<p>So far the closest I've gotten is <code>/\t/e+1</code>. This works pretty well except that if comes to a blank... | [
{
"answer_id": 39547,
"author": "Dan Piponi",
"author_id": 2160,
"author_profile": "https://vi.stackexchange.com/users/2160",
"pm_score": 1,
"selected": false,
"text": "<p>This is implied by the comments but I think it'd be useful to have it as a self-contained answer. Use <code>vim --cm... | 2021/09/30 | [
"https://vi.stackexchange.com/questions/34658",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/37865/"
] | I am editing tab-delimited data in a plaintext file (that was originally a spreadsheet) and I'd like to quickly jump forward to the next entry, the character after the next "tab" character.
So far the closest I've gotten is `/\t/e+1`. This works pretty well except that if comes to a blank entry - just a tab character ... | This is implied by the comments but I think it'd be useful to have it as a self-contained answer. Use `vim --cmd ":source <filename>"`.
Eg. when `test.vim` contains
```
echo "Hello, world!"
quit!
```
and I type `vim --cmd "source test.vim"` the output is
```
Hello, world!
```
I think this is what you want. Alter... |
34,693 | <p>What I have referenced in my <strong>.zshrc</strong> file:</p>
<pre><code>nvim --headless -c 'LspInstall tsserver | qall'
</code></pre>
<p>This doesn't work. The <code>qall</code> is regarded as an argument of <code>LspInstall</code> while I didn't mean to. The <code>LspInstall</code> will take some time to download... | [
{
"answer_id": 34694,
"author": "B Layer",
"author_id": 11054,
"author_profile": "https://vi.stackexchange.com/users/11054",
"pm_score": 4,
"selected": true,
"text": "<p>I guess the <code>LspInstall</code> user command is configured to take multiple parameters. No matter, you can use mul... | 2021/10/05 | [
"https://vi.stackexchange.com/questions/34693",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/10189/"
] | What I have referenced in my **.zshrc** file:
```
nvim --headless -c 'LspInstall tsserver | qall'
```
This doesn't work. The `qall` is regarded as an argument of `LspInstall` while I didn't mean to. The `LspInstall` will take some time to download the language servers, thus it seems like that I need some pseudo-comm... | I guess the `LspInstall` user command is configured to take multiple parameters. No matter, you can use multiple `-c` flags, each with their own command(s).
Specifically...
>
> You can use up to 10 "+" or "-c" arguments in a Vim command. They are executed in the order given. A "-S" argument counts as a "-c" argument... |
34,724 | <p>I have this snippet for latex:</p>
<pre><code># theta --> \theta
context "math()"
snippet theta "theta" iA
\theta
endsnippet
</code></pre>
<p>My problem is that if I type <code>theta</code>, it is transformed automatically to <code>\theta</code>, but then if I press <code><tab></code>, i... | [
{
"answer_id": 34694,
"author": "B Layer",
"author_id": 11054,
"author_profile": "https://vi.stackexchange.com/users/11054",
"pm_score": 4,
"selected": true,
"text": "<p>I guess the <code>LspInstall</code> user command is configured to take multiple parameters. No matter, you can use mul... | 2021/10/08 | [
"https://vi.stackexchange.com/questions/34724",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/38253/"
] | I have this snippet for latex:
```
# theta --> \theta
context "math()"
snippet theta "theta" iA
\theta
endsnippet
```
My problem is that if I type `theta`, it is transformed automatically to `\theta`, but then if I press `<tab>`, it expands to `\\theta` which I do not want.
One solution could be to expand **only** ... | I guess the `LspInstall` user command is configured to take multiple parameters. No matter, you can use multiple `-c` flags, each with their own command(s).
Specifically...
>
> You can use up to 10 "+" or "-c" arguments in a Vim command. They are executed in the order given. A "-S" argument counts as a "-c" argument... |
34,735 | <p>I would like to tag lines with a certain text property and then sort all lines with that text property to come to the top. How can I sort based on having a text property rather than a pattern match?</p>
| [
{
"answer_id": 34736,
"author": "B Layer",
"author_id": 11054,
"author_profile": "https://vi.stackexchange.com/users/11054",
"pm_score": 2,
"selected": false,
"text": "<p>There's nothing like that built in. A custom function would be necessary. An actual general sort would be fairly invo... | 2021/10/09 | [
"https://vi.stackexchange.com/questions/34735",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/37865/"
] | I would like to tag lines with a certain text property and then sort all lines with that text property to come to the top. How can I sort based on having a text property rather than a pattern match? | There's nothing like that built in. A custom function would be necessary. An actual general sort would be fairly involved but I can provide you with a function that will do the one specific thing you mention: move all lines with a certain text property to the top of the buffer. (Since "a certain text property" is ambig... |
34,751 | <p>I'm using <a href="https://python-poetry.org/" rel="nofollow noreferrer">Poetry</a> to manage my virtual environments for Python and I'm using <a href="https://github.com/puremourning/vimspector" rel="nofollow noreferrer">Vimspector</a> as a debugger plugin for Vim.</p>
<p>How can I use the Poetry venv when starting... | [
{
"answer_id": 34865,
"author": "Squioc",
"author_id": 38547,
"author_profile": "https://vi.stackexchange.com/users/38547",
"pm_score": 2,
"selected": false,
"text": "<p>I think you should create your own adapter in your vimspector configuration.</p>\n<p>You can find help in <a href=\"ht... | 2021/10/12 | [
"https://vi.stackexchange.com/questions/34751",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/29877/"
] | I'm using [Poetry](https://python-poetry.org/) to manage my virtual environments for Python and I'm using [Vimspector](https://github.com/puremourning/vimspector) as a debugger plugin for Vim.
How can I use the Poetry venv when starting debugging?
I'm thinking that all that has to be done is to run the command `poetr... | For those that trying to find an answer, creating a specific adapter is not the best approach.
I asked at [Gitter](https://gitter.im/vimspector/Lobby) of Vimspector and the best way is to specify the path of Python executable, which can be found using `which python` when inside Poetry.
That is, at the configuration (... |
34,763 | <p>Currently:</p>
<ul>
<li>I have some key binding <code>A</code> β <code>^X^O</code> (in insert mode) to omni-complete something</li>
<li>I have some key binding <code>B</code> β <code>^Ogj</code> to temporarily do something in normal mode (in this case, move down a display line)</li>
</ul>
<p>However, if I press ^A^B... | [
{
"answer_id": 34764,
"author": "user202729",
"author_id": 26108,
"author_profile": "https://vi.stackexchange.com/users/26108",
"pm_score": 0,
"selected": false,
"text": "<p>These are some workaround:</p>\n<ul>\n<li><code><space><backspace></code>. Works (space is guaranteed ... | 2021/10/15 | [
"https://vi.stackexchange.com/questions/34763",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/26108/"
] | Currently:
* I have some key binding `A` β `^X^O` (in insert mode) to omni-complete something
* I have some key binding `B` β `^Ogj` to temporarily do something in normal mode (in this case, move down a display line)
However, if I press ^A^B, the second ^O conflicts with the first ^O and removes the omnicompletion.
... | The second `^O` actually functions like `^N` when omnicompletion is active. From `:h i^x^o`, we see that
>
> CTRL-O or
> CTRL-N : Use the next match. This match replaces the previous one.
>
>
>
To exit omnicompletion, we need a key that "does nothing", as suggested by your answer. One such combination is `^gU` (T... |
34,784 | <p>If I do <code>gg=G</code> on a file with the following text</p>
<pre><code>- 2018-2019 ICPC Northwestern European Regional Programming Contest (NWERC 2018)
- 2020 ICPC Universidad Nacional de Colombia Programming Contest
- 2018-2019 ICPC Southwestern European Regional Programming Contest (SWERC 2018)
</code></pre>... | [
{
"answer_id": 34814,
"author": "Matt",
"author_id": 22797,
"author_profile": "https://vi.stackexchange.com/users/22797",
"pm_score": 3,
"selected": true,
"text": "<p>This is a misuse of <code>=</code> operator.</p>\n<p>Actually, Vim has two builtin "formatting" operators, i.e.... | 2021/10/18 | [
"https://vi.stackexchange.com/questions/34784",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/11096/"
] | If I do `gg=G` on a file with the following text
```
- 2018-2019 ICPC Northwestern European Regional Programming Contest (NWERC 2018)
- 2020 ICPC Universidad Nacional de Colombia Programming Contest
- 2018-2019 ICPC Southwestern European Regional Programming Contest (SWERC 2018)
```
it becomes
```
- 2018-2019 ICP... | This is a misuse of `=` operator.
Actually, Vim has two builtin "formatting" operators, i.e. `=` and `gq` (there's also `gw` that is simply the same as "internal" `gq`-formatter).
`=` is supposed for use with programming languages. Of course, it could be set up to do anything you like, but it defaults to C. Does it c... |
34,790 | <p>I want to override NetRW's response to <code><CR></code>. When I hit enter, I want to:</p>
<ul>
<li>get the path of the file or directory of the line with the cursor in the <code>:Lex</code> window</li>
<li>test if path is a file</li>
<li>if the path is a file:
<ul>
<li>the explorer from <code>:Lex</code> clo... | [
{
"answer_id": 34822,
"author": "D. Ben Knoble",
"author_id": 10604,
"author_profile": "https://vi.stackexchange.com/users/10604",
"pm_score": 2,
"selected": false,
"text": "<p>Here's a couple ideas:</p>\n<ul>\n<li>Combine <code>b:netrw_curdir</code> with <code>expand('<cfile>')</c... | 2021/10/20 | [
"https://vi.stackexchange.com/questions/34790",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/20193/"
] | I want to override NetRW's response to `<CR>`. When I hit enter, I want to:
* get the path of the file or directory of the line with the cursor in the `:Lex` window
* test if path is a file
* if the path is a file:
+ the explorer from `:Lex` closes
+ `tab drop` to the path
+ open `:Lex`
However, I have no idea how... | Just found a better way without opening file, and is consistent.
```
netrw#Call('NetrwFile', netrw#Call('NetrwGetWord'))
``` |
34,803 | <p>I have two plugins (todo.txt-vim and vim-buffergator) that both map the</p>
<p><localleader>b</p>
<p>command (for .txt files at least). One plugin ended up dominating the other.</p>
<p>I solved this by removing the mapping from one of the plugins, but this is hardly ideal long term (plugin updates, moving to n... | [
{
"answer_id": 34804,
"author": "Luc Hermitte",
"author_id": 626,
"author_profile": "https://vi.stackexchange.com/users/626",
"pm_score": 3,
"selected": true,
"text": "<p>If the plugin have been (dare I say: correctly) been designed with the end-user in mind, they should be defining thei... | 2021/10/21 | [
"https://vi.stackexchange.com/questions/34803",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/8792/"
] | I have two plugins (todo.txt-vim and vim-buffergator) that both map the
<localleader>b
command (for .txt files at least). One plugin ended up dominating the other.
I solved this by removing the mapping from one of the plugins, but this is hardly ideal long term (plugin updates, moving to new machines and so on)
Wha... | If the plugin have been (dare I say: correctly) been designed with the end-user in mind, they should be defining their mappings with something like
```
if !hasmapto('<Plug>Something')
nmap <leader>b <Plug>Something
endif
```
If that's the case, you just need to choose either one of the two default mappings and o... |
34,850 | <p>It is possible in vanilla vim to:</p>
<ol>
<li>visual select some number of characters, e.g. a variable name in code</li>
<li>type <kbd>c</kbd> to begin replacing selection in insert mode</li>
<li>type a replacement (variable name)</li>
<li>exit insert mode</li>
<li>navigate to another location (typically <code>n</c... | [
{
"answer_id": 34860,
"author": "Steven Lu",
"author_id": 390,
"author_profile": "https://vi.stackexchange.com/users/390",
"pm_score": 0,
"selected": false,
"text": "<p>As far as I can tell (Will need a few days of testing to confirm) This dragon has been slayed with the help of a sugges... | 2021/10/27 | [
"https://vi.stackexchange.com/questions/34850",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/390/"
] | It is possible in vanilla vim to:
1. visual select some number of characters, e.g. a variable name in code
2. type `c` to begin replacing selection in insert mode
3. type a replacement (variable name)
4. exit insert mode
5. navigate to another location (typically `n` to go to the next instance of original variable nam... | #### Explanation of the problem
The visual put + repeat pattern is quite broken in vim. Internally, vim implements visual puts as a literal visual delete followed by a normal mode put. However, only the delete part gets stored in the repeat buffer. So, usage of `.` after visual put simply deletes text in the shape of ... |
34,899 | <p>How can I simplify the following codes in my <code>init.lua</code>?
(For "simplify" I mean that by <code>vim.cmd(...)</code> you're actually letting Lua run vimscript under the hood. But there is probably a Lua API to call instead. For example currently I learned that: <code>vim.cmd("set nowrap")... | [
{
"answer_id": 34901,
"author": "Matt",
"author_id": 22797,
"author_profile": "https://vi.stackexchange.com/users/22797",
"pm_score": 2,
"selected": false,
"text": "<p>Neovim API is neither complete nor stable, and so, IMO and contrary to what other people may suggest, there's no good po... | 2021/11/04 | [
"https://vi.stackexchange.com/questions/34899",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/10189/"
] | How can I simplify the following codes in my `init.lua`?
(For "simplify" I mean that by `vim.cmd(...)` you're actually letting Lua run vimscript under the hood. But there is probably a Lua API to call instead. For example currently I learned that: `vim.cmd("set nowrap")` can be re-written to `vim.opt.wrap = false`.)
`... | After some searching.
* `vim.g.mapleader = ' '`: Simplest already.
* `vim.cmd('cnoreabbrev S LspStart')`: This has not been implemented. (read from a neovim GitHub issue)
* `vim.cmd('noremap! <S-Insert> <C-W>')`:
```
vim.keymap.set('!', '<S-Insert>', '<C-W>')
```
* `vim.cmd('runtime plugin/astronauta.vim')` can be
... |
34,905 | <p>Is there a way to use a read filter that calls an interactive command?</p>
<p>My use case is a grep command that returns a long list of tags that I might want to include in a blog post; I was hoping to be able to filter it with fzf, something like:</p>
<pre><code>:r ! grep foo bar.txt | fzf -m
</code></pre>
<p>Unfor... | [
{
"answer_id": 34906,
"author": "n8henrie",
"author_id": 25201,
"author_profile": "https://vi.stackexchange.com/users/25201",
"pm_score": 2,
"selected": true,
"text": "<p>On MacOS and Linux, this seems to work in vim (but not neovim):</p>\n<pre><code>:set noshelltemp\n</code></pre>\n<p>A... | 2021/11/04 | [
"https://vi.stackexchange.com/questions/34905",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/25201/"
] | Is there a way to use a read filter that calls an interactive command?
My use case is a grep command that returns a long list of tags that I might want to include in a blog post; I was hoping to be able to filter it with fzf, something like:
```
:r ! grep foo bar.txt | fzf -m
```
Unfortunately this doesn't show the... | On MacOS and Linux, this seems to work in vim (but not neovim):
```
:set noshelltemp
```
Afterwards this works as hoped.
```
:r ! echo -e 'foo\nbar\nbaz' | fzf -m
``` |
34,909 | <p>I'm searching for a command (let's say Ctrl+j) to add to my <em>.vimrc</em> to erase the last character of the line in normal mode, without changing position of the cursor. I'm beginner in this <em>.vimrc</em> language, sorry if it's too easy</p>
| [
{
"answer_id": 34906,
"author": "n8henrie",
"author_id": 25201,
"author_profile": "https://vi.stackexchange.com/users/25201",
"pm_score": 2,
"selected": true,
"text": "<p>On MacOS and Linux, this seems to work in vim (but not neovim):</p>\n<pre><code>:set noshelltemp\n</code></pre>\n<p>A... | 2021/11/05 | [
"https://vi.stackexchange.com/questions/34909",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/38639/"
] | I'm searching for a command (let's say Ctrl+j) to add to my *.vimrc* to erase the last character of the line in normal mode, without changing position of the cursor. I'm beginner in this *.vimrc* language, sorry if it's too easy | On MacOS and Linux, this seems to work in vim (but not neovim):
```
:set noshelltemp
```
Afterwards this works as hoped.
```
:r ! echo -e 'foo\nbar\nbaz' | fzf -m
``` |
34,921 | <p>I have created a table of contents at the beginning of my markdown document and linked the headers of the document:</p>
<pre><code># TOC
[first header](#first-header)
# first header
</code></pre>
<p>Now, having opened the document in vim, I want to jump from the reference in the table of contents directly to the re... | [
{
"answer_id": 34922,
"author": "Parker Tailor",
"author_id": 30511,
"author_profile": "https://vi.stackexchange.com/users/30511",
"pm_score": 2,
"selected": false,
"text": "<p>I'm not aware of any built in vim functionality that works like this, but here are 2 options:</p>\n<ul>\n<li><p... | 2021/11/08 | [
"https://vi.stackexchange.com/questions/34921",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/38662/"
] | I have created a table of contents at the beginning of my markdown document and linked the headers of the document:
```
# TOC
[first header](#first-header)
# first header
```
Now, having opened the document in vim, I want to jump from the reference in the table of contents directly to the respective header. What is... | I'm not aware of any built in vim functionality that works like this, but here are 2 options:
* Use the link text to search for the heading. e.g. `vi[y/<c-r>0<cr>`
+ `vi[` visually select inner square brackets
+ `y` copy the selection
+ `/` start a search
+ `<c-r>0` to access register 0 (the most recent yank)
+ ... |
34,930 | <p>Is there a way to do a search and replace where it searches for if a line contains 4 pipes ( | ) anywhere in the line it will delete it?</p>
<p>I'm working with a big csv file and some lines have 4 pipes and some have 3 pipes. I want to separate out all the ones with 4 pipes in them into a separate file.</p>
| [
{
"answer_id": 34931,
"author": "Chris Heithoff",
"author_id": 36840,
"author_profile": "https://vi.stackexchange.com/users/36840",
"pm_score": 1,
"selected": false,
"text": "<p>I recommend using:</p>\n<pre><code>:g/regex/d\n</code></pre>\n<p>There might be better regexes, but this one w... | 2021/11/09 | [
"https://vi.stackexchange.com/questions/34930",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/6738/"
] | Is there a way to do a search and replace where it searches for if a line contains 4 pipes ( | ) anywhere in the line it will delete it?
I'm working with a big csv file and some lines have 4 pipes and some have 3 pipes. I want to separate out all the ones with 4 pipes in them into a separate file. | A regex-free one-liner which I like better than my previous answer.
```
:g/|/if count(getline('.'),'|')==4 | delete
```
On any line matching at least one pipe, then delete lines with exactly 4 pipes. |
34,933 | <p>I want to use <code><S-Tab></code> to do the reverse of <code><Tab></code> in insert mode in Lua. (If this is complicated in Lua then VimScript is OK) How?</p>
| [
{
"answer_id": 34934,
"author": "job_start",
"author_id": 10189,
"author_profile": "https://vi.stackexchange.com/users/10189",
"pm_score": 0,
"selected": false,
"text": "<pre><code>vim.api.nvim_set_keymap('i', '<S-Tab>', "v:lua.check_back_space() ? '<BS>' : '<NOP>'... | 2021/11/09 | [
"https://vi.stackexchange.com/questions/34933",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/10189/"
] | I want to use `<S-Tab>` to do the reverse of `<Tab>` in insert mode in Lua. (If this is complicated in Lua then VimScript is OK) How? | Is `<C-d>` what you want? `:h i_CTRL-D`
```
*i_CTRL-D*
CTRL-D Delete one shiftwidth of indent at the start of the current
line. The indent is always rounded to a 'shiftwidth' (this is
vi compatible).
```
If so
```
inoremap <S-Tab> <C-d>
``` |
34,936 | <p>I would like to add a dot after the first number in a line. I tried using the command below.</p>
<pre><code>:g/\v^\d/exe "norm!:s/\v(\d)/\1\./^M"
</code></pre>
<p>The command above does not work. I recorded the macro <code>@q=':s/\v\β¬kb(\d)/\1./^M'</code> that substitutes like below.</p>
<pre><code>:g/\v^\... | [
{
"answer_id": 34937,
"author": "frippe",
"author_id": 38526,
"author_profile": "https://vi.stackexchange.com/users/38526",
"pm_score": 1,
"selected": false,
"text": "<p>Alright, let me walk you through a set of steps to refine the command, starting with a slightly revised version of you... | 2021/11/09 | [
"https://vi.stackexchange.com/questions/34936",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/38687/"
] | I would like to add a dot after the first number in a line. I tried using the command below.
```
:g/\v^\d/exe "norm!:s/\v(\d)/\1\./^M"
```
The command above does not work. I recorded the macro `@q=':s/\v\β¬kb(\d)/\1./^M'` that substitutes like below.
```
:g/\v^\d/exe "norm!@q"
```
Why does the first way does not ... | The `:global` command takes a series of Ex commands to execute on the marked lines. `:substitute` is one-such, so use it directly:
```
:global/^\d/substitute/\v(\d)/\1.
```
Though as noted this (in this particular case) equivalent to
```
:%substitute/^\d/&.
``` |
34,939 | <p>Running a python script from gVim on Windows keeps popping up a terminal window (cmd), even when adding the silent parameter to the command: <code>execute 'silent !python script.py'</code>. Basically the script has no output, and I am calling it with a keymap to encrypt/decrypt some files. The terminal cmd popup is ... | [
{
"answer_id": 34943,
"author": "Heptite",
"author_id": 1311,
"author_profile": "https://vi.stackexchange.com/users/1311",
"pm_score": 0,
"selected": false,
"text": "<p>There exists more than one way to prevent the terminal window from popping up in Windows, but I find the easiest way is... | 2021/11/10 | [
"https://vi.stackexchange.com/questions/34939",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/38700/"
] | Running a python script from gVim on Windows keeps popping up a terminal window (cmd), even when adding the silent parameter to the command: `execute 'silent !python script.py'`. Basically the script has no output, and I am calling it with a keymap to encrypt/decrypt some files. The terminal cmd popup is getting annoyi... | Recent Vims can make use of the internal terminal to run external scripts. To enable this option, simply use:
```
:set guioptions+=!
```
See also the documentation [:h 'go-!'](https://vimhelp.org/options.txt.html#%27go-%21%27)
I am not sure this works in your case, but it is worth a try :) |
34,950 | <p>I am starting to have issues with my pinky finger. I tend to write variables and functions using underscores as in <code>my_variable</code>. I would like to find a way to avoid having to press "shift + -" to get the underscore. One way I thought of is by having vim transform <code>--</code> to <code>_</cod... | [
{
"answer_id": 34951,
"author": "B Layer",
"author_id": 11054,
"author_profile": "https://vi.stackexchange.com/users/11054",
"pm_score": 3,
"selected": true,
"text": "<p>Sorry about your pinky. :)</p>\n<p>You could try one of...</p>\n<pre><code>:inoremap -- _\n</code></pre>\n<p>...or...<... | 2021/11/10 | [
"https://vi.stackexchange.com/questions/34950",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1713/"
] | I am starting to have issues with my pinky finger. I tend to write variables and functions using underscores as in `my_variable`. I would like to find a way to avoid having to press "shift + -" to get the underscore. One way I thought of is by having vim transform `--` to `_` automatically as I type. How can I do that?... | Sorry about your pinky. :)
You could try one of...
```
:inoremap -- _
```
...or...
```
:iabbrev -- _
```
The difference has to do with when the substituted character appears. With mappings it's immediately. With abbreviations it's after you type a *non-keyword* character (e.g. `Space`).
Of course, if your prima... |
34,958 | <p>I have the following text in a buffer:</p>
<pre><code>Β² b
Β³ c
ΒΉ a
β°
β΄ d
</code></pre>
<p>The issue is that this is the text after running :sort (and :sort n ). My question is: why doesn't the superscripted numbers sort in the expected order, and how can I make them do so?</p>
<p>EDIT:</p>
<p>:%sort l failed for me... | [
{
"answer_id": 34959,
"author": "Karl Yngve LervΓ₯g",
"author_id": 21,
"author_profile": "https://vi.stackexchange.com/users/21",
"pm_score": 2,
"selected": false,
"text": "<p>Because the superscript numbers are <em>not</em> numbers. They are symbols. Let's assume you are using unicode, t... | 2021/11/11 | [
"https://vi.stackexchange.com/questions/34958",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/8792/"
] | I have the following text in a buffer:
```
Β² b
Β³ c
ΒΉ a
β°
β΄ d
```
The issue is that this is the text after running :sort (and :sort n ). My question is: why doesn't the superscripted numbers sort in the expected order, and how can I make them do so?
EDIT:
:%sort l failed for me as shown:
[![enter image descriptio... | You can sort these symbols properly by using collation locale sort (modifier l):
```
:%sort l
```
For this to work, you need to have language collate setting set properly, for example:
```
:language collate en_US.UTF-8
``` |
34,960 | <p>A follow up to my other question here: <a href="https://vi.stackexchange.com/q/34957/29573">Problem using gdb with vim over ssh</a></p>
<p>I was messing around trying to get my issues over ssh fixed, and I don't know what I did but now vim doesn't show any colour when I open a <code>.c</code> file I am working on</p... | [
{
"answer_id": 34961,
"author": "Maxim Kim",
"author_id": 9333,
"author_profile": "https://vi.stackexchange.com/users/9333",
"pm_score": 3,
"selected": true,
"text": "<p>First of all, most probably you don't need to reset to "factory settings".</p>\n<p>To see colors of the <cod... | 2021/11/11 | [
"https://vi.stackexchange.com/questions/34960",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/29573/"
] | A follow up to my other question here: [Problem using gdb with vim over ssh](https://vi.stackexchange.com/q/34957/29573)
I was messing around trying to get my issues over ssh fixed, and I don't know what I did but now vim doesn't show any colour when I open a `.c` file I am working on
If I just type in `vim` there is... | First of all, most probably you don't need to reset to "factory settings".
To see colors of the `c` filetype you have to either manually `:set filetype=c` or add to your vimrc a setting that will autodetect it.
After filetype was detected you should have `:syntax on` to actually turn on syntax highlighting for the de... |
34,963 | <p>I have textfiles with paths that have lost underscores between words inline in an OCR process. I want to keep the indentation and put back the underscores in the paths.</p>
<p>I have a path like this:</p>
<pre><code> /dir/file name and stuff
</code></pre>
<p>I want it to look like this:</p>
<pre><code> /dir/fi... | [
{
"answer_id": 34964,
"author": "Rasmus Groth",
"author_id": 26430,
"author_profile": "https://vi.stackexchange.com/users/26430",
"pm_score": 2,
"selected": false,
"text": "<p>I found <a href=\"https://www.reddit.com/r/vim/comments/64glrh/comment/dg252id\" rel=\"nofollow noreferrer\">thi... | 2021/11/11 | [
"https://vi.stackexchange.com/questions/34963",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/26430/"
] | I have textfiles with paths that have lost underscores between words inline in an OCR process. I want to keep the indentation and put back the underscores in the paths.
I have a path like this:
```
/dir/file name and stuff
```
I want it to look like this:
```
/dir/file_name_and_stuff
```
If I try:
```
:... | The substitution is easier to read with word-boundaries in my opinion, and very magic mode makes typing easier:
```
:%substitute/\v>\s+</_/g
``` |
34,978 | <p>I had the following piece of Markdown text that I wanted to edit:</p>
<pre><code> * 2-6 for a moka pot
* 7-10 for a drip machine
* 5-12 for a pour-over
</code></pre>
<p>When I had the cursor over the number <code>6</code> in the first bullet point, pressing <kbd>Ctrl</kbd>-<kbd>A</kbd> should β<em>Add</em> <code>[... | [
{
"answer_id": 34979,
"author": "Anthony Geoghegan",
"author_id": 1608,
"author_profile": "https://vi.stackexchange.com/users/1608",
"pm_score": 3,
"selected": false,
"text": "<p>It turns out that if a number is preceded by a <a href=\"https://en.wikipedia.org/wiki/Hyphen-minus\" rel=\"n... | 2021/11/13 | [
"https://vi.stackexchange.com/questions/34978",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1608/"
] | I had the following piece of Markdown text that I wanted to edit:
```
* 2-6 for a moka pot
* 7-10 for a drip machine
* 5-12 for a pour-over
```
When I had the cursor over the number `6` in the first bullet point, pressing `Ctrl`-`A` should β*Add* `[count]` to the number or alphabetic character at or after the cur... | Just use `set nrformats+=unsigned`. Then vim will treat all numbers as positive and ignore the hyphen. |
34,992 | <p>I want to write some mappings so I can move faster between the code. The problem is that I have hlsearch on(and i don't want it off) so I did it like this:</p>
<pre><code>au BufNewFile,BufRead *.py
nnoremap <Leader>r /return<CR>:noh<CR>
nnoremap <Leader>nf /def .*(.*):<CR>:noh&l... | [
{
"answer_id": 34993,
"author": "D. Ben Knoble",
"author_id": 10604,
"author_profile": "https://vi.stackexchange.com/users/10604",
"pm_score": 0,
"selected": false,
"text": "<p>I really like <a href=\"https://github.com/romainl/vim-cool\" rel=\"nofollow noreferrer\">vim-cool</a> for this... | 2021/11/15 | [
"https://vi.stackexchange.com/questions/34992",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/33740/"
] | I want to write some mappings so I can move faster between the code. The problem is that I have hlsearch on(and i don't want it off) so I did it like this:
```
au BufNewFile,BufRead *.py
nnoremap <Leader>r /return<CR>:noh<CR>
nnoremap <Leader>nf /def .*(.*):<CR>:noh<CR>
nnoremap <Leader>pf ?def .*(.*):<CR>... | You can perform a search without setting any highlight with the `:h search()` function.
For example, this will jump to the next occurrence of a 'return' preceded by optional space characters only:
```
nnoremap <leader>r :call search("\s*return")<cr>
``` |
35,056 | <p>I have vim-markdown and nerdtree installed. And everything was working fine until I added the following to my .vimrc (verbatim from the nerdtree readme)</p>
<pre><code>" Open the existing NERDTree on each new tab.
autocmd BufWinEnter * if getcmdwintype() == '' | silent NERDTreeMirror | endif
</code></pre>
<p>No... | [
{
"answer_id": 34993,
"author": "D. Ben Knoble",
"author_id": 10604,
"author_profile": "https://vi.stackexchange.com/users/10604",
"pm_score": 0,
"selected": false,
"text": "<p>I really like <a href=\"https://github.com/romainl/vim-cool\" rel=\"nofollow noreferrer\">vim-cool</a> for this... | 2021/11/25 | [
"https://vi.stackexchange.com/questions/35056",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/38874/"
] | I have vim-markdown and nerdtree installed. And everything was working fine until I added the following to my .vimrc (verbatim from the nerdtree readme)
```
" Open the existing NERDTree on each new tab.
autocmd BufWinEnter * if getcmdwintype() == '' | silent NERDTreeMirror | endif
```
Now everytime I run the vim-mar... | You can perform a search without setting any highlight with the `:h search()` function.
For example, this will jump to the next occurrence of a 'return' preceded by optional space characters only:
```
nnoremap <leader>r :call search("\s*return")<cr>
``` |
35,057 | <p>My <code>.vimrc</code> remaps <code>0</code> to <code>^</code> in normal and visual+search modes.</p>
<pre><code>:nmap 0 ^
:vmap 0 ^
</code></pre>
<p>Ideally, I would like <code>00</code> to go to the true beginning of the line (i.e., what <code>0</code> does by default). Is this possible in a <code>.vimrc</code>? ... | [
{
"answer_id": 34993,
"author": "D. Ben Knoble",
"author_id": 10604,
"author_profile": "https://vi.stackexchange.com/users/10604",
"pm_score": 0,
"selected": false,
"text": "<p>I really like <a href=\"https://github.com/romainl/vim-cool\" rel=\"nofollow noreferrer\">vim-cool</a> for this... | 2021/11/25 | [
"https://vi.stackexchange.com/questions/35057",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/23199/"
] | My `.vimrc` remaps `0` to `^` in normal and visual+search modes.
```
:nmap 0 ^
:vmap 0 ^
```
Ideally, I would like `00` to go to the true beginning of the line (i.e., what `0` does by default). Is this possible in a `.vimrc`? If that is not directly possible, is it possible to have `0` go to the true beginning if th... | You can perform a search without setting any highlight with the `:h search()` function.
For example, this will jump to the next occurrence of a 'return' preceded by optional space characters only:
```
nnoremap <leader>r :call search("\s*return")<cr>
``` |
35,089 | <p>I'm using <a href="https://sw.kovidgoyal.net/kitty/conf/" rel="nofollow noreferrer">kitty</a> to run terminal nvim on macOS. I want to use D- (command-key) mappings inside nvim. Because terminals, for reasons I don't understand, don't simply pass command-key chords through to the underlying nvim, this requires a wor... | [
{
"answer_id": 35090,
"author": "filbranden",
"author_id": 18609,
"author_profile": "https://vi.stackexchange.com/users/18609",
"pm_score": 3,
"selected": true,
"text": "<p>You can find out which key code is used by Vim (or NeoVim) to represent the <code><Cmd></code> sequence with:... | 2021/12/03 | [
"https://vi.stackexchange.com/questions/35089",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/13151/"
] | I'm using [kitty](https://sw.kovidgoyal.net/kitty/conf/) to run terminal nvim on macOS. I want to use D- (command-key) mappings inside nvim. Because terminals, for reasons I don't understand, don't simply pass command-key chords through to the underlying nvim, this requires a workaround. This is what I currently use in... | You can find out which key code is used by Vim (or NeoVim) to represent the `<Cmd>` sequence with:
```
:echo "\<Cmd>"
```
From my own experimentation, it seems that this produces `<80><fd>g` in Vim and `<80><fd>h` in NeoVim, where the `<80>` and `<fd>` are hexadecimal codes representing keys in the upper half of the... |
35,091 | <p>Got this function:</p>
<pre><code>function! TaskAnnotateWithFile()
let uuid = GetUUID()
:!task
echo uuid . ' '
annotate -- ~/
endfunction
</code></pre>
<p>The idea here is a I want to prefill the command line with something like this:</p>
<p><code>:task 693614b6-0141-4e22-93cd-ebc37ef47d55 annotate ... | [
{
"answer_id": 35092,
"author": "B Layer",
"author_id": 11054,
"author_profile": "https://vi.stackexchange.com/users/11054",
"pm_score": 3,
"selected": true,
"text": "<p>If you want to trigger this with a mapping then there's really no need for the function. Everything can happen in the ... | 2021/12/03 | [
"https://vi.stackexchange.com/questions/35091",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/2021/"
] | Got this function:
```
function! TaskAnnotateWithFile()
let uuid = GetUUID()
:!task
echo uuid . ' '
annotate -- ~/
endfunction
```
The idea here is a I want to prefill the command line with something like this:
`:task 693614b6-0141-4e22-93cd-ebc37ef47d55 annotate -- ~/`
I then want to be able to t... | If you want to trigger this with a mapping then there's really no need for the function. Everything can happen in the mapping without much trouble.
There are a couple ways to approach this.\* I just happened to be using the [`c_CTRL-\_e`](https://vimhelp.org/cmdline.txt.html#c_CTRL-%5C_e) command-line editing feature ... |
35,101 | <p>I've got this in my vim buffer:</p>
<pre><code>* [ ] set up adding asterisk or changing color automatically when a task is annotated ==ANN== #9f359cd0
* [ ] write documentation in ## Notes section #7226ec9c
</code></pre>
<p>I want to highlight the first line with the ==ANN== in red. So I have this:</p>
<pre><code>... | [
{
"answer_id": 35102,
"author": "StevieD",
"author_id": 2021,
"author_profile": "https://vi.stackexchange.com/users/2021",
"pm_score": 1,
"selected": false,
"text": "<p>Got it figured out. Went with this, no need for the <code>contains</code>:</p>\n<pre><code>syntax region Annotation sta... | 2021/12/05 | [
"https://vi.stackexchange.com/questions/35101",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/2021/"
] | I've got this in my vim buffer:
```
* [ ] set up adding asterisk or changing color automatically when a task is annotated ==ANN== #9f359cd0
* [ ] write documentation in ## Notes section #7226ec9c
```
I want to highlight the first line with the ==ANN== in red. So I have this:
```
syntax region Annotation start=/==... | I can see you've already come up with a solution for your problem, but for the benefit of posterity, I thought I'd explain what was wrong with your original code, which is that you're mistaken about what `contains` does.
`contains=Annotation` *doesn't* mean that `TaskWithAnn` will only match regions that contain an `A... |
35,116 | <p>I have a location list populated with around 50 lines, and I would like to remove some of these. Is there a way?</p>
<p>Specifically, I searched for references of a Java method and the LSP (using coc-java) filled the references, but most are to test classes, which do not interest me at the moment.</p>
| [
{
"answer_id": 35117,
"author": "Matt",
"author_id": 22797,
"author_profile": "https://vi.stackexchange.com/users/22797",
"pm_score": 2,
"selected": false,
"text": "<p>There's no builtin command, so you need to do a bit of scripting. Sort of this</p>\n<pre><code>:call getloclist(0)->f... | 2021/12/06 | [
"https://vi.stackexchange.com/questions/35116",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/30280/"
] | I have a location list populated with around 50 lines, and I would like to remove some of these. Is there a way?
Specifically, I searched for references of a Java method and the LSP (using coc-java) filled the references, but most are to test classes, which do not interest me at the moment. | There's no builtin command, so you need to do a bit of scripting. Sort of this
```
:call getloclist(0)->filter('v:val.text !~? "test"')->setloclist(0)
```
Alternatively, you may want to search through github for relevant plugins, e.g. [github.com/search topic:vim topic:quickfix](https://github.com/search?q=topic%3Av... |
35,121 | <p>I've got this simple function:</p>
<pre><code>" generates a link in markdown using an extern script
function! WebLink()
put =system('~/bin/taskwiki_helper.pl markdown_link_from_url')
endfunction
</code></pre>
<p>It works but inserts a blank line before inserting the text into the buffer. <code>:h put</code>... | [
{
"answer_id": 35123,
"author": "mattb",
"author_id": 31858,
"author_profile": "https://vi.stackexchange.com/users/31858",
"pm_score": 3,
"selected": true,
"text": "<p>Maybe this:</p>\n<pre><code>call setline('.', system('~/bin/taskwiki_helper.pl markdown_link_from_url'))\n</code></pre>\... | 2021/12/07 | [
"https://vi.stackexchange.com/questions/35121",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/2021/"
] | I've got this simple function:
```
" generates a link in markdown using an extern script
function! WebLink()
put =system('~/bin/taskwiki_helper.pl markdown_link_from_url')
endfunction
```
It works but inserts a blank line before inserting the text into the buffer. `:h put` didn't seem to offer any useful info on... | Maybe this:
```
call setline('.', system('~/bin/taskwiki_helper.pl markdown_link_from_url'))
```
#### Edit
See caveats in the comments from @filbranden and also check out their answer! |
35,124 | <p>I would like to either find or write a plugin that does the following:</p>
<p>Assume I have this python code:</p>
<pre><code>def foo(a,b,c):
# comment
[100 lines that do stuff]
for i in range(N):
[100 lines that do stuff]
# another comment
--> more code
</code></pre>
<p>Let's assum... | [
{
"answer_id": 35125,
"author": "D. Ben Knoble",
"author_id": 10604,
"author_profile": "https://vi.stackexchange.com/users/10604",
"pm_score": 2,
"selected": false,
"text": "<p>I <em>think</em> I've heard of a plugin that does this, but I cannot recall it's name. When I need this I do on... | 2021/12/07 | [
"https://vi.stackexchange.com/questions/35124",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/23754/"
] | I would like to either find or write a plugin that does the following:
Assume I have this python code:
```
def foo(a,b,c):
# comment
[100 lines that do stuff]
for i in range(N):
[100 lines that do stuff]
# another comment
--> more code
```
Let's assume this does not vertically fit in... | There's plug-in [wellle/context.vim](https://github.com/wellle/context.vim) which seems to implement what you requested. (Perhaps it's the one D. Ben Knoble was trying to recall?)
It will try to show context (`if`, `for` or `while` block, function/class definitions, cases within a `switch` command, etc.) for the line ... |
35,131 | <p>I am on windows natively with neovim-qt .</p>
<p>I tried to use <code>%!python -m json.tool</code> on a valid json file .
It says <code>Expecting value: line 1 column 1 (char 0)</code> .
In powershell : <code>cat .\graphs.json | python -m json.tool</code> worked.</p>
<p><code>%!python -c "import sys;print(sys.s... | [
{
"answer_id": 37367,
"author": "eyal karni",
"author_id": 18375,
"author_profile": "https://vi.stackexchange.com/users/18375",
"pm_score": 0,
"selected": false,
"text": "<p>It is a bit of a sad solution. After applying the powershell script, the following would Filter through and add th... | 2021/12/07 | [
"https://vi.stackexchange.com/questions/35131",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/18375/"
] | I am on windows natively with neovim-qt .
I tried to use `%!python -m json.tool` on a valid json file .
It says `Expecting value: line 1 column 1 (char 0)` .
In powershell : `cat .\graphs.json | python -m json.tool` worked.
`%!python -c "import sys;print(sys.stdin.read())"`
return nothing
meaning, shell handing is p... | Your question is confusing. You talk about powershell not working with `json.tool`, but then you say your shell is set to `cmd.exe`. With cmd, you should have no problem working with `:%!` (I checked just now; it works). But with powershell/pwsh, there is a bug in both vim and neovim. I have a [PR open](https://github.... |
35,132 | <p>I want to use <code>!</code> with powershell. I use neovim natively on windows.</p>
<p>I tried these settings</p>
<pre><code>set shell=powershell.exe
set shellcmdflag=-NoProfile\ -NoLogo\ -NonInteractive\ -Command
set shellpipe=|
set shellredir=>
</code></pre>
<p>as suggested here <a href="https://robindouglas.uk... | [
{
"answer_id": 35133,
"author": "eyal karni",
"author_id": 18375,
"author_profile": "https://vi.stackexchange.com/users/18375",
"pm_score": 2,
"selected": true,
"text": "<p>OK, I didn't notice it . There is actually in help <code>shell-powershell</code></p>\n<p>The settings are</p>\n<pre... | 2021/12/07 | [
"https://vi.stackexchange.com/questions/35132",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/18375/"
] | I want to use `!` with powershell. I use neovim natively on windows.
I tried these settings
```
set shell=powershell.exe
set shellcmdflag=-NoProfile\ -NoLogo\ -NonInteractive\ -Command
set shellpipe=|
set shellredir=>
```
as suggested here <https://robindouglas.uk/powershell/vim/2018/04/05/PowerShell-with-Vim.html>... | OK, I didn't notice it . There is actually in help `shell-powershell`
The settings are
```
let &shell = has('win32') ? 'powershell' : 'pwsh'
let &shellcmdflag = '-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.Encoding]::UTF8;'
... |
35,169 | <p>Without <code>-complete=file</code>:</p>
<pre><code>command! -nargs=* C1 echo <q-args>
C1 fzf#vim#grep /home/yuri/.vim/pack/foo/start/fzf.vim
" fzf#vim#grep /home/yuri/.vim/pack/foo/start/fzf.vim
</code></pre>
<p>With <code>-complete=file</code>:</p>
<pre><code>command! -nargs=* -complete=file C1 echo <... | [
{
"answer_id": 35133,
"author": "eyal karni",
"author_id": 18375,
"author_profile": "https://vi.stackexchange.com/users/18375",
"pm_score": 2,
"selected": true,
"text": "<p>OK, I didn't notice it . There is actually in help <code>shell-powershell</code></p>\n<p>The settings are</p>\n<pre... | 2021/12/10 | [
"https://vi.stackexchange.com/questions/35169",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1553/"
] | Without `-complete=file`:
```
command! -nargs=* C1 echo <q-args>
C1 fzf#vim#grep /home/yuri/.vim/pack/foo/start/fzf.vim
" fzf#vim#grep /home/yuri/.vim/pack/foo/start/fzf.vim
```
With `-complete=file`:
```
command! -nargs=* -complete=file C1 echo <q-args>
C1 fzf#vim#grep /home/yuri/.vim/pack/foo/start/fzf.vim
" fzf/... | OK, I didn't notice it . There is actually in help `shell-powershell`
The settings are
```
let &shell = has('win32') ? 'powershell' : 'pwsh'
let &shellcmdflag = '-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.Encoding]::UTF8;'
... |
35,184 | <p>All,</p>
<p>I am pretty new to <strong>NeoVim</strong> or <strong>Vim</strong> and i have setup vim for <strong>scala development</strong>. Everything else seems to be working fine. The only hiccup i have is i am not able to navigate to a file or function.</p>
<p>Is there a <em><strong>plugin</strong></em> for vim o... | [
{
"answer_id": 35133,
"author": "eyal karni",
"author_id": 18375,
"author_profile": "https://vi.stackexchange.com/users/18375",
"pm_score": 2,
"selected": true,
"text": "<p>OK, I didn't notice it . There is actually in help <code>shell-powershell</code></p>\n<p>The settings are</p>\n<pre... | 2021/12/13 | [
"https://vi.stackexchange.com/questions/35184",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/39086/"
] | All,
I am pretty new to **NeoVim** or **Vim** and i have setup vim for **scala development**. Everything else seems to be working fine. The only hiccup i have is i am not able to navigate to a file or function.
Is there a ***plugin*** for vim or neovim that i can use to make the navigation simpler.
*ps: I have tried... | OK, I didn't notice it . There is actually in help `shell-powershell`
The settings are
```
let &shell = has('win32') ? 'powershell' : 'pwsh'
let &shellcmdflag = '-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.Encoding]::UTF8;'
... |
35,186 | <p>I have several lines that look like the following:</p>
<pre><code>"Timestamp": 200,
"Timestamp": 1200,
"Timestamp": 3100,
</code></pre>
<p>I want to replace all the numbers, starting at 10 and incrementing by 10's so it looks like this:</p>
<pre><code>"Timestamp": 10,
"Ti... | [
{
"answer_id": 35187,
"author": "Maxim Kim",
"author_id": 9333,
"author_profile": "https://vi.stackexchange.com/users/9333",
"pm_score": 2,
"selected": false,
"text": "<p>I am not sure if you are looking for pure <code>:%s///</code> solution or not.</p>\n<p>I would approach this with <co... | 2021/12/13 | [
"https://vi.stackexchange.com/questions/35186",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/39088/"
] | I have several lines that look like the following:
```
"Timestamp": 200,
"Timestamp": 1200,
"Timestamp": 3100,
```
I want to replace all the numbers, starting at 10 and incrementing by 10's so it looks like this:
```
"Timestamp": 10,
"Timestamp": 20,
"Timestamp": 30,
``` | I am not sure if you are looking for pure `:%s///` solution or not.
I would approach this with `10` + `g` + `<C-a>`:
1. replace all numbers with `0`: `:%s/\d\+,/0,`
2. select all zeroes and increment them by 10: `10g<C-a>`
[](https://i.stack.imgur.c... |
36,217 | <p>Been using Vim for a few weeks now and I find myself constantly using <code>ci"</code> or <code>ci(</code> to change whats enclosed in <code>""</code> or <code>()</code>. I do also find myself wanting to append inside of the brackets e.g.:</p>
<p>If I have:</p>
<pre><code>if (name == "Frank"... | [
{
"answer_id": 36220,
"author": "mattb",
"author_id": 31858,
"author_profile": "https://vi.stackexchange.com/users/31858",
"pm_score": 3,
"selected": true,
"text": "<p>There's not a command that follows the <code>ci...</code> structure to do that. You can\nadd a remap to do it (see below... | 2021/12/17 | [
"https://vi.stackexchange.com/questions/36217",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/38923/"
] | Been using Vim for a few weeks now and I find myself constantly using `ci"` or `ci(` to change whats enclosed in `""` or `()`. I do also find myself wanting to append inside of the brackets e.g.:
If I have:
```
if (name == "Frank") {
```
I want to be anywhere on that line and append `&& lastName == "Castle"` to my... | There's not a command that follows the `ci...` structure to do that. You can
add a remap to do it (see below), or use core vim commands `f` and `t` (and
their counterparts `F` and `T`) motions to get the cursor to where you want,
and then switch to insert mode (with `i` or `a`) to effect the change (see even
further be... |
36,227 | <p>When I select a range visually and run this command:</p>
<p><code>:'<,'>s/\(.*\)\s\+#.*$/\1/g</code></p>
<p>It removes the text at the end of <strong>each line</strong> that starts with <code>#</code> which is what I want.</p>
<p>I want to run a vim function that does the same on the text in a register to clea... | [
{
"answer_id": 36219,
"author": "user1068352",
"author_id": 34608,
"author_profile": "https://vi.stackexchange.com/users/34608",
"pm_score": 3,
"selected": false,
"text": "<p>By default Vim replaces only first occurrence. You should add <code>g</code> to you substitution: <code>:s/X/Y/cg... | 2021/12/18 | [
"https://vi.stackexchange.com/questions/36227",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/2021/"
] | When I select a range visually and run this command:
`:'<,'>s/\(.*\)\s\+#.*$/\1/g`
It removes the text at the end of **each line** that starts with `#` which is what I want.
I want to run a vim function that does the same on the text in a register to clean it up the text:
```
function! PasteTasksClean()
let tas... | By default Vim replaces only first occurrence. You should add `g` to you substitution: `:s/X/Y/cg`.
Vim will then let you change each X one by one (confirming with `y`) or all at once (confirming with `a`). |
36,233 | <p>How can I sort by frequency without deleting any?</p>
<pre><code>one
two
one
</code></pre>
<p>to</p>
<pre><code>one
one
two
</code></pre>
<p>The output of the standard sort-by-frequency <code>:%!sort | uniq -c | sort -nr</code> is</p>
<pre><code> 2 one
1 two
</code></pre>
<p>It has deleted all the copies of the... | [
{
"answer_id": 36219,
"author": "user1068352",
"author_id": 34608,
"author_profile": "https://vi.stackexchange.com/users/34608",
"pm_score": 3,
"selected": false,
"text": "<p>By default Vim replaces only first occurrence. You should add <code>g</code> to you substitution: <code>:s/X/Y/cg... | 2021/12/19 | [
"https://vi.stackexchange.com/questions/36233",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/9024/"
] | How can I sort by frequency without deleting any?
```
one
two
one
```
to
```
one
one
two
```
The output of the standard sort-by-frequency `:%!sort | uniq -c | sort -nr` is
```
2 one
1 two
```
It has deleted all the copies of the line (bc of `uniq`), and the spaces and numbers are not desired in the outpu... | By default Vim replaces only first occurrence. You should add `g` to you substitution: `:s/X/Y/cg`.
Vim will then let you change each X one by one (confirming with `y`) or all at once (confirming with `a`). |
36,243 | <p>I've created a mapping to a function that accepts a range. Like this:</p>
<pre><code>command! -range Test call TestFunc(<range>,<line1>,<line2>)
nnoremap <leader>t :Test<CR>
</code></pre>
<p>How do I supply a specific range to the mapped command, in normal mode?</p>
<p>For example: from... | [
{
"answer_id": 36244,
"author": "filbranden",
"author_id": 18609,
"author_profile": "https://vi.stackexchange.com/users/18609",
"pm_score": 2,
"selected": false,
"text": "<p>There are typically two ways to pass a range to a Normal-mode command.</p>\n<p>One is to use a Visual selection (w... | 2021/12/20 | [
"https://vi.stackexchange.com/questions/36243",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/31937/"
] | I've created a mapping to a function that accepts a range. Like this:
```
command! -range Test call TestFunc(<range>,<line1>,<line2>)
nnoremap <leader>t :Test<CR>
```
How do I supply a specific range to the mapped command, in normal mode?
For example: from current line to line 81, apply mapped command `t`. Somethin... | There are typically two ways to pass a range to a Normal-mode command.
One is to use a Visual selection (which is not exactly a Normal-mode command, but a Visual-mode one, but still pretty close) and the other is to create a mapping that takes an operator and acts on the range resulting of the operator or motions that... |
36,260 | <p>I often do <code>ver_w</code> some times to change words into blanks. I am making quiz this way. What I noticed is that this is a bit of a pain. The amount of work is not so heavy as to make it a macro, but cannot be repeated by the <code>.</code> command.<br>
Do you come up with an easier way to do this?</p>
<p>
Ex... | [
{
"answer_id": 36272,
"author": "Maxim Kim",
"author_id": 9333,
"author_profile": "https://vi.stackexchange.com/users/9333",
"pm_score": 0,
"selected": false,
"text": "<p>Indeed <code>.</code> repeats last change that is bound to the visual selection you have used last time (4 chars for ... | 2021/12/22 | [
"https://vi.stackexchange.com/questions/36260",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/39060/"
] | I often do `ver_w` some times to change words into blanks. I am making quiz this way. What I noticed is that this is a bit of a pain. The amount of work is not so heavy as to make it a macro, but cannot be repeated by the `.` command.
Do you come up with an easier way to do this?
Example
I *make it a rule* never... | I pondered upon this question for quite a bit. Using macros would be the most straightforward way to set this up quickly, but you explicitly called out you find this βnot so heavy as to make it a macro.β
You mentioned something that could be repeated by the `.` command, so I thought of a mapping using [operator-pendin... |
36,284 | <p>I'm using <code>Neovim 0.6.0</code> with <a href="https://github.com/navarasu/onedark.nvim" rel="nofollow noreferrer">nvim-treesitter</a> installed and I mostly work with JavaScript, Flow, TypeScript based React projects. This means, I also need syntax highlighting for JSX and TSX.</p>
<p>Syntax highlighting works r... | [
{
"answer_id": 36272,
"author": "Maxim Kim",
"author_id": 9333,
"author_profile": "https://vi.stackexchange.com/users/9333",
"pm_score": 0,
"selected": false,
"text": "<p>Indeed <code>.</code> repeats last change that is bound to the visual selection you have used last time (4 chars for ... | 2021/12/23 | [
"https://vi.stackexchange.com/questions/36284",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/40234/"
] | I'm using `Neovim 0.6.0` with [nvim-treesitter](https://github.com/navarasu/onedark.nvim) installed and I mostly work with JavaScript, Flow, TypeScript based React projects. This means, I also need syntax highlighting for JSX and TSX.
Syntax highlighting works rather well with TypeScript and TSX out of the box, howeve... | I pondered upon this question for quite a bit. Using macros would be the most straightforward way to set this up quickly, but you explicitly called out you find this βnot so heavy as to make it a macro.β
You mentioned something that could be repeated by the `.` command, so I thought of a mapping using [operator-pendin... |
36,289 | <p>When I edit some code, I have a repl aside which gives me useless imports/includes, and I'd like to remove them in one command.</p>
<p>To be concrete, I have the following text:</p>
<pre><code>import A
import B
import C
import D
import E
import F
import G
</code></pre>
<p>And I would like to remove lines 1, 3, 4, an... | [
{
"answer_id": 36290,
"author": "Heptite",
"author_id": 1311,
"author_profile": "https://vi.stackexchange.com/users/1311",
"pm_score": 3,
"selected": true,
"text": "<p>I came up with this:</p>\n<pre><code>:for i in reverse([1, 3, 4, 7]) | exe i . 'delete' | endfor\n</code></pre>\n<p>This... | 2021/12/23 | [
"https://vi.stackexchange.com/questions/36289",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/32062/"
] | When I edit some code, I have a repl aside which gives me useless imports/includes, and I'd like to remove them in one command.
To be concrete, I have the following text:
```
import A
import B
import C
import D
import E
import F
import G
```
And I would like to remove lines 1, 3, 4, and 7.
I have tried `:1,3,4,7` ... | I came up with this:
```
:for i in reverse([1, 3, 4, 7]) | exe i . 'delete' | endfor
```
This could easily be put into a function that could be called:
```
function DeleteLines(lines)
let lines = reverse(uniq(sort(a:lines, 'n')))
for i in lines
if i > line('$')
echohl WarningMsg
... |
36,307 | <p>I want to use a feature included in Patch 7.4.1154.</p>
<p>From <a href="https://github.com/vim/vim-history" rel="nofollow noreferrer">vim-history</a>, I see releases:</p>
<ul>
<li>v8.0 - 12 September, 2016</li>
<li>v7.4 - 10 August, 2013</li>
</ul>
<p>There's a few years between them.</p>
<p>How do I find the relea... | [
{
"answer_id": 36308,
"author": "Mass",
"author_id": 13728,
"author_profile": "https://vi.stackexchange.com/users/13728",
"pm_score": 3,
"selected": true,
"text": "<p>Conventionally, Bram tags every numbered patch of vim with a tag of the form <code>v{patch_num}</code>.</p>\n<p>If you ha... | 2021/12/26 | [
"https://vi.stackexchange.com/questions/36307",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/5324/"
] | I want to use a feature included in Patch 7.4.1154.
From [vim-history](https://github.com/vim/vim-history), I see releases:
* v8.0 - 12 September, 2016
* v7.4 - 10 August, 2013
There's a few years between them.
How do I find the release date of Patch 7.4.1154 itself? | Conventionally, Bram tags every numbered patch of vim with a tag of the form `v{patch_num}`.
If you have access to a local clone of the vim repository (<https://github.com/vim/vim>), the release date can be found using `git show`:
```
VER=7.4.1154
git show --no-patch --no-notes --pretty='%cd' v${VER}
Sat Jan 23 19:4... |
36,311 | <p>I'm separating the functions from <code>main.c</code> to <code>func1.c</code> <code>func2.c</code>, then I'm using <code>util.h</code> to store the prototype (all name of all functions).</p>
<h2>PROBLEM</h2>
<p>when I try to go to implementation, lsp leading me into <code>util.c</code>, but i want to leading to <cod... | [
{
"answer_id": 37992,
"author": "Rintse van de Vlasakker",
"author_id": 42810,
"author_profile": "https://vi.stackexchange.com/users/42810",
"pm_score": 2,
"selected": true,
"text": "<p>The location of the implementation depends on the way the project is built. You can tell <code>clangd<... | 2021/12/26 | [
"https://vi.stackexchange.com/questions/36311",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/33304/"
] | I'm separating the functions from `main.c` to `func1.c` `func2.c`, then I'm using `util.h` to store the prototype (all name of all functions).
PROBLEM
-------
when I try to go to implementation, lsp leading me into `util.c`, but i want to leading to `func1.c`
#### main.c
```c
#include "util.h"
int main(){
int x ... | The location of the implementation depends on the way the project is built. You can tell `clangd` about this using [`compile_commands.json`](https://clang.llvm.org/docs/JSONCompilationDatabase.html).
You can generate this file using [bear](https://github.com/rizsotto/Bear): `bear -- make`.
Bear is probably available ... |
36,326 | <p>As title. Since no one wants to become a turtle, I want to setup a behavior like <code>M</code> but instead pin the current line to 80% height (0% start from bottom) of the current window, not to center.</p>
| [
{
"answer_id": 36327,
"author": "job_start",
"author_id": 10189,
"author_profile": "https://vi.stackexchange.com/users/10189",
"pm_score": 0,
"selected": false,
"text": "<h2>Update</h2>\n<p>Since I don't like scrolloff, I update to this new version:</p>\n<pre><code>vim.api.nvim_set_keyma... | 2021/12/28 | [
"https://vi.stackexchange.com/questions/36326",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/10189/"
] | As title. Since no one wants to become a turtle, I want to setup a behavior like `M` but instead pin the current line to 80% height (0% start from bottom) of the current window, not to center. | `:h H` accepts a count, so you can do something like this:
```
exe "normal " .. winheight(0) * 80 / 100 .. "H"
```
which translates to `XH` where `X` is a number. |
36,401 | <p>I have a CSV filled with text messages, and I want to be able to easily filter by sender/receiver. The last field indicates "SMS", "iMessage" or "WhatsApp"; the previous fields may spill over multiple lines.</p>
<p>E.g: "Sent","Aug 4, 2021 12:34:56","Some Person... | [
{
"answer_id": 36438,
"author": "eyal karni",
"author_id": 18375,
"author_profile": "https://vi.stackexchange.com/users/18375",
"pm_score": 2,
"selected": false,
"text": "<p>OK, lets do tricks.\nSuppose you don't have the word NEWLINE on your file.\nThen:</p>\n<pre><code>:%s/\\n/NEWLINE/... | 2022/01/06 | [
"https://vi.stackexchange.com/questions/36401",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/158/"
] | I have a CSV filled with text messages, and I want to be able to easily filter by sender/receiver. The last field indicates "SMS", "iMessage" or "WhatsApp"; the previous fields may spill over multiple lines.
E.g: "Sent","Aug 4, 2021 12:34:56","Some Person","+11234567890","Hello!","SMS"
So I can easily `:g/.*Some Pers... | Match starting line by global. Then by range until the closing pattern.
```
g/"Some person"/,/"\(SMS\|iMessage\|WhatsApp\)"/p
```
Upd. If full match can consist of a single line only then we have to use a little longer construction. For example,
```
g/"Some person"/exe search('\v"(SMS|iMessage|WhatsApp)"', 'n')->pr... |
36,411 | <p>I am using this in my vimrc, to get output of current script printed on the screen when I click enter.</p>
<pre><code>autocmd FileType python map <buffer> <CR> :w<CR>:!python3 %<CR>
</code></pre>
<p>How can I get it to open in a new buffer where I can edit the output?</p>
| [
{
"answer_id": 36413,
"author": "eyal karni",
"author_id": 18375,
"author_profile": "https://vi.stackexchange.com/users/18375",
"pm_score": 1,
"selected": false,
"text": "<p>You may run</p>\n<pre><code>autocmd FileType python map <buffer> <CR> :w<CR>:call Exec('!python3... | 2022/01/06 | [
"https://vi.stackexchange.com/questions/36411",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/34006/"
] | I am using this in my vimrc, to get output of current script printed on the screen when I click enter.
```
autocmd FileType python map <buffer> <CR> :w<CR>:!python3 %<CR>
```
How can I get it to open in a new buffer where I can edit the output? | Use a `:terminal`:
```
" in ~/.vim/after/ftplugin/python.vim
nnoremap <buffer> <CR> :write <bar> terminal python3 %<CR>
" update b:undo_ftplugin
```
When the command is finished, you can `:set modifiable` (`:set ma`) and edit. |
36,412 | <p>I've been using vim for about 3 years and am starting to write <a href="https://github.com/Matt-A-Bennett/surround-funk.vim" rel="nofollow noreferrer">my first
plugin</a>. I've noticed when
looking at the code of other popular plugins that the functions very rarely
seem to achieve their aim with lines like:</p>
<pre... | [
{
"answer_id": 36433,
"author": "Ari Sweedler",
"author_id": 14861,
"author_profile": "https://vi.stackexchange.com/users/14861",
"pm_score": 1,
"selected": false,
"text": "<p>Not an answer, but I think you'll appreciate it.</p>\n<pre><code>let saved_pos = getcurpos()\ncall search('mysea... | 2022/01/06 | [
"https://vi.stackexchange.com/questions/36412",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/31858/"
] | I've been using vim for about 3 years and am starting to write [my first
plugin](https://github.com/Matt-A-Bennett/surround-funk.vim). I've noticed when
looking at the code of other popular plugins that the functions very rarely
seem to achieve their aim with lines like:
```
execute "normal! <some commands>"
```
Ins... | In no particular order.
1. **Readability** Any sequence of normals, except a very short one, is nearly impossible to read and understand. Vimgolf can't lie.
2. **Clobbering registers etc.** Quite often there is more things to change than one can even remember of. For example, your code sets at least four(!) registers ... |
36,416 | <p>The problem I wish to solve, first of all, is when you want do do the same editing on multiple lines, but they are not aligned so you can't use <code>Ctrl + V</code>, maybe the lines are not even adjacent. In these cases I tend to use <code>q</code> to record, and then I reproduce with <code>@</code>, but I would li... | [
{
"answer_id": 36418,
"author": "filbranden",
"author_id": 18609,
"author_profile": "https://vi.stackexchange.com/users/18609",
"pm_score": 1,
"selected": true,
"text": "<p>You could accomplish that with a mapping that stores the count (for example, in a buffer-local, script-local or eve... | 2022/01/07 | [
"https://vi.stackexchange.com/questions/36416",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/40403/"
] | The problem I wish to solve, first of all, is when you want do do the same editing on multiple lines, but they are not aligned so you can't use `Ctrl + V`, maybe the lines are not even adjacent. In these cases I tend to use `q` to record, and then I reproduce with `@`, but I would like to know if I can do both at the s... | You could accomplish that with a mapping that stores the count (for example, in a buffer-local, script-local or even global variable) and start recording a macro (say `qa`), and then a second mapping for `]` that stops recording the macro and executes it the number of times passed as the count (minus one, since the rec... |
36,426 | <p>I've got the problem that the neovim language is set to German for some reason even though I only use a German keyboard layout (<a href="https://vi.stackexchange.com/questions/14429/why-is-my-neovim-not-in-english-and-how-do-i-force-it-to-be">see this question</a>). Unfortunately I am using lua for configuring neovi... | [
{
"answer_id": 36418,
"author": "filbranden",
"author_id": 18609,
"author_profile": "https://vi.stackexchange.com/users/18609",
"pm_score": 1,
"selected": true,
"text": "<p>You could accomplish that with a mapping that stores the count (for example, in a buffer-local, script-local or eve... | 2022/01/07 | [
"https://vi.stackexchange.com/questions/36426",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/40419/"
] | I've got the problem that the neovim language is set to German for some reason even though I only use a German keyboard layout ([see this question](https://vi.stackexchange.com/questions/14429/why-is-my-neovim-not-in-english-and-how-do-i-force-it-to-be)). Unfortunately I am using lua for configuring neovim (the linked ... | You could accomplish that with a mapping that stores the count (for example, in a buffer-local, script-local or even global variable) and start recording a macro (say `qa`), and then a second mapping for `]` that stops recording the macro and executes it the number of times passed as the count (minus one, since the rec... |
36,435 | <p>I know the title should have been "God can you share all the knowledge in the Universe please ?"</p>
<p>But anyway it doesn't hurt if I ask...</p>
<p>Is there any compiled complete list of all VIM commands ? I want this by some reasons:</p>
<ul>
<li>I would like to know how little do I know about VIM</li>
... | [
{
"answer_id": 36437,
"author": "mattb",
"author_id": 31858,
"author_profile": "https://vi.stackexchange.com/users/31858",
"pm_score": 3,
"selected": true,
"text": "<h3>For all the gory details</h3>\n<p>From <code>:help index</code>:</p>\n<blockquote>\n<p>This file contains a list of all... | 2022/01/07 | [
"https://vi.stackexchange.com/questions/36435",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/5944/"
] | I know the title should have been "God can you share all the knowledge in the Universe please ?"
But anyway it doesn't hurt if I ask...
Is there any compiled complete list of all VIM commands ? I want this by some reasons:
* I would like to know how little do I know about VIM
* I would like to groups commands I woul... | ### For all the gory details
From `:help index`:
>
> This file contains a list of all commands for each mode, with a tag and a
> short description. The lists are sorted on ASCII value.
>
>
>
From `:help function-list`:
>
> There are many functions. We will mention them here, grouped by what they
> are used for... |
36,449 | <p>Is there a command to exit insert mode and perform <code>:w</code> or <code>:wq</code> in the same command?</p>
<p>I am tired of pressing <code>esc + :w</code> every time I need to write to a file after making edits.</p>
<p>Alternatively, is there an autosave function?</p>
| [
{
"answer_id": 36451,
"author": "Matt",
"author_id": 22797,
"author_profile": "https://vi.stackexchange.com/users/22797",
"pm_score": 3,
"selected": false,
"text": "<p>It is pretty straightforward to create a mapping, e.g.</p>\n<pre><code>inoremap <C-S> <cmd>update<CR>\... | 2022/01/09 | [
"https://vi.stackexchange.com/questions/36449",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/40446/"
] | Is there a command to exit insert mode and perform `:w` or `:wq` in the same command?
I am tired of pressing `esc + :w` every time I need to write to a file after making edits.
Alternatively, is there an autosave function? | It is pretty straightforward to create a mapping, e.g.
```
inoremap <C-S> <cmd>update<CR>
```
But the point is that you shouldn't stay in Insert mode for too long. That is, always press "esc" immediately after you've finished typing. Use "J", "d", "o", "<<" and other Normal mode keys to reduce the time spent in Inse... |
36,454 | <p>I want vim to launch rails console(it's like relp) within terminal windows when vim is launched on my project directory.
To launch rails console, I need to run three commands like below and it's tedious.</p>
<pre><code>vagrant up # launch virtual server.
ssh xxxx@example.hoge # ssh into virtual server
cd xxxx/xxxx/... | [
{
"answer_id": 36456,
"author": "user1692121",
"author_id": 30531,
"author_profile": "https://vi.stackexchange.com/users/30531",
"pm_score": 0,
"selected": false,
"text": "<p>I can work around this problem like this.</p>\n<pre><code>vsplit | term | close\n</code></pre>\n"
},
{
"a... | 2022/01/10 | [
"https://vi.stackexchange.com/questions/36454",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/30531/"
] | I want vim to launch rails console(it's like relp) within terminal windows when vim is launched on my project directory.
To launch rails console, I need to run three commands like below and it's tedious.
```
vagrant up # launch virtual server.
ssh xxxx@example.hoge # ssh into virtual server
cd xxxx/xxxx/ && bundle ex... | See the function `term_start()`; it creates a terminal window, which you can then `:hide`. Or, pass the `hidden` option to `term_start()`.
I suppose `:terminal` followed by `:hide` also works. `:vsplit` should not be necessary, as `:terminal` creates its own windows. If you want to avoid messing with the layout of the... |
36,457 | <p>As title. Is it possible to change the current buffer by vimscript to the (only) <code>[No Name]</code> buffer?</p>
<p>I need these tools:</p>
<ul>
<li>an API to return all (loaded) buffers</li>
<li>loop through each of them
<ul>
<li>if the buffer is a <code>No Name</code>-buffer, then record its buffer number</li>
... | [
{
"answer_id": 36459,
"author": "Matt",
"author_id": 22797,
"author_profile": "https://vi.stackexchange.com/users/22797",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n<p>an API to return all (loaded) buffers</p>\n</blockquote>\n<p><code>:h getbufinfo()</code></p>\n<blockquote... | 2022/01/10 | [
"https://vi.stackexchange.com/questions/36457",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/10189/"
] | As title. Is it possible to change the current buffer by vimscript to the (only) `[No Name]` buffer?
I need these tools:
* an API to return all (loaded) buffers
* loop through each of them
+ if the buffer is a `No Name`-buffer, then record its buffer number
* an API to edit that buffer from the current window.
I pu... | This is the Lua version:
>
> * an API to return all (loaded) buffers
> * loop through each of them
> + if the buffer is a `No Name`-buffer, then record its buffer number
>
>
>
```lua
local function is_no_name_buf(buf)
return
vim.api.nvim_buf_is_loaded(buf)
and vim.api.nvim_buf_get_option(buf, 'bufliste... |
36,458 | <p>As title. I want to check that a buffer is not shown in any tabs. How to do so?</p>
| [
{
"answer_id": 36460,
"author": "Matt",
"author_id": 22797,
"author_profile": "https://vi.stackexchange.com/users/22797",
"pm_score": 3,
"selected": true,
"text": "<p>Buffer is called "hidden" if it's</p>\n<ol>\n<li>Loaded</li>\n<li>Not shown in any window</li>\n</ol>\n<pre><co... | 2022/01/10 | [
"https://vi.stackexchange.com/questions/36458",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/10189/"
] | As title. I want to check that a buffer is not shown in any tabs. How to do so? | Buffer is called "hidden" if it's
1. Loaded
2. Not shown in any window
```
:echo bufloaded(N) && win_findbuf(N)->empty()
```
or
```
:echo bufexists(N) && getbufinfo(N)[0].hidden
``` |
36,462 | <p>Is it possible to start insertion in the end of word with a single keystroke? Currently I am using <code>ea</code>, but it does not allow me to use <code>.</code> to repeat the same action.</p>
<p>I really love <code>A</code> and <code>I</code> which operate with a line. Is there the same alternative, which operates... | [
{
"answer_id": 36463,
"author": "D. Ben Knoble",
"author_id": 10604,
"author_profile": "https://vi.stackexchange.com/users/10604",
"pm_score": 3,
"selected": false,
"text": "<p>An alternative: use a search motion for βmove and repeatβ (<code>n.</code>):</p>\n<pre><code>/^\\w\\+\\>/e&l... | 2022/01/10 | [
"https://vi.stackexchange.com/questions/36462",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/147/"
] | Is it possible to start insertion in the end of word with a single keystroke? Currently I am using `ea`, but it does not allow me to use `.` to repeat the same action.
I really love `A` and `I` which operate with a line. Is there the same alternative, which operates with a word either `w` or `W`?
Let's say I have the... | >
>
> ```
> object_name = "foo"
> another_long_object_name = "bar"
> again_different_length_word_which_needs_same_modification = "spam"
>
> ```
>
> I would like to press a keystroke when standing in the middle of object\_name and add a suffix \_id then repeat the j. command two times to get this result:
>
>
>
T... |
36,494 | <p>Imagine my cursor is where the <code>^</code> is in this document:</p>
<pre class="lang-json prettyprint-override"><code>{
"first": [
{
"second": {
"third": [
"fourth"
]
}
},
{
^ "second": {
"third&... | [
{
"answer_id": 36495,
"author": "Yegappan Lakshmanan",
"author_id": 29827,
"author_profile": "https://vi.stackexchange.com/users/29827",
"pm_score": 2,
"selected": false,
"text": "<p>You can use the following plugin to jump to the different levels of indent:</p>\n<p><a href=\"https://git... | 2022/01/13 | [
"https://vi.stackexchange.com/questions/36494",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/9024/"
] | Imagine my cursor is where the `^` is in this document:
```json
{
"first": [
{
"second": {
"third": [
"fourth"
]
}
},
{
^ "second": {
"third": [
"fourth"
]
}
}
]
}
```
How can I move it to `"first"`?
In reality I have a th... | You can use the following plugin to jump to the different levels of indent:
<https://github.com/jeetsukumaran/vim-indentwise>
Also, refer to
<https://vim.fandom.com/wiki/Move_to_next/previous_line_with_same_indentation>
[How do I jump to the next line with the same indent level?](https://vi.stackexchange.com/question... |
36,537 | <p>An <a href="https://skippi.medium.com/ideas-for-non-leader-vim-mappings-fd32a2769c87" rel="nofollow noreferrer">article</a> on key-mapping uses <code><Cmd></code> where I would expect <code>:</code></p>
<pre><code>nnoremap [q <Cmd>cprev<CR>
nnoremap ]q <Cmd>cnext<CR>
nnoremap [t <Cmd... | [
{
"answer_id": 36495,
"author": "Yegappan Lakshmanan",
"author_id": 29827,
"author_profile": "https://vi.stackexchange.com/users/29827",
"pm_score": 2,
"selected": false,
"text": "<p>You can use the following plugin to jump to the different levels of indent:</p>\n<p><a href=\"https://git... | 2022/01/16 | [
"https://vi.stackexchange.com/questions/36537",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/7810/"
] | An [article](https://skippi.medium.com/ideas-for-non-leader-vim-mappings-fd32a2769c87) on key-mapping uses `<Cmd>` where I would expect `:`
```
nnoremap [q <Cmd>cprev<CR>
nnoremap ]q <Cmd>cnext<CR>
nnoremap [t <Cmd>tprev<CR>
nnoremap ]t <Cmd>tnext<CR>
```
The author apparently distinguishes between the two:
```
nno... | You can use the following plugin to jump to the different levels of indent:
<https://github.com/jeetsukumaran/vim-indentwise>
Also, refer to
<https://vim.fandom.com/wiki/Move_to_next/previous_line_with_same_indentation>
[How do I jump to the next line with the same indent level?](https://vi.stackexchange.com/question... |
36,617 | <p>As title. For example if I have this:</p>
<pre><code>foo/bar/baz/bee
</code></pre>
<p>which is stored in a variable, then which function should I call to get:</p>
<pre><code>foo/bar/baz
</code></pre>
<p>Notice that I will need to store this result back to the variable.</p>
<p>Thanks in advance! I also want to know w... | [
{
"answer_id": 36619,
"author": "D. Ben Knoble",
"author_id": 10604,
"author_profile": "https://vi.stackexchange.com/users/10604",
"pm_score": 2,
"selected": false,
"text": "<p>This is <code>fnamemodify(var, ':h')</code>.</p>\n"
},
{
"answer_id": 36621,
"author": "job_start",... | 2022/01/24 | [
"https://vi.stackexchange.com/questions/36617",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/10189/"
] | As title. For example if I have this:
```
foo/bar/baz/bee
```
which is stored in a variable, then which function should I call to get:
```
foo/bar/baz
```
Notice that I will need to store this result back to the variable.
Thanks in advance! I also want to know whether this is possible in Lua too. | This is `fnamemodify(var, ':h')`. |
36,659 | <p>What is the quickest way to un-doublespace in Vim, without using a regex?</p>
<p>I.e., convert</p>
<pre><code>line one
<emptyline>
line two
<emptyline>
line three
</code></pre>
<p>to</p>
<pre><code>line one
line two
line three
</code></pre>
<p>There's gotta be a way without regexes, by using <code>J</cod... | [
{
"answer_id": 36660,
"author": "Geremia",
"author_id": 5224,
"author_profile": "https://vi.stackexchange.com/users/5224",
"pm_score": 0,
"selected": false,
"text": "<p>Not faster than using <code>s/\\n\\n/\\r/</code>, but this is a macro way of doing it:</p>\n<pre><code>qxJjq\n</code></... | 2022/01/29 | [
"https://vi.stackexchange.com/questions/36659",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/5224/"
] | What is the quickest way to un-doublespace in Vim, without using a regex?
I.e., convert
```
line one
<emptyline>
line two
<emptyline>
line three
```
to
```
line one
line two
line three
```
There's gotta be a way without regexes, by using `J` somehow. | If you're on linux, you could call an external program to filter a range of
lines (here I filter all of them with `%`):
```
:%! awk NF
```
In the above awk command, NF indicates the total number of fields, and hence
this prints only non-blank lines, since in blank lines NF is 0 and evaluates to
false.
Not sure if i... |
36,668 | <p>I have set VIM as the default editor in the Terminal.</p>
<p>I changed the ~/.bashrc:</p>
<pre class="lang-bash prettyprint-override"><code>export VISUAL=vim
export EDITOR="$VISUAL"
</code></pre>
<p>You can also set the default editor only for git:</p>
<pre><code>git config --global core.editor "vim&q... | [
{
"answer_id": 36693,
"author": "Maxim Kim",
"author_id": 9333,
"author_profile": "https://vi.stackexchange.com/users/9333",
"pm_score": 2,
"selected": true,
"text": "<blockquote>\n<p>How can I ungrey this terminal "Copy" button in the right-click menu when all of the text is s... | 2022/01/31 | [
"https://vi.stackexchange.com/questions/36668",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/40728/"
] | I have set VIM as the default editor in the Terminal.
I changed the ~/.bashrc:
```bash
export VISUAL=vim
export EDITOR="$VISUAL"
```
You can also set the default editor only for git:
```
git config --global core.editor "vim"
```
So far so good.
When I open VIM on its own, it opens in the Terminal frame. When I ... | >
> How can I ungrey this terminal "Copy" button in the right-click menu when all of the text is selected? Or which VIM shortcut can still copy when the "Copy" symbol of the right-click menu is greyed out?
>
>
>
You can't ungrey terminal "Copy" menu for vim's visual selection. It only works for terminal selection.... |
36,685 | <p>I just got into <code>:make</code> and I love the ability to browse the errors.</p>
<p>However, in my usual workflow, I am interested in running make and then running some executable. So my to-go option so far was to run something along the lines of <code>:!pushd build && make && ./bin/exec</code>. A... | [
{
"answer_id": 36687,
"author": "Peter Rincker",
"author_id": 778,
"author_profile": "https://vi.stackexchange.com/users/778",
"pm_score": 3,
"selected": true,
"text": "<p>Since editing your makefile is not an option then may need to edit your <code>'makeprg'</code> setting to accommodat... | 2022/02/01 | [
"https://vi.stackexchange.com/questions/36685",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/2938/"
] | I just got into `:make` and I love the ability to browse the errors.
However, in my usual workflow, I am interested in running make and then running some executable. So my to-go option so far was to run something along the lines of `:!pushd build && make && ./bin/exec`. As I said, I love the way I can browse the compi... | Since editing your makefile is not an option then may need to edit your `'makeprg'` setting to accommodate your build process
```
:setlocal makeprg build\ &&\ make\ &&\ ./bin/exec
```
See `'makeprg'` for more details |
36,690 | <p>When writing Markdown, fenced code written between triple backticks is highlighted, but not code in indented blocks (I don't care about language specific highlighting). How can I get vim to recognize indented blocks and highlight them as code? Using nvim v0.4.3 with syntastic and vim-syntax-extra.</p>
| [
{
"answer_id": 36698,
"author": "qwr",
"author_id": 9553,
"author_profile": "https://vi.stackexchange.com/users/9553",
"pm_score": 1,
"selected": false,
"text": "<p>I tested plugins <a href=\"https://github.com/gabrielelana/vim-markdown\" rel=\"nofollow noreferrer\">https://github.com/ga... | 2022/02/01 | [
"https://vi.stackexchange.com/questions/36690",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/9553/"
] | When writing Markdown, fenced code written between triple backticks is highlighted, but not code in indented blocks (I don't care about language specific highlighting). How can I get vim to recognize indented blocks and highlight them as code? Using nvim v0.4.3 with syntastic and vim-syntax-extra. | The default syntax file for markdown doesnβt link the code or code block groups, but:
```
highlight link markdownCode somegroup
highlight link markdownCodeBlock somegroup
```
Will do just fine |
36,702 | <p>I have the feeling that the answer is <em>you can't</em>, but I'd like to be sure about it.</p>
<p><a href="https://github.com/Aster89/WinZoZ" rel="nofollow noreferrer">My plugin</a> has some <code>s:<i>function-name</i></code> functions, and one <code><i>plugin-name</i>#<i>function-name</i></code> function that use... | [
{
"answer_id": 36703,
"author": "mattb",
"author_id": 31858,
"author_profile": "https://vi.stackexchange.com/users/31858",
"pm_score": 0,
"selected": false,
"text": "<p>I have a <a href=\"https://github.com/Matt-A-Bennett/vim-unit-test\" rel=\"nofollow noreferrer\">plugin that I use to d... | 2022/02/02 | [
"https://vi.stackexchange.com/questions/36702",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/6498/"
] | I have the feeling that the answer is *you can't*, but I'd like to be sure about it.
[My plugin](https://github.com/Aster89/WinZoZ) has some `s:*function-name*` functions, and one `*plugin-name*#*function-name*` function that uses the former ones.
Is there a way to write unit tests for those `s:` functions? For insta... | When I have internal functions that I want to test, I don't declare them as `s:` functions but with a different naming policy like `mypluginscope#_whatever()`. This way testing them is not an issue and I keep `s:functions` really internal.
Otherwise there is a way to find script-local functions from the name of the pl... |
36,708 | <p>When editing a script in vim, I can run it with <code>:! bash %</code> or <code>:! python %</code> for python scripts. When running the script, vim kinda goes back to the terminal, runs there, and then, after "ENTER" it goes back to the Vim window.</p>
<p>I would like to have it open a small window, that I... | [
{
"answer_id": 36709,
"author": "mattb",
"author_id": 31858,
"author_profile": "https://vi.stackexchange.com/users/31858",
"pm_score": 2,
"selected": false,
"text": "<p>One way to have this kind of behaviour is to use tmux to split the terminal\ninto 2 (or more) panes. Then run vim in on... | 2022/02/03 | [
"https://vi.stackexchange.com/questions/36708",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/20287/"
] | When editing a script in vim, I can run it with `:! bash %` or `:! python %` for python scripts. When running the script, vim kinda goes back to the terminal, runs there, and then, after "ENTER" it goes back to the Vim window.
I would like to have it open a small window, that I can jump to and from, for execution. Som... | This is what the `:terminal` command is for:
```
:terminal bash %
:terminal python %
``` |
36,716 | <p>When in normal mode, with the following (<code>^</code> indicates cursor position):</p>
<pre><code>Lorem ipsum
^
</code></pre>
<p>How do I delete the entire word ipsum in the least keystrokes?</p>
<h2>Things I've Tried:</h2>
<p><code>db</code> gets</p>
<pre><code>Lorem m
^
</code></pre>
<p>requiring ... | [
{
"answer_id": 36709,
"author": "mattb",
"author_id": 31858,
"author_profile": "https://vi.stackexchange.com/users/31858",
"pm_score": 2,
"selected": false,
"text": "<p>One way to have this kind of behaviour is to use tmux to split the terminal\ninto 2 (or more) panes. Then run vim in on... | 2022/02/03 | [
"https://vi.stackexchange.com/questions/36716",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/40775/"
] | When in normal mode, with the following (`^` indicates cursor position):
```
Lorem ipsum
^
```
How do I delete the entire word ipsum in the least keystrokes?
Things I've Tried:
------------------
`db` gets
```
Lorem m
^
```
requiring an additional keypress of `x`.
Is there a way to do this with... | This is what the `:terminal` command is for:
```
:terminal bash %
:terminal python %
``` |
36,720 | <p>Looking for <code>lambda</code> in the doc, I've found out (to my surprise) that they do exist in vimscript, and they use the syntax <code>{args -> expr1}</code>.</p>
<p>But I've also discovered that there's Vim9, the doc of which is at <code>:help Vim9</code>, which offers a different syntax for lambdas: <code>(... | [
{
"answer_id": 36721,
"author": "Chris Heithoff",
"author_id": 36840,
"author_profile": "https://vi.stackexchange.com/users/36840",
"pm_score": 4,
"selected": true,
"text": "<p>Because Vim9 has not been formally released yet, but the features are ready to try out in the latest Vim8 relea... | 2022/02/03 | [
"https://vi.stackexchange.com/questions/36720",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/6498/"
] | Looking for `lambda` in the doc, I've found out (to my surprise) that they do exist in vimscript, and they use the syntax `{args -> expr1}`.
But I've also discovered that there's Vim9, the doc of which is at `:help Vim9`, which offers a different syntax for lambdas: `(args) -> expr1`.
However, if I try entering `:ech... | Because Vim9 has not been formally released yet, but the features are ready to try out in the latest Vim8 releases.
If you see it in the help, then you can use it two ways:
```
The Vim9 script syntax and semantics are used in:
- a function defined with the `:def` command
- a script file where the first command is `vi... |
36,799 | <p>I'm refactoring the logger code in my software.</p>
<p>The old log message ends with either <code>);</code> or just <code>;</code> at the end of a line and I want to remove those characters and add a new line with some additional data. Here are a few examples showing the endings:</p>
<pre><code>SNAP_LOG_INFO("S... | [
{
"answer_id": 36800,
"author": "Alexis Wilke",
"author_id": 9276,
"author_profile": "https://vi.stackexchange.com/users/9276",
"pm_score": 0,
"selected": false,
"text": "<p>The problem is to find where to go to the end of the line. For that we can actually use a search, but in a macro i... | 2022/02/14 | [
"https://vi.stackexchange.com/questions/36799",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/9276/"
] | I'm refactoring the logger code in my software.
The old log message ends with either `);` or just `;` at the end of a line and I want to remove those characters and add a new line with some additional data. Here are a few examples showing the endings:
```
SNAP_LOG_INFO("Some message");
SNAP_LOG_INFO("Some message ")(... | Another approach is to use `:substitute`, having:
```
SNAP_LOG_INFO("Some message");
SNAP_LOG_INFO("Some message ")(variable);
SNAP_LOG_INFO("Some message ")(func());
SNAP_LOG_INFO() << "Some message";
// Here is a special case, but I'm not trying to solve it because it's really rare
SNAP_LOG_INFO() << func();
```
... |
36,805 | <p>I just installed Ubuntu linux on my laptop and made sure to install python.</p>
<p>After installing Python, I type the command <code>python3 --version</code> and found that I got version 3.9.7, which is stored in the <code>/usr/bin/</code> directory.</p>
<p>However, when I manually check the directory contents in <c... | [
{
"answer_id": 36820,
"author": "Vivian De Smedt",
"author_id": 23502,
"author_profile": "https://vi.stackexchange.com/users/23502",
"pm_score": 2,
"selected": false,
"text": "<p>I use the <code>:CocConfig</code> command to edit the <code>coc-settings.json</code> file and make sure the <... | 2022/02/15 | [
"https://vi.stackexchange.com/questions/36805",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/41009/"
] | I just installed Ubuntu linux on my laptop and made sure to install python.
After installing Python, I type the command `python3 --version` and found that I got version 3.9.7, which is stored in the `/usr/bin/` directory.
However, when I manually check the directory contents in `/usr/bin` I find that I also have a Py... | I use the `:CocConfig` command to edit the `coc-settings.json` file and make sure the `python.pythonPath` is set correctly:
Here is a excerpt of my `coc-settings.json` file to set the interpreter to Python36 on the Windows platform.
```
{
"python.pythonPath": "C:\\Python36_x64\\python.exe",
"python.formatting... |
36,855 | <p>I'd like to insert uuids into my tests when I need them without having to leave vim. I've tried to create a python3 plugin to do this:</p>
<pre><code>import neovim
import uuid
@neovim.plugin
class GenerateUuid(object):
def __init__(self, vim):
self.vim = vim
self.current_line = vim.current.line... | [
{
"answer_id": 36858,
"author": "statox",
"author_id": 1841,
"author_profile": "https://vi.stackexchange.com/users/1841",
"pm_score": 2,
"selected": true,
"text": "<p>This is not directly an answer to your question because I don't feel like digging in some python plugin code. This is jus... | 2022/02/21 | [
"https://vi.stackexchange.com/questions/36855",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/10361/"
] | I'd like to insert uuids into my tests when I need them without having to leave vim. I've tried to create a python3 plugin to do this:
```
import neovim
import uuid
@neovim.plugin
class GenerateUuid(object):
def __init__(self, vim):
self.vim = vim
self.current_line = vim.current.line
@neovim... | This is not directly an answer to your question because I don't feel like digging in some python plugin code. This is just an alternative way covering only the need you presented.
---
What about something much simpler than your whole plugin? For example you could add these lines to your vimrc:
```
command! GetUuid l... |
36,865 | <p>Neovim .6.1</p>
<p>Got this line:</p>
<p><code>add_post_meta($this->cmr_id, 'intro_paragraph', 'Hello');</code></p>
<p>With:</p>
<pre><code>add_post_meta($this->cmr_id, 'intro_paragraph', 'Hello');
^ cursor here
</code></pre>
<p>Hitting '%' key jumps to opening paren as expecte... | [
{
"answer_id": 36867,
"author": "StevieD",
"author_id": 2021,
"author_profile": "https://vi.stackexchange.com/users/2021",
"pm_score": 0,
"selected": false,
"text": "<p>Looks to be a bug in html.vim which gets loaded by php.vim.</p>\n<p>Hack fix:</p>\n<p>Comment out:</p>\n<p><code>"... | 2022/02/22 | [
"https://vi.stackexchange.com/questions/36865",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/2021/"
] | Neovim .6.1
Got this line:
`add_post_meta($this->cmr_id, 'intro_paragraph', 'Hello');`
With:
```
add_post_meta($this->cmr_id, 'intro_paragraph', 'Hello');
^ cursor here
```
Hitting '%' key jumps to opening paren as expected.
But with:
```
add_post_meta($this->cmr_id, 'intro_para... | OK, here's a much better fix, albeit probably not perfect.
In `after/ftplugin/php.vim`, add the following 3 lines:
```
let b:match_words .= '<?php:[^-]>'
set matchpairs-=<:>
let b:match_words = substitute(b:match_words, '<:>', '<:\@<=[^-]>', '')
``` |
36,866 | <p>running newvim 0.6.1. Totally clean install, no plugins.</p>
<p>In <code>init.lua</code>:</p>
<p><code>vim.opt.syntax</code> = "off"</p>
<p>Also tried "false" and "disabled." Didn't work. Also tried <code>vim.g</code>, <code>vim.o</code>, <code>vim.bo</code>. Didn't work.</p>
<p>Syntax ... | [
{
"answer_id": 36867,
"author": "StevieD",
"author_id": 2021,
"author_profile": "https://vi.stackexchange.com/users/2021",
"pm_score": 0,
"selected": false,
"text": "<p>Looks to be a bug in html.vim which gets loaded by php.vim.</p>\n<p>Hack fix:</p>\n<p>Comment out:</p>\n<p><code>"... | 2022/02/22 | [
"https://vi.stackexchange.com/questions/36866",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/2021/"
] | running newvim 0.6.1. Totally clean install, no plugins.
In `init.lua`:
`vim.opt.syntax` = "off"
Also tried "false" and "disabled." Didn't work. Also tried `vim.g`, `vim.o`, `vim.bo`. Didn't work.
Syntax highlighting still shows up.
In `init.vim`:
`syntax off`
No syntax highlighting. | OK, here's a much better fix, albeit probably not perfect.
In `after/ftplugin/php.vim`, add the following 3 lines:
```
let b:match_words .= '<?php:[^-]>'
set matchpairs-=<:>
let b:match_words = substitute(b:match_words, '<:>', '<:\@<=[^-]>', '')
``` |
36,885 | <p>I have a variable with a "key" in vim notation, <code><C-j></code>. How can I use it in <code><expr></code> mapping?</p>
<pre><code>let g:key = "<C-j>"
inoremap <expr> <C-j> '\' .. g:key
" inserts \<C-j> instead of newline
</code></pre>
<p>The mapping I g... | [
{
"answer_id": 36886,
"author": "Matt",
"author_id": 22797,
"author_profile": "https://vi.stackexchange.com/users/22797",
"pm_score": 4,
"selected": true,
"text": "<p>You don't need backslash in map command. Simply</p>\n<pre><code>let g:key = "\\<C-j>"\ninoremap <expr&... | 2022/02/24 | [
"https://vi.stackexchange.com/questions/36885",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/9333/"
] | I have a variable with a "key" in vim notation, `<C-j>`. How can I use it in `<expr>` mapping?
```
let g:key = "<C-j>"
inoremap <expr> <C-j> '\' .. g:key
" inserts \<C-j> instead of newline
```
The mapping I get from redirecting `imap` and extracting the `<C-j>` out of it, so I can't use `let g:key = "\<C-j>"`. | You don't need backslash in map command. Simply
```
let g:key = "\<C-j>"
inoremap <expr><C-j> g:key
```
UPD. It looks as if you want `:h nvim_replace_termcodes()` function available in Neovim. There's no direct counterpart in Vim, but you can write your own (incomplete?) implementation:
```
function! Replace_termco... |
36,893 | <p>I'd like to set c++ header file path automatically from .vimrc.
So I tried to write .vimrc file as shown below:</p>
<pre><code>let g:gcpp_headers_path=system("g++ --version | grep g++ | awk '{print \"/usr/include/c++/\"$NF}'")
"if isdirectory(gcpp_headers_path)
set path+=g:gcpp_headers_pa... | [
{
"answer_id": 36896,
"author": "Jumogehn",
"author_id": 41153,
"author_profile": "https://vi.stackexchange.com/users/41153",
"pm_score": 1,
"selected": false,
"text": "<p>This works!</p>\n<pre><code>let g:gcpp_headers_path = system("g++ --version | grep g++ | awk '{print \\"/u... | 2022/02/26 | [
"https://vi.stackexchange.com/questions/36893",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/41153/"
] | I'd like to set c++ header file path automatically from .vimrc.
So I tried to write .vimrc file as shown below:
```
let g:gcpp_headers_path=system("g++ --version | grep g++ | awk '{print \"/usr/include/c++/\"$NF}'")
"if isdirectory(gcpp_headers_path)
set path+=g:gcpp_headers_path
"endif
```
from the vimrc above I... | Here is the full implementation taken from my own config. Basically, run preprocessor, parse the output and cache the result. Then set path by ftplugin as needed.
>
> ~/.vim/autoload/misc.vim
>
>
>
```
" misc#gcc_include([{gcc} [, {force} [, {ft}]]])
" get GCC include dirs
function! misc#gcc_include(gcc = b:curre... |
36,902 | <p>I use <a href="https://github.com/glepnir/dashboard-nvim" rel="nofollow noreferrer">dashboard</a> so I like my marks clean.
So I generally make many marks while working on something and then delete them all except the file bookmark in the end. Is there any way to delete all marks <strong>except the bookmarks or the ... | [
{
"answer_id": 36896,
"author": "Jumogehn",
"author_id": 41153,
"author_profile": "https://vi.stackexchange.com/users/41153",
"pm_score": 1,
"selected": false,
"text": "<p>This works!</p>\n<pre><code>let g:gcpp_headers_path = system("g++ --version | grep g++ | awk '{print \\"/u... | 2022/02/28 | [
"https://vi.stackexchange.com/questions/36902",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/40325/"
] | I use [dashboard](https://github.com/glepnir/dashboard-nvim) so I like my marks clean.
So I generally make many marks while working on something and then delete them all except the file bookmark in the end. Is there any way to delete all marks **except the bookmarks or the uppercase letters**. So is there a way to clea... | Here is the full implementation taken from my own config. Basically, run preprocessor, parse the output and cache the result. Then set path by ftplugin as needed.
>
> ~/.vim/autoload/misc.vim
>
>
>
```
" misc#gcc_include([{gcc} [, {force} [, {ft}]]])
" get GCC include dirs
function! misc#gcc_include(gcc = b:curre... |
36,914 | <p>On Mac OS Big Sur (11.6.3) with <code>nvi</code> 1.81.6 and several <code>tmux</code> panels, I accidentally quit Terminal.</p>
<p>Now opening files leads to the message</p>
<pre><code><file> already locked, session is read-only
<file> unmodified, readonly: line 1
</code></pre>
<p>After consulting <a hre... | [
{
"answer_id": 36896,
"author": "Jumogehn",
"author_id": 41153,
"author_profile": "https://vi.stackexchange.com/users/41153",
"pm_score": 1,
"selected": false,
"text": "<p>This works!</p>\n<pre><code>let g:gcpp_headers_path = system("g++ --version | grep g++ | awk '{print \\"/u... | 2022/03/01 | [
"https://vi.stackexchange.com/questions/36914",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/41179/"
] | On Mac OS Big Sur (11.6.3) with `nvi` 1.81.6 and several `tmux` panels, I accidentally quit Terminal.
Now opening files leads to the message
```
<file> already locked, session is read-only
<file> unmodified, readonly: line 1
```
After consulting [this answer about recovery files](https://vi.stackexchange.com/a/3664... | Here is the full implementation taken from my own config. Basically, run preprocessor, parse the output and cache the result. Then set path by ftplugin as needed.
>
> ~/.vim/autoload/misc.vim
>
>
>
```
" misc#gcc_include([{gcc} [, {force} [, {ft}]]])
" get GCC include dirs
function! misc#gcc_include(gcc = b:curre... |
36,930 | <p>I know that I can delete until the first character with <code>dgg</code> or until line 1 with <code>d1 Shift-G</code>.</p>
<p>But I would prefer something conceptually elegant if possible.</p>
<p>I guess I can easily just remap a single key to <code>d2 Shift-G</code>, but Iβm still not clear on how you find or decid... | [
{
"answer_id": 36931,
"author": "statox",
"author_id": 1841,
"author_profile": "https://vi.stackexchange.com/users/1841",
"pm_score": 2,
"selected": false,
"text": "<p>I think what you are looking for is the following command:</p>\n<pre><code>:2,.d\n</code></pre>\n<p>The <code>2,.</code>... | 2022/03/03 | [
"https://vi.stackexchange.com/questions/36930",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/37865/"
] | I know that I can delete until the first character with `dgg` or until line 1 with `d1 Shift-G`.
But I would prefer something conceptually elegant if possible.
I guess I can easily just remap a single key to `d2 Shift-G`, but Iβm still not clear on how you find or decide what key to map to, in case you overwrite some... | I think what you are looking for is the following command:
```
:2,.d
```
The `2,.` is the range on which `d` is applied it goes from the second line to the current line (`.`)
And you can map that to whatever you want:
```
nnoremap <leader>d :2,.d<CR>
``` |