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 |
|---|---|---|---|---|---|---|
36,940 | <p>I want to find and eventually delete all whitespace between all occurrences of an equal sign and the next character. For example, turn</p>
<pre><code>@article{article1,
author= {author1},
journal= {journal1},
year= 2022,
}
@article{article2,
author= {author2},
journal= {journa... | [
{
"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/05 | [
"https://vi.stackexchange.com/questions/36940",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/38662/"
] | I want to find and eventually delete all whitespace between all occurrences of an equal sign and the next character. For example, turn
```
@article{article1,
author= {author1},
journal= {journal1},
year= 2022,
}
@article{article2,
author= {author2},
journal= {journal2},
year= ... | 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>
``` |
36,943 | <p>I have lines like this:</p>
<pre><code>$params["request_id_$i"] => $v["request_id_$i"];
$params["drug_name_$i"] => $v["drug_name"];
</code></pre>
<p>I want to replace all _ occuring after "=>" with "-". I am able to replace
single "_" wit... | [
{
"answer_id": 36944,
"author": "Heptite",
"author_id": 1311,
"author_profile": "https://vi.stackexchange.com/users/1311",
"pm_score": 2,
"selected": false,
"text": "<p>It's not elegant, but it works:</p>\n<pre><code>:%s/=> \\zs\\(.*\\)/\\=substitute(submatch(1), '_', '-', 'g')/\n</co... | 2022/03/05 | [
"https://vi.stackexchange.com/questions/36943",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/33977/"
] | I have lines like this:
```
$params["request_id_$i"] => $v["request_id_$i"];
$params["drug_name_$i"] => $v["drug_name"];
```
I want to replace all \_ occuring after "=>" with "-". I am able to replace
single "\_" with following:
```
s/^.*=> \zs\(.\{-}\)_\(.\{-}\)$/\1-\2/g
```
But how to do it for multiple \_ ? | The simplest way is to use a lookbehind assertion
```
s/\(=>.*\)\@<=_/-/g
```
This is telling vim to check backwards for `=>` for each possible `_` match. |
36,952 | <p>I have an external command which accepts a SQL. I want to execute it within vim while editing SQL. I found two ways but both are not very satisfying.</p>
<ol>
<li><p><code>:w !<cmd></code>
This passes the content of the current buffer to <code><cmd></code> and outputs the result. However, because the res... | [
{
"answer_id": 36944,
"author": "Heptite",
"author_id": 1311,
"author_profile": "https://vi.stackexchange.com/users/1311",
"pm_score": 2,
"selected": false,
"text": "<p>It's not elegant, but it works:</p>\n<pre><code>:%s/=> \\zs\\(.*\\)/\\=substitute(submatch(1), '_', '-', 'g')/\n</co... | 2022/03/07 | [
"https://vi.stackexchange.com/questions/36952",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/36524/"
] | I have an external command which accepts a SQL. I want to execute it within vim while editing SQL. I found two ways but both are not very satisfying.
1. `:w !<cmd>`
This passes the content of the current buffer to `<cmd>` and outputs the result. However, because the result is shown in vim command line area, if the res... | The simplest way is to use a lookbehind assertion
```
s/\(=>.*\)\@<=_/-/g
```
This is telling vim to check backwards for `=>` for each possible `_` match. |
36,962 | <p><a href="https://i.stack.imgur.com/VgB38.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VgB38.png" alt="enter image description here" /></a></p>
<p>I want to remove <strong>#</strong> from line 79 to 91</p>
| [
{
"answer_id": 36944,
"author": "Heptite",
"author_id": 1311,
"author_profile": "https://vi.stackexchange.com/users/1311",
"pm_score": 2,
"selected": false,
"text": "<p>It's not elegant, but it works:</p>\n<pre><code>:%s/=> \\zs\\(.*\\)/\\=substitute(submatch(1), '_', '-', 'g')/\n</co... | 2022/03/08 | [
"https://vi.stackexchange.com/questions/36962",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/41247/"
] | [](https://i.stack.imgur.com/VgB38.png)
I want to remove **#** from line 79 to 91 | The simplest way is to use a lookbehind assertion
```
s/\(=>.*\)\@<=_/-/g
```
This is telling vim to check backwards for `=>` for each possible `_` match. |
36,972 | <p>I find I forget to leave INSERT or REPLACE to navigate around the file with cursor keys, Page Up, Page Down, etc. Or, I walk off from the computer to make my coffee, or whatever.</p>
<p>Then when my brain comes back to editing the file, it's forgotten which mode Vim was left in. I want to reduce this cognitive load ... | [
{
"answer_id": 36975,
"author": "statox",
"author_id": 1841,
"author_profile": "https://vi.stackexchange.com/users/1841",
"pm_score": 3,
"selected": true,
"text": "<p>You can use the following mappings:</p>\n<pre><code>inoremap <left> <esc><left>\ninoremap <right... | 2022/03/09 | [
"https://vi.stackexchange.com/questions/36972",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/40470/"
] | I find I forget to leave INSERT or REPLACE to navigate around the file with cursor keys, Page Up, Page Down, etc. Or, I walk off from the computer to make my coffee, or whatever.
Then when my brain comes back to editing the file, it's forgotten which mode Vim was left in. I want to reduce this cognitive load by just h... | You can use the following mappings:
```
inoremap <left> <esc><left>
inoremap <right> <esc><right>
inoremap <up> <esc><up>
inoremap <down> <esc><down>
inoremap <PageUp> <esc><<PageUp>
inoremap <PageDown> <esc><PageDown>
```
Or just for fun:
```
let escapeInsertModeKeys = [ '<left>', '<right>', '<u... |
36,985 | <p>I'm trying to use <a href="https://github.com/junegunn/vim-easy-align" rel="nofollow noreferrer"><code>junegunn/vim-easy-align</code></a> to vertically align some text.</p>
<p>EasyAlign has an <a href="https://github.com/junegunn/vim-easy-align#interactive-mode" rel="nofollow noreferrer">interactive-mode</a> which m... | [
{
"answer_id": 36986,
"author": "D. Ben Knoble",
"author_id": 10604,
"author_profile": "https://vi.stackexchange.com/users/10604",
"pm_score": 3,
"selected": true,
"text": "<p>Try <code>:</code> instead of <code><cmd></code>; it’s possible switching mode is intended here. Read abou... | 2022/03/10 | [
"https://vi.stackexchange.com/questions/36985",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/40684/"
] | I'm trying to use [`junegunn/vim-easy-align`](https://github.com/junegunn/vim-easy-align) to vertically align some text.
EasyAlign has an [interactive-mode](https://github.com/junegunn/vim-easy-align#interactive-mode) which means you can invoke EasyAlign, it prompts for a key, and then aligns around whatever key you e... | Try `:` instead of `<cmd>`; it’s possible switching mode is intended here. Read about the difference at `:help <cmd>`. |
37,002 | <p>I have come across this behaviour and the documentation does not make sense to me.</p>
<p>Consider this sentence:</p>
<pre><code>I am 100% sure there is something I am missing.
This is the next line.
</code></pre>
<p>Pressing <code>w</code> takes me to the start of the next word. What a word is, is defined by the <c... | [
{
"answer_id": 37005,
"author": "filbranden",
"author_id": 18609,
"author_profile": "https://vi.stackexchange.com/users/18609",
"pm_score": 3,
"selected": false,
"text": "<p>When you're using a <code>w</code> (or <code>e</code>, or <code>b</code>) command to move on a word that contains ... | 2022/03/13 | [
"https://vi.stackexchange.com/questions/37002",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/41334/"
] | I have come across this behaviour and the documentation does not make sense to me.
Consider this sentence:
```
I am 100% sure there is something I am missing.
This is the next line.
```
Pressing `w` takes me to the start of the next word. What a word is, is defined by the `'iskeyword'` option. `%` is by default not... | When you're using a `w` (or `e`, or `b`) command to move on a word that contains both characters listed in `'iskeyword'` and characters *not* listed in `'iskeyword'`, then the `w` command will alternate between the sequences of keyword and non-keyword characters.
The last part of [section 03.1 of the docs](https://vim... |
37,009 | <p>This is just my own curiosity speaking here, but would it be possible (if it's even possible by default in normal <code>vim</code>, without any additional plugins etc) to call a function inside a vimscript function <em>without</em> having to use <code>call</code>?</p>
<p>I'm thinking of emulating or doing things lik... | [
{
"answer_id": 37010,
"author": "statox",
"author_id": 1841,
"author_profile": "https://vi.stackexchange.com/users/1841",
"pm_score": 3,
"selected": true,
"text": "<p>I'm not sure why you would need that in this context but you could use a user defined command (<a href=\"http://vimhelp.a... | 2022/03/14 | [
"https://vi.stackexchange.com/questions/37009",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/30351/"
] | This is just my own curiosity speaking here, but would it be possible (if it's even possible by default in normal `vim`, without any additional plugins etc) to call a function inside a vimscript function *without* having to use `call`?
I'm thinking of emulating or doing things like when special function/keywords like ... | I'm not sure why you would need that in this context but you could use a user defined command ([`:h user-commands`](http://vimhelp.appspot.com/map.txt.html#user-commands)):
```
function MyFunction(argument)
echo a:argument
endfunction
command! -nargs=1 Myfunc call MyFunction(<args>)
```
With this you can use `:... |
37,012 | <p>Is there any way to list all global variable?
I'm guessing i could maintain a list where multiple value represent a global variable but that feel a bit weird. is there an official way to do that? (looked into the docs but didn't find anything)</p>
<p>I'm only talking about <code>g:variable_name</code> here.</p>
| [
{
"answer_id": 37013,
"author": "filbranden",
"author_id": 18609,
"author_profile": "https://vi.stackexchange.com/users/18609",
"pm_score": 4,
"selected": true,
"text": "<p>This command will list all global variables:</p>\n<pre><code>:let g:\n</code></pre>\n<p>Using <code>:let</code> by ... | 2022/03/14 | [
"https://vi.stackexchange.com/questions/37012",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/30351/"
] | Is there any way to list all global variable?
I'm guessing i could maintain a list where multiple value represent a global variable but that feel a bit weird. is there an official way to do that? (looked into the docs but didn't find anything)
I'm only talking about `g:variable_name` here. | This command will list all global variables:
```
:let g:
```
Using `:let` by itself will list all variables, and passing it just a prefix (such as `g:` or `b:` or `v:`) will filter the output to only include variables in that prefix. Therefore, `:let g:` will show you all global variables. |
37,070 | <p>I've got a shell script: <code>find... | stuff | xargs vi</code> which works fine from the shell. But if I invoke that from inside Vim like <code>:! find... | stuff | xargs vi</code> it's kinda weird... like maybe I'm seeing different instance of vim that's spawned in a new shell? In that new vim <code>:ls</code> on... | [
{
"answer_id": 37072,
"author": "filbranden",
"author_id": 18609,
"author_profile": "https://vi.stackexchange.com/users/18609",
"pm_score": 3,
"selected": true,
"text": "<p>You can use backquotes in an Ex command in Vim to use the output of a shell command as part of the Ex command argum... | 2022/03/23 | [
"https://vi.stackexchange.com/questions/37070",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/6189/"
] | I've got a shell script: `find... | stuff | xargs vi` which works fine from the shell. But if I invoke that from inside Vim like `:! find... | stuff | xargs vi` it's kinda weird... like maybe I'm seeing different instance of vim that's spawned in a new shell? In that new vim `:ls` only shows the new buffer and after do... | You can use backquotes in an Ex command in Vim to use the output of a shell command as part of the Ex command arguments, similarly to how backquotes work on a Bourne shell.
Note that this seems to only work on Unix versions of Vim, not on Windows.
If you have a pipeline, you need to escape the pipes with a backslash ... |
37,082 | <p>I want to achieve the same thing as <code>S ESC</code> without entering insert
mode. Is there a way to do this?</p>
<p>The best I've come up with is <code>d$</code>, but then you have to make sure
you're at the front of a line which makes it <code>^ d$</code>.</p>
<p>Visually, with cursor as <code>|</code>; before:<... | [
{
"answer_id": 37084,
"author": "Peter Rincker",
"author_id": 778,
"author_profile": "https://vi.stackexchange.com/users/778",
"pm_score": 1,
"selected": false,
"text": "<p>As far as I know there is no blanking line command. I imagine you would need to make your own mapping</p>\n<pre><co... | 2022/03/24 | [
"https://vi.stackexchange.com/questions/37082",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/40353/"
] | I want to achieve the same thing as `S ESC` without entering insert
mode. Is there a way to do this?
The best I've come up with is `d$`, but then you have to make sure
you're at the front of a line which makes it `^ d$`.
Visually, with cursor as `|`; before:
```
Beautiful sentence that I wa|nt to destroy.
```
Afte... | To save one keystroke, instead of `^d$`, do `^D`
Also faster because you keep the Shift key down for both `^` and `D` |
37,088 | <p>I use some statusline plugin, which source theme files from <code><the-autoload-directory>/lightline/colorscheme/*.vim</code>.</p>
<p>Many color plugins also provide themes for that statusline. Switching the theme requires just one argument, the theme name, which is same as its file name. So I would like to ge... | [
{
"answer_id": 37089,
"author": "Maxim Kim",
"author_id": 9333,
"author_profile": "https://vi.stackexchange.com/users/9333",
"pm_score": 2,
"selected": true,
"text": "<p><code>:h glob()</code></p>\n<p>And for your case it might be:</p>\n<pre><code>:echo glob("~/.vim/**/lightline/**/... | 2022/03/25 | [
"https://vi.stackexchange.com/questions/37088",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/16270/"
] | I use some statusline plugin, which source theme files from `<the-autoload-directory>/lightline/colorscheme/*.vim`.
Many color plugins also provide themes for that statusline. Switching the theme requires just one argument, the theme name, which is same as its file name. So I would like to get the list of available th... | `:h glob()`
And for your case it might be:
```
:echo glob("~/.vim/**/lightline/**/*.vim")
``` |
37,125 | <p>I'm in a file and want to copy and edit part of the file content in a new tab temporarily.</p>
<p>I know that I can write it in a file using <code>:'<,'> w /tmp/list.txt</code>, then <code>:tabnew /tmp/list.txt</code>.</p>
<p>But what if I don't want to write a file and open it afterwards? Do you know a better... | [
{
"answer_id": 37126,
"author": "Maxim Kim",
"author_id": 9333,
"author_profile": "https://vi.stackexchange.com/users/9333",
"pm_score": 1,
"selected": false,
"text": "<p>Imagine you want to have range 6, 16 of lines into a new tab buffer:</p>\n<ol>\n<li><code>tabnew</code></li>\n<li><co... | 2022/03/31 | [
"https://vi.stackexchange.com/questions/37125",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/12070/"
] | I'm in a file and want to copy and edit part of the file content in a new tab temporarily.
I know that I can write it in a file using `:'<,'> w /tmp/list.txt`, then `:tabnew /tmp/list.txt`.
But what if I don't want to write a file and open it afterwards? Do you know a better and/or faster way? | Imagine you want to have range 6, 16 of lines into a new tab buffer:
1. `tabnew`
2. `:call setline(1, getbufline('#', 6, 16))`
Alternate buffer `#` would be set to the buffer you start `tabnew` from.
Or, for example, if you want to "copy" a visual:
```
func! IntoNewTab() abort
let lines = getline("'<", "'>")
... |
37,143 | <p>I would like to have a regular expression that replace:</p>
<pre><code>"foo" "bar" Is "hello" "world" "!"
</code></pre>
<p>by:</p>
<pre><code>"foo" "bar" Is "hello world !"
</code></pre>
<p>I have tried <code>:%s/Is\(\s*"\([^"]... | [
{
"answer_id": 37126,
"author": "Maxim Kim",
"author_id": 9333,
"author_profile": "https://vi.stackexchange.com/users/9333",
"pm_score": 1,
"selected": false,
"text": "<p>Imagine you want to have range 6, 16 of lines into a new tab buffer:</p>\n<ol>\n<li><code>tabnew</code></li>\n<li><co... | 2022/04/01 | [
"https://vi.stackexchange.com/questions/37143",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/23502/"
] | I would like to have a regular expression that replace:
```
"foo" "bar" Is "hello" "world" "!"
```
by:
```
"foo" "bar" Is "hello world !"
```
I have tried `:%s/Is\(\s*"\([^"]*\)"\)*/Is "\2\4\6"/`
But it seems that `\2` is the last capture of the second group (`!`) and it returns:
```
Is "!"
```
Is there a way... | Imagine you want to have range 6, 16 of lines into a new tab buffer:
1. `tabnew`
2. `:call setline(1, getbufline('#', 6, 16))`
Alternate buffer `#` would be set to the buffer you start `tabnew` from.
Or, for example, if you want to "copy" a visual:
```
func! IntoNewTab() abort
let lines = getline("'<", "'>")
... |
37,186 | <p>Currently my <code>.vimrc</code> file has this in it,</p>
<pre><code>filetype plugin indent on -- filetype detection[ON] plugin[ON] indent[ON]
</code></pre>
<p>How can I port <code>filetype plugin indent on</code> to neovim's lua format?</p>
| [
{
"answer_id": 37192,
"author": "filbranden",
"author_id": 18609,
"author_profile": "https://vi.stackexchange.com/users/18609",
"pm_score": 0,
"selected": false,
"text": "<p>You should use <a href=\"https://github.com/nanotee/nvim-lua-guide#vimapinvim_command\" rel=\"nofollow noreferrer\... | 2022/04/06 | [
"https://vi.stackexchange.com/questions/37186",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/5078/"
] | Currently my `.vimrc` file has this in it,
```
filetype plugin indent on -- filetype detection[ON] plugin[ON] indent[ON]
```
How can I port `filetype plugin indent on` to neovim's lua format? | >
> How can I port `filetype plugin indent on`?
>
>
>
You don't. This is the default (in Neovim).
From `:he nvim-defaults`,
>
> * Syntax highlighting is enabled by default
> * `:filetype plugin indent on` is enabled by default
>
>
> |
37,197 | <p>On regular vim, you can find the defaults in <a href="https://github.com/vim/vim/blob/master/runtime/defaults.vim" rel="nofollow noreferrer"><code>defaults.vim</code></a>. These are sourced when there is no <code>.vimrc</code>, or when you include in your <code>.vimrc</code> the following,</p>
<pre><code>source $VIM... | [
{
"answer_id": 37200,
"author": "Matt",
"author_id": 22797,
"author_profile": "https://vi.stackexchange.com/users/22797",
"pm_score": 2,
"selected": false,
"text": "<p><code>$VIMRUNTIME/defaults.vim</code> is NOT the defaults. It is a script that changes them. It could be sourced under s... | 2022/04/07 | [
"https://vi.stackexchange.com/questions/37197",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/5078/"
] | On regular vim, you can find the defaults in [`defaults.vim`](https://github.com/vim/vim/blob/master/runtime/defaults.vim). These are sourced when there is no `.vimrc`, or when you include in your `.vimrc` the following,
```
source $VIMRUNTIME/defaults.vim " Source the defaults
```
Where does Neovim **specify** the ... | The defaults are stored in [`src/nvim/options.lua`](https://github.com/neovim/neovim/blob/master/src/nvim/options.lua)
Which is part of the neovim source code. |
37,199 | <p>For example, we have:</p>
<pre><code>1 this is line. please go to file example.txt for more information.
2 this is line. please go to file demo.txt for more information.
3 this is line. please go to file new.txt for more information.
</code></pre>
<p>Result:</p>
<pre><code>1 this is line 6555. please go ... | [
{
"answer_id": 37200,
"author": "Matt",
"author_id": 22797,
"author_profile": "https://vi.stackexchange.com/users/22797",
"pm_score": 2,
"selected": false,
"text": "<p><code>$VIMRUNTIME/defaults.vim</code> is NOT the defaults. It is a script that changes them. It could be sourced under s... | 2022/04/07 | [
"https://vi.stackexchange.com/questions/37199",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/41623/"
] | For example, we have:
```
1 this is line. please go to file example.txt for more information.
2 this is line. please go to file demo.txt for more information.
3 this is line. please go to file new.txt for more information.
```
Result:
```
1 this is line 6555. please go to file example.txt for more infor... | The defaults are stored in [`src/nvim/options.lua`](https://github.com/neovim/neovim/blob/master/src/nvim/options.lua)
Which is part of the neovim source code. |
37,207 | <p>I have a hotkey that runs python of the first buffer when I press F8 and outputs the outputs to the bottom.</p>
<p>However, this hotkey does not work when I switch buffers... it only works when I am on the first buffer.. Why would this be the case?</p>
<pre><code>nnoremap <buffer> <F8> :! python3 #1<c... | [
{
"answer_id": 37208,
"author": "yh dev",
"author_id": 40607,
"author_profile": "https://vi.stackexchange.com/users/40607",
"pm_score": 0,
"selected": false,
"text": "<p>Ok... removing <code><buffer></code> seems to do the trick...\nI am not sure I had it there in the first place..... | 2022/04/07 | [
"https://vi.stackexchange.com/questions/37207",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/40607/"
] | I have a hotkey that runs python of the first buffer when I press F8 and outputs the outputs to the bottom.
However, this hotkey does not work when I switch buffers... it only works when I am on the first buffer.. Why would this be the case?
```
nnoremap <buffer> <F8> :! python3 #1<cr>
``` | The modifier `<buffer>` means the mapping is only effective for the buffer in which the command was run.
This is heavily used in ftplugins to create local mappings; *e.g.*, you might want `F8` to run `:!python3 %` in python buffers but `:make` in C buffers. You can make a single function that does this and bind it glo... |
37,218 | <p>Lets say there are multiple splits at the following layout. Is it possible to keep the last two placed in their position when the editing area is closed or unloaded from the buffer list, and fill its remaining real estate with void tilde lines.</p>
<pre><code>--------------------------------------------------------
... | [
{
"answer_id": 37219,
"author": "Vivian De Smedt",
"author_id": 23502,
"author_profile": "https://vi.stackexchange.com/users/23502",
"pm_score": 1,
"selected": true,
"text": "<p>I recommend to use the <code>vim-bbye</code> plug-in and the associated <code>:Bd</code> command.</p>\n<p>It u... | 2022/04/08 | [
"https://vi.stackexchange.com/questions/37218",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/36738/"
] | Lets say there are multiple splits at the following layout. Is it possible to keep the last two placed in their position when the editing area is closed or unloaded from the buffer list, and fill its remaining real estate with void tilde lines.
```
--------------------------------------------------------
| ... | I recommend to use the `vim-bbye` plug-in and the associated `:Bd` command.
It unloads the buffer but keep the layout. |
37,246 | <p>Looking for simple and straightforward solution.
I'd like to jump out of parenthesis, bracket, brace, quotes etc while typing in "insert" mode. Obviously following mapping settings in ~/.vimrc work only for angle bracket in the last line:</p>
<pre><code>inoremap <C-j> <Esc>f)a
inoremap <C-j&... | [
{
"answer_id": 37247,
"author": "Mass",
"author_id": 13728,
"author_profile": "https://vi.stackexchange.com/users/13728",
"pm_score": 1,
"selected": false,
"text": "<p>There is a function <code>searchpair</code> which goes to the end of the outer matching pattern. In this case, we can u... | 2022/04/11 | [
"https://vi.stackexchange.com/questions/37246",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/41661/"
] | Looking for simple and straightforward solution.
I'd like to jump out of parenthesis, bracket, brace, quotes etc while typing in "insert" mode. Obviously following mapping settings in ~/.vimrc work only for angle bracket in the last line:
```
inoremap <C-j> <Esc>f)a
inoremap <C-j> <Esc>f]a
inoremap <C-j> <Esc>f}a
inor... | The answer that uses `searchpair()` as provided by user Mass is great in finding the next closing `)`,`]`,`}`, or `>`. However, as `searchpair()` requires the opening and closing characters to be distinct, it cannot be used to find a closing `'` or `"` (eg. `searchpair('"', '', '"', 'W')` will not work).
From the comm... |
37,249 | <p>Let's say I have a file like this</p>
<pre><code>(abc)
(123)
(456)
</code></pre>
<p>I want to yank <code>abc</code> and paste it in place of <code>123</code> and <code>456</code>.
I would <code>yi)</code> on the first line. Then go down a line and paste it with <code>vi)p</code>.
But for the <code>456</code>, vim wi... | [
{
"answer_id": 37251,
"author": "Vivian De Smedt",
"author_id": 23502,
"author_profile": "https://vi.stackexchange.com/users/23502",
"pm_score": 3,
"selected": true,
"text": "<p>The result of the second paste is determined by the first paste that substitute de default register with what ... | 2022/04/11 | [
"https://vi.stackexchange.com/questions/37249",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/26304/"
] | Let's say I have a file like this
```
(abc)
(123)
(456)
```
I want to yank `abc` and paste it in place of `123` and `456`.
I would `yi)` on the first line. Then go down a line and paste it with `vi)p`.
But for the `456`, vim will paste the last visual selected text which is `123` instead of `abc`. The file is now lo... | The result of the second paste is determined by the first paste that substitute de default register with what has been overridden.
The standard solution for that is to include the following mapping in your `.vimrc` file:
`xnoremap p pgvy`
When you paste in visual mode (`x`):
* It select what has been previously sel... |
37,281 | <p>How do I make vim open files in insert mode? I've got the line "startinsert" in my .vimrc, and it does what it's supposed to (vim opens in insert mode), but when I open another file it opens it in command mode. I've played around with autocmd with no luck.Any ideas?</p>
| [
{
"answer_id": 37282,
"author": "Biggybi",
"author_id": 22375,
"author_profile": "https://vi.stackexchange.com/users/22375",
"pm_score": 1,
"selected": false,
"text": "<p>The way you did it, your command is only read and applyied once, when vim starts.</p>\n<p>To get the behaviour you ex... | 2022/04/15 | [
"https://vi.stackexchange.com/questions/37281",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/41722/"
] | How do I make vim open files in insert mode? I've got the line "startinsert" in my .vimrc, and it does what it's supposed to (vim opens in insert mode), but when I open another file it opens it in command mode. I've played around with autocmd with no luck.Any ideas? | The way you did it, your command is only read and applyied once, when vim starts.
To get the behaviour you expect, you need to apply it to each buffer you open.
This can be done with an `:h autocmd`.
For example:
```
augroup OpenEveryBufferInInsertMode
autocmd!
autocmd BufRead,BufEnter * startinsert
augroup... |
37,290 | <p>I have a function like this in <code>autoload/foo/bar.vim</code>:</p>
<pre><code>function! foo#bar#do_stuff(...) abort
" do stuff
return
endfunction
</code></pre>
<p>Is it possible to create an "alias" for this function, without defining a wrapper function and passing args with <code>call()</code>... | [
{
"answer_id": 37291,
"author": "Luc Hermitte",
"author_id": 626,
"author_profile": "https://vi.stackexchange.com/users/626",
"pm_score": 2,
"selected": false,
"text": "<p>May I ask why do you want to address this function through another name?</p>\n<p>If you need an indirection</p>\n<pr... | 2022/04/15 | [
"https://vi.stackexchange.com/questions/37290",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4674/"
] | I have a function like this in `autoload/foo/bar.vim`:
```
function! foo#bar#do_stuff(...) abort
" do stuff
return
endfunction
```
Is it possible to create an "alias" for this function, without defining a wrapper function and passing args with `call()`?
I tried this in `autoload/quux.vim`:
```
let quux#do_stuf... | May I ask why do you want to address this function through another name?
If you need an indirection
```
let SomeRef = function('foo#bar#do_stuff')
```
works correctly. You can define as many variables as you want (that respect Vim naming policy for function-reference variables), but you won't be able to define func... |
37,309 | <p>I notice when I work with larger Mardown files, the syntax highlighting is
broken if I skip around the page. This seems to fix the issue:</p>
<pre><code>syntax sync minlines=999
</code></pre>
<p>but if I put it into my <code>_gvimrc</code>, it doesnt do anything. Is it possible to
save this setting?</p>
| [
{
"answer_id": 37310,
"author": "filbranden",
"author_id": 18609,
"author_profile": "https://vi.stackexchange.com/users/18609",
"pm_score": 0,
"selected": false,
"text": "<p>The issue you're having is that syntax configuration is loaded for specific filetypes in Vim, so you want that cha... | 2022/04/18 | [
"https://vi.stackexchange.com/questions/37309",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/7184/"
] | I notice when I work with larger Mardown files, the syntax highlighting is
broken if I skip around the page. This seems to fix the issue:
```
syntax sync minlines=999
```
but if I put it into my `_gvimrc`, it doesnt do anything. Is it possible to
save this setting? | This seems to do it:
```
let g:markdown_minlines = 999
``` |
37,322 | <p>Want to convert</p>
<pre><code> //comment
abc_def ...
thank_you123 ...
</code></pre>
<p>to</p>
<pre><code> //comment
.abc_def ( abc_def ),
.thank_you123 ( thank_you123 ),
</code></pre>
<p>with single substitute command.<br />
Need to avoid both empty lines and comment lines.<br />
Comment line... | [
{
"answer_id": 37310,
"author": "filbranden",
"author_id": 18609,
"author_profile": "https://vi.stackexchange.com/users/18609",
"pm_score": 0,
"selected": false,
"text": "<p>The issue you're having is that syntax configuration is loaded for specific filetypes in Vim, so you want that cha... | 2022/04/20 | [
"https://vi.stackexchange.com/questions/37322",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/13402/"
] | Want to convert
```
//comment
abc_def ...
thank_you123 ...
```
to
```
//comment
.abc_def ( abc_def ),
.thank_you123 ( thank_you123 ),
```
with single substitute command.
Need to avoid both empty lines and comment lines.
Comment line starts with `//`.
`abc_def` can be a-z, A-Z, 0-... | This seems to do it:
```
let g:markdown_minlines = 999
``` |
37,326 | <p>Is it possible to use vim <em>find and replace</em> to replace a variable with the current filename? for example, fancyFileName.txt contains</p>
<pre><code>this is the VARIABLE to replace in this fancyFileName.txt
</code></pre>
<p>and I am trying to use something like <code>:%s/VARIABLE/expand(%)/</code> to get</p>
... | [
{
"answer_id": 37327,
"author": "Christian Brabandt",
"author_id": 71,
"author_profile": "https://vi.stackexchange.com/users/71",
"pm_score": 1,
"selected": false,
"text": "<p>Assuming you have defined <code>VARIABLE</code> as a global Vim Script variable like this:</p>\n<pre><code>:let ... | 2022/04/20 | [
"https://vi.stackexchange.com/questions/37326",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/11944/"
] | Is it possible to use vim *find and replace* to replace a variable with the current filename? for example, fancyFileName.txt contains
```
this is the VARIABLE to replace in this fancyFileName.txt
```
and I am trying to use something like `:%s/VARIABLE/expand(%)/` to get
```
this is the fancyFileName.txt to replace ... | As pointed out in other answers, `:help sub-replace-special`, and `:help \=`, you can use any expression as the replacement text like so:
```
:%substitute/\<VARIABLE\>/\=expression/g
```
In your case:
```
:%substitute/\<VARIABLE\>/\=expand('%')/g
``` |
37,393 | <p>As title. When running <code>:bn</code> the current buffer will be switched to the next buffer. I want to get the buffer number of this buffer without changing the current buffer(or, at least, can switch back to the starting buffer)</p>
| [
{
"answer_id": 37394,
"author": "Kindred",
"author_id": 41775,
"author_profile": "https://vi.stackexchange.com/users/41775",
"pm_score": 0,
"selected": false,
"text": "<p>It turns out that the naive way works: (answer in Lua)</p>\n<pre class=\"lang-lua prettyprint-override\"><code>vim.cm... | 2022/05/03 | [
"https://vi.stackexchange.com/questions/37393",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/41775/"
] | As title. When running `:bn` the current buffer will be switched to the next buffer. I want to get the buffer number of this buffer without changing the current buffer(or, at least, can switch back to the starting buffer) | I can't fint a build-in solution for this, here is a function using [getbufinfo()](https://vimhelp.org/builtin.txt.html#getbufinfo%28%29) that does not need to actually change buffers:
```
function! Next_buf()
let l:bufs = getbufinfo({'buflisted': 1}
let l:later = filter(l:bufs), 'v:val.bufnr > ' . bufnr())
... |
37,397 | <p>I have neovim 0.8.0 installed.
I have neovim/nvim-lspconfig plugin installed.
I have installed <code>pyright</code> language server on my system (<code>pip install pyright</code>)
I have configured neovim to use the <code>pyright</code> language server.</p>
<p>So now when I open a python file I get some warnings pro... | [
{
"answer_id": 37398,
"author": "Vivian De Smedt",
"author_id": 23502,
"author_profile": "https://vi.stackexchange.com/users/23502",
"pm_score": -1,
"selected": false,
"text": "<p>There are many ways.</p>\n<p>Here is one using <code>Coc.Nvim</code> (<a href=\"https://neoclide/coc.nvim\" ... | 2022/05/03 | [
"https://vi.stackexchange.com/questions/37397",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/6194/"
] | I have neovim 0.8.0 installed.
I have neovim/nvim-lspconfig plugin installed.
I have installed `pyright` language server on my system (`pip install pyright`)
I have configured neovim to use the `pyright` language server.
So now when I open a python file I get some warnings produced by `pyright`. `:LspInfo` command con... | It took some time to figure out what is happening.
**Short answer**: looks like LSP servers do not affect nvim's indentation when you press "Enter" button while editing text. I had to install and properly configure 'nvim-treesitter' plugin to make things work.
**More detailed answer**.
To find out what happens when y... |
37,404 | <p>I am having issues with pasting text from the clipboard into vim (v7.4) on an HPC cluster using Centos, which I have logged into using MTPuTTY. I still get the same error when I'm logging in via MobaXterm.</p>
<p>This is the result of pasting into e.g. sublime text:</p>
<p><a href="https://i.stack.imgur.com/HKftD.pn... | [
{
"answer_id": 37398,
"author": "Vivian De Smedt",
"author_id": 23502,
"author_profile": "https://vi.stackexchange.com/users/23502",
"pm_score": -1,
"selected": false,
"text": "<p>There are many ways.</p>\n<p>Here is one using <code>Coc.Nvim</code> (<a href=\"https://neoclide/coc.nvim\" ... | 2022/05/04 | [
"https://vi.stackexchange.com/questions/37404",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/38195/"
] | I am having issues with pasting text from the clipboard into vim (v7.4) on an HPC cluster using Centos, which I have logged into using MTPuTTY. I still get the same error when I'm logging in via MobaXterm.
This is the result of pasting into e.g. sublime text:
[
``` | This should do the trick:
```lua
vim.api.nvim_create_autocmd({ "BufWritePre" }, {
pattern = { "*" },
command = [[%s/\s\+$//e]],
})
```
Be sure to read the `h:nvim_create_autocmd()` for more info! |
37,422 | <p>I'm not really sure if I should post this as a web browser question (or nginx), but I compose in VIM so here it is!</p>
<p>Because I don't like 8 character tabs in my documents, I set by tabstops to 4, shiftwidth to 4 and turn on autoindent so that when I do bullets things are the way they do them.</p>
<pre><code>se... | [
{
"answer_id": 37426,
"author": "Danathar",
"author_id": 41959,
"author_profile": "https://vi.stackexchange.com/users/41959",
"pm_score": 0,
"selected": false,
"text": "<p>Problem Solved. Seems that the action of posting a stack exchange article was all I needed!</p>\n<p>The answer is to... | 2022/05/07 | [
"https://vi.stackexchange.com/questions/37422",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/41959/"
] | I'm not really sure if I should post this as a web browser question (or nginx), but I compose in VIM so here it is!
Because I don't like 8 character tabs in my documents, I set by tabstops to 4, shiftwidth to 4 and turn on autoindent so that when I do bullets things are the way they do them.
```
set shiftwidth=4
set ... | A tab character is a tab character. Any front-end has to choose how to display it. Your browser will choose to represent `\t` as 8 characters. |
37,424 | <p>I'm trying to write a function to write the contents of the current paragraph the cursor is on to a temp file. In normal more <code>vip:w!temp.txt<cr></code> works fine, but placing <code>normal! vip:w!unidecode.txt<cr></code> within a function doesn't seem to.</p>
<p>Any ideas on a clean way to do this... | [
{
"answer_id": 37425,
"author": "Matt",
"author_id": 22797,
"author_profile": "https://vi.stackexchange.com/users/22797",
"pm_score": 3,
"selected": true,
"text": "<p>The "clean" way is to avoid normal if possible. So simply</p>\n<pre><code>'{,'}write foobar\n</code></pre>\n"
... | 2022/05/07 | [
"https://vi.stackexchange.com/questions/37424",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/9117/"
] | I'm trying to write a function to write the contents of the current paragraph the cursor is on to a temp file. In normal more `vip:w!temp.txt<cr>` works fine, but placing `normal! vip:w!unidecode.txt<cr>` within a function doesn't seem to.
Any ideas on a clean way to do this? | The "clean" way is to avoid normal if possible. So simply
```
'{,'}write foobar
``` |
37,444 | <p>Vim has the concept of actions, which can act on text objects via motions.
For example <code>diw</code> will delete (the action) the inner word (the motion).
I want to create a function that can be applied/executed with those motions. For example, if my function appends to certain register, I can append whatever I w... | [
{
"answer_id": 37447,
"author": "Matt",
"author_id": 22797,
"author_profile": "https://vi.stackexchange.com/users/22797",
"pm_score": 3,
"selected": true,
"text": "<ol>\n<li><p>Scripting language does not matter. The help for mappings is in <code>:h map.txt</code>. Specific topic is <cod... | 2022/05/10 | [
"https://vi.stackexchange.com/questions/37444",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/27445/"
] | Vim has the concept of actions, which can act on text objects via motions.
For example `diw` will delete (the action) the inner word (the motion).
I want to create a function that can be applied/executed with those motions. For example, if my function appends to certain register, I can append whatever I want by doing `... | 1. Scripting language does not matter. The help for mappings is in `:h map.txt`. Specific topic is `:h :map-operator`.
2. There is `g@` normal operator and `opfunc` global string option.
3. In order to perform "custom action" we must
1. Make sure `opfunc` is set to the name of appropriate VimScript callable object;
... |
37,453 | <p>I just moved from Mac to Ubuntu.</p>
<p>I have set everything up but my lua keybindings are following the 0.7 configurations.</p>
<p>When I install neovim on Ubuntu it gives me 0.6.</p>
<p>I tried this:</p>
<pre><code>sudo add-apt-repository ppa:neovim-ppa/stable
sudo apt-get update
sudo apt-get install neovim
</cod... | [
{
"answer_id": 37462,
"author": "D. Ben Knoble",
"author_id": 10604,
"author_profile": "https://vi.stackexchange.com/users/10604",
"pm_score": 3,
"selected": true,
"text": "<p><a href=\"https://packages.ubuntu.com/search?keywords=neovim\" rel=\"nofollow noreferrer\">This page linked from... | 2022/05/11 | [
"https://vi.stackexchange.com/questions/37453",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/41513/"
] | I just moved from Mac to Ubuntu.
I have set everything up but my lua keybindings are following the 0.7 configurations.
When I install neovim on Ubuntu it gives me 0.6.
I tried this:
```
sudo add-apt-repository ppa:neovim-ppa/stable
sudo apt-get update
sudo apt-get install neovim
```
But it still gives me 0.6.
Ho... | [This page linked from the NeoVim readme](https://packages.ubuntu.com/search?keywords=neovim) doesn't yet list 0.7. You might want to try a source build. |
37,469 | <p>Is there script or function for vim to do search of words that is not in proper location (sorry, i don't know how to put it in question) ?</p>
<p>Example:
This is a vim user who like the functionality which is pure manual power.</p>
<p>Question:
I want to search a sentence which contains words "power, vim , fun... | [
{
"answer_id": 37471,
"author": "Mass",
"author_id": 13728,
"author_profile": "https://vi.stackexchange.com/users/13728",
"pm_score": 3,
"selected": false,
"text": "<p>You can use a branch syntax <code>\\&</code>,</p>\n<pre><code>/.*power\\&.*vim\\&.*functionality \n</code></... | 2022/05/14 | [
"https://vi.stackexchange.com/questions/37469",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/30744/"
] | Is there script or function for vim to do search of words that is not in proper location (sorry, i don't know how to put it in question) ?
Example:
This is a vim user who like the functionality which is pure manual power.
Question:
I want to search a sentence which contains words "power, vim , functionality".
I have... | You can use a branch syntax `\&`,
```
/.*power\&.*vim\&.*functionality
```
would find all lines containing all of these three words
Note that the `.*` are necessary as branch attempts to match all parts at the same location. |
37,476 | <p>I have a very large table covering many pages in a document. The same footnote appears under the table on every page and I want to strip the entire document of these lines so I'm left only with the table. Imagine there are 3 footnotes like this:</p>
<pre><code>This is a footnote
Another footnote
Yet another footnote... | [
{
"answer_id": 37471,
"author": "Mass",
"author_id": 13728,
"author_profile": "https://vi.stackexchange.com/users/13728",
"pm_score": 3,
"selected": false,
"text": "<p>You can use a branch syntax <code>\\&</code>,</p>\n<pre><code>/.*power\\&.*vim\\&.*functionality \n</code></... | 2022/05/15 | [
"https://vi.stackexchange.com/questions/37476",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/41978/"
] | I have a very large table covering many pages in a document. The same footnote appears under the table on every page and I want to strip the entire document of these lines so I'm left only with the table. Imagine there are 3 footnotes like this:
```
This is a footnote
Another footnote
Yet another footnote
```
It see... | You can use a branch syntax `\&`,
```
/.*power\&.*vim\&.*functionality
```
would find all lines containing all of these three words
Note that the `.*` are necessary as branch attempts to match all parts at the same location. |
37,484 | <p>I upgraded my mac to Catalina and now the vim syntax looks all off to me. I am sure that strings used to be red, and I think that <code>def</code> used to be turquoise and <code>import</code> was pink. Is there a simple way for me to change the default syntax coloring so that strings are displayed in red text?</p>
... | [
{
"answer_id": 37471,
"author": "Mass",
"author_id": 13728,
"author_profile": "https://vi.stackexchange.com/users/13728",
"pm_score": 3,
"selected": false,
"text": "<p>You can use a branch syntax <code>\\&</code>,</p>\n<pre><code>/.*power\\&.*vim\\&.*functionality \n</code></... | 2022/05/16 | [
"https://vi.stackexchange.com/questions/37484",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/18017/"
] | I upgraded my mac to Catalina and now the vim syntax looks all off to me. I am sure that strings used to be red, and I think that `def` used to be turquoise and `import` was pink. Is there a simple way for me to change the default syntax coloring so that strings are displayed in red text?
[![enter image description he... | You can use a branch syntax `\&`,
```
/.*power\&.*vim\&.*functionality
```
would find all lines containing all of these three words
Note that the `.*` are necessary as branch attempts to match all parts at the same location. |
37,489 | <p>When using the vertical file/folder wild menu (ex: pressing <code>Tab</code> after <code>:e </code> or <code>:cd </code>) and focused on a folder, is there a way to map a key to "move" inside that folder, and pick one of it's children ? If I press <code>Enter</code>, that is considered the "final answ... | [
{
"answer_id": 37491,
"author": "Matt",
"author_id": 22797,
"author_profile": "https://vi.stackexchange.com/users/22797",
"pm_score": 0,
"selected": false,
"text": "<p>By default the same keys are used for both horizontal and vertical menu. That is, <code><Left></code> and <code>&l... | 2022/05/17 | [
"https://vi.stackexchange.com/questions/37489",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/37799/"
] | When using the vertical file/folder wild menu (ex: pressing `Tab` after `:e` or `:cd` ) and focused on a folder, is there a way to map a key to "move" inside that folder, and pick one of it's children ? If I press `Enter`, that is considered the "final answer", and the wildmenu is dismissed. | So after some trial and error, this seems to do the trick:
```
set wildcharm=<C-z>
cnoremap <Right> <Space><BS><Right><C-z>
cnoremap <expr> <Up> pumvisible() ? "\<C-p>" : "\<Up>"
cnoremap <expr> <Down> pumvisible() ? "\<C-n>" : "\<Down>"
```
* `<Up>`/`<Down>` selects the item above/below the currently selected one, ... |
37,520 | <p>I'm trying to have a .vimrc that is portable between machines. Some computers I use have VimPlugin installed, while others don't. On the ones with VimPlug, I'd like to do some setup using <code>call plug#begin</code> and <code>call plug#end</code>. Currently though, I get an error on the computers without VimPlug, a... | [
{
"answer_id": 37500,
"author": "job_start",
"author_id": 10189,
"author_profile": "https://vi.stackexchange.com/users/10189",
"pm_score": 0,
"selected": false,
"text": "<p>It turns out this can fit my requirement:</p>\n<pre class=\"lang-lua prettyprint-override\"><code>vim.cmd("exe... | 2022/05/21 | [
"https://vi.stackexchange.com/questions/37520",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/40845/"
] | I'm trying to have a .vimrc that is portable between machines. Some computers I use have VimPlugin installed, while others don't. On the ones with VimPlug, I'd like to do some setup using `call plug#begin` and `call plug#end`. Currently though, I get an error on the computers without VimPlug, and on those, I'd just lik... | You can use the `\%l` atom to restrict the search to the current cursor line, so in your case you probably want `/<regex>\%.l`
The `.` before the `l` is the shortcut to only search in the cursor line. See [:h /%l](https://vimhelp.org/pattern.txt.html#%2F%5C%25l) |
37,554 | <p>I have a lot of plaintext documentation of many different programming languages I like to browse with vim. My documents look like</p>
<pre><code>w3m -dump https://nodejs.org/dist/latest-v16.x/docs/api/events.html
w3m -dump https://nodejs.org/dist/latest-v16.x/docs/api/http.html
w3m -dump https://nodejs.org/dist/late... | [
{
"answer_id": 37558,
"author": "Maxim Kim",
"author_id": 9333,
"author_profile": "https://vi.stackexchange.com/users/9333",
"pm_score": 1,
"selected": false,
"text": "<p>Not sure if I get the problem right, but with the following mapping I get result in the new tabpage by pressing <code... | 2022/05/26 | [
"https://vi.stackexchange.com/questions/37554",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/32183/"
] | I have a lot of plaintext documentation of many different programming languages I like to browse with vim. My documents look like
```
w3m -dump https://nodejs.org/dist/latest-v16.x/docs/api/events.html
w3m -dump https://nodejs.org/dist/latest-v16.x/docs/api/http.html
w3m -dump https://nodejs.org/dist/latest-v16.x/docs... | So let's brake down what you want to do:
1. open a new tab
2. get the output from a command
3. put that output into the newly opened tab
So in Vim commands, this would be:
1. `:tabnew`
2. `:call system('command')`
3. `:call append(previous output)`
So now, let put this all together into a "single" command, that can... |
37,560 | <p>I'm recently working on a project in vim, and I need to execute the same command in command-line mode multiple times to different files which are in the same folder.
like</p>
<pre><code>:%s/V1/V2/g
</code></pre>
<p>Is there a easiler way to do this?</p>
| [
{
"answer_id": 37561,
"author": "glenn jackman",
"author_id": 1015,
"author_profile": "https://vi.stackexchange.com/users/1015",
"pm_score": 1,
"selected": false,
"text": "<p>Perhaps call out to sed:</p>\n<pre><code>:!sed -i 's/V1/V2/g' %:p:h/*\n</code></pre>\n<p>The last parameter is do... | 2022/05/26 | [
"https://vi.stackexchange.com/questions/37560",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/35388/"
] | I'm recently working on a project in vim, and I need to execute the same command in command-line mode multiple times to different files which are in the same folder.
like
```
:%s/V1/V2/g
```
Is there a easiler way to do this? | Fill up the args list (`:args …`; note there are some nice shorthands so you don’t need to list out every file often) then use `:argdo <cmd>`. There is also `:bufdo`, `:cdo`, and more. This last is particularly handy with `:grep`/`:vimgrep`. |
37,566 | <p>I inserted the program below in both the original vi and nvi. The indented lines are indented using a single tab.</p>
<pre class="lang-c prettyprint-override"><code>#include <stdio.h>
int main(void)
{
puts("Hello world!");
return 0;
}
</code></pre>
<p>When I try to position the cursor on the... | [
{
"answer_id": 37567,
"author": "Matt",
"author_id": 22797,
"author_profile": "https://vi.stackexchange.com/users/22797",
"pm_score": 1,
"selected": false,
"text": "<p>Hard tab is a single character. Eight spaces are displayed on screen but they are not a part of a buffer. Just like thos... | 2022/05/27 | [
"https://vi.stackexchange.com/questions/37566",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/19712/"
] | I inserted the program below in both the original vi and nvi. The indented lines are indented using a single tab.
```c
#include <stdio.h>
int main(void)
{
puts("Hello world!");
return 0;
}
```
When I try to position the cursor on the first column of an indented line (`5G``0`), this is what happens:
[![nvi]... | Hard tab is a single character. Eight spaces are displayed on screen but they are not a part of a buffer. Just like those trailing spaces after line ends.
In Vim if you want the cursor to move through all non-existent chars one by one you have to set `virtualedit` option to "all" value. In nvi, AFAIU, you just can't. |
37,618 | <p>I'm editing my <code>~/.vimrc</code> this weekend, and I've run into a use case that seems to beg that I strip off indentation in an if-block.</p>
<p><em>Broken use-case</em> in my <code>~/.vimrc</code> (with if-block indentation):</p>
<pre><code>if has('python3')
python3 << EOF
# Insert python here
# more p... | [
{
"answer_id": 37619,
"author": "Mike Pennington",
"author_id": 863,
"author_profile": "https://vi.stackexchange.com/users/863",
"pm_score": 0,
"selected": false,
"text": "<blockquote>\n<p>Is there any problem with stripping off indentation inside the if-block for my "Working use-ca... | 2022/06/04 | [
"https://vi.stackexchange.com/questions/37618",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/863/"
] | I'm editing my `~/.vimrc` this weekend, and I've run into a use case that seems to beg that I strip off indentation in an if-block.
*Broken use-case* in my `~/.vimrc` (with if-block indentation):
```
if has('python3')
python3 << EOF
# Insert python here
# more python
# and more python
EOF
endif
```
*Working use... | In the recent vim (I have 8.2.4975) there is a `trim` parameter and following works for me:
```
if has('python3')
py3 << trim PYEND
def hello(world):
print(world)
hello("world")
PYEND
endif
```
I don't know when it was added though.
**UPD** Looks like it is quite old <https://gi... |
37,645 | <p>I use ssh-keys to access the remote git server (e.g. github/gitlab). My ssh-key is protected by a password. Thus when I call a git command with the remote, it will require me to enter the password for my key.</p>
<p>An alternative, is to use an ssh-agent. Within a given shell, I could do</p>
<pre><code>eval `ssh-age... | [
{
"answer_id": 37646,
"author": "clem steredenn",
"author_id": 2170,
"author_profile": "https://vi.stackexchange.com/users/2170",
"pm_score": 0,
"selected": false,
"text": "<p>This does not exactly answers the question as it is, but it provides a work-around.</p>\n<p>In a shell, run</p>\... | 2022/06/08 | [
"https://vi.stackexchange.com/questions/37645",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/2170/"
] | I use ssh-keys to access the remote git server (e.g. github/gitlab). My ssh-key is protected by a password. Thus when I call a git command with the remote, it will require me to enter the password for my key.
An alternative, is to use an ssh-agent. Within a given shell, I could do
```
eval `ssh-agent -s`
ssh-add
```... | I have a little `ssh-reagent` function in my zshrc:
```
# Restart ssh-agent after restarting WM or x11 (may be old env var in tmux).
ssh-reagent() {
export SSH_AUTH_SOCK=$(echo /tmp/ssh-*/agent.*)
ssh-add -l >/dev/null || ssh-add
}
```
This will pick up on any existing ssh-agent processes in `/tmp`; it kind ... |
37,650 | <p>I have a bad habit of deleting some text <code>a</code>, heading off to another section of the document to paste it, and finding something else along the way that I need to delete. When I get to my final destination, where I want to paste the originally deleted text <code>a</code>, it's no longer in the default reg... | [
{
"answer_id": 37651,
"author": "Matt",
"author_id": 22797,
"author_profile": "https://vi.stackexchange.com/users/22797",
"pm_score": 3,
"selected": false,
"text": "<p>"Unnamed" register is not a real one. It's just a pointer. When you delete the text that has more than one lin... | 2022/06/08 | [
"https://vi.stackexchange.com/questions/37650",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/2108/"
] | I have a bad habit of deleting some text `a`, heading off to another section of the document to paste it, and finding something else along the way that I need to delete. When I get to my final destination, where I want to paste the originally deleted text `a`, it's no longer in the default register.
I know that this i... | Here's a script you can put in `~/.vim/plugin/registers.vim` for a command `:Registers` that does `:registers` on all registers matching the commands argument (pattern).
```
if exists('g:registers')
finish
endif
let g:registers = 1
const s:registers = [
\ '"',
\ '0', '1', '2', '3', '4', '5', '6', '7', '... |
37,663 | <p>I've just got the hang of the wonders of <code>:make</code> and the ability to cycle through the errors. Obviously, I have to do a <code>set makeprg</code> with the settings I need and everything is nice, but the problem is that I don't know how to run.</p>
<p>Basically, the problem is that I got used to something l... | [
{
"answer_id": 37665,
"author": "Luc Hermitte",
"author_id": 626,
"author_profile": "https://vi.stackexchange.com/users/626",
"pm_score": 2,
"selected": false,
"text": "<p>At this moment detecting whether the compilation has successfully ended to chain with something else requires script... | 2022/06/09 | [
"https://vi.stackexchange.com/questions/37663",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/2938/"
] | I've just got the hang of the wonders of `:make` and the ability to cycle through the errors. Obviously, I have to do a `set makeprg` with the settings I need and everything is nice, but the problem is that I don't know how to run.
Basically, the problem is that I got used to something like
`:!pushd build && make && ... | Assuming you have the `makeprg` set up correctly:
```
let &l:makeprg = 'cd build && make'
```
The `&l:` syntax for `let` sets local variables; you can also use `setlocal` but then you need to use backslashes, which is annoying.
You can make a command or keybind which 1) runs `:make` or `:makel`, which either popula... |
37,711 | <pre><code>//console.log('not this, since it is not adjancent')
console.log()
// console.log("uncomment this")
// console.log("uncomment this") <-- cursor may be at this at this line for instance
// console.log("uncomment this")
// console.log("uncomment this")
// console.log... | [
{
"answer_id": 37712,
"author": "mattb",
"author_id": 31858,
"author_profile": "https://vi.stackexchange.com/users/31858",
"pm_score": 2,
"selected": false,
"text": "<p>If you're using tpope's <a href=\"https://github.com/tpope/vim-commentary\" rel=\"nofollow noreferrer\">commentary plug... | 2022/06/14 | [
"https://vi.stackexchange.com/questions/37711",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/33463/"
] | ```
//console.log('not this, since it is not adjancent')
console.log()
// console.log("uncomment this")
// console.log("uncomment this") <-- cursor may be at this at this line for instance
// console.log("uncomment this")
// console.log("uncomment this")
// console.log("uncomment this")
console.log()
//console.log('no... | If you're using tpope's [commentary plugin](https://github.com/tpope/vim-commentary), see `:help gcgc` or `:help gcu`:
```
gcgc Uncomment the current and adjacent commented lines.
gcu
```
As pointed out by @D. Ben. Knoble, `gc` is both an operator *and* a text object! So `gc<some motion>` will toggle the comment... |
37,716 | <p>I wrote a function to execute different external commands according to different file types and get the corresponding formatted results:</p>
<pre><code>:function! FileFormat()
let cursorLine = line(".")
let filetype = &filetype
let tab_width = 4
let text = join(getbufline(".",... | [
{
"answer_id": 37721,
"author": "Vivian De Smedt",
"author_id": 23502,
"author_profile": "https://vi.stackexchange.com/users/23502",
"pm_score": 2,
"selected": false,
"text": "<p>The <code>gq</code> family of command reformat a section of the code. For some formatter the only option is t... | 2022/06/15 | [
"https://vi.stackexchange.com/questions/37716",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/42412/"
] | I wrote a function to execute different external commands according to different file types and get the corresponding formatted results:
```
:function! FileFormat()
let cursorLine = line(".")
let filetype = &filetype
let tab_width = 4
let text = join(getbufline(".", 1, "$"), "\n")
let output
i... | The `gq` family of command reformat a section of the code. For some formatter the only option is to format the entire file.
I would suggest to use the `%!` filter pattern that take the entire buffer an input pass it to an external program and replace the buffer content by the output.
You could also combine it with a ... |
37,725 | <p>I like Vim's swap file system and I want to be prepared for the case I forget to :w, reusing this system. I think it's possible if I can change when Vim deletes the swap file, but I could not find the way firstly to stop Vim from deleting it. Do you know how to do it? or any alternative?</p>
| [
{
"answer_id": 37730,
"author": "Zinklestoff",
"author_id": 42167,
"author_profile": "https://vi.stackexchange.com/users/42167",
"pm_score": 1,
"selected": false,
"text": "<p>Set up a cron job to rsync the swap files to another location.</p>\n<p>That being said, I have no idea what you a... | 2022/06/16 | [
"https://vi.stackexchange.com/questions/37725",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/42424/"
] | I like Vim's swap file system and I want to be prepared for the case I forget to :w, reusing this system. I think it's possible if I can change when Vim deletes the swap file, but I could not find the way firstly to stop Vim from deleting it. Do you know how to do it? or any alternative? | ### A few thoughts
As mentioned already, Vim does not *quit without writing* if one does not *explicitly tell Vim* not to. If one say `:q` and there are any open, regular file(s), that is not saved it prompt you to either save or use `:q!` / `:qa!`.
Sometimes one have made changes to a file that one do *not want to s... |
37,731 | <p>I recently upgraded from Unbuntu 18.x to 20.x and I'm trying to compile vim with the following features:</p>
<ul>
<li><code>+lua</code></li>
<li><code>+python</code></li>
<li><code>+python3</code></li>
<li><code>+ruby</code></li>
</ul>
<p>but I haven't been able to get it to go through.</p>
<p>Looking through the ou... | [
{
"answer_id": 37742,
"author": "Christian Brabandt",
"author_id": 71,
"author_profile": "https://vi.stackexchange.com/users/71",
"pm_score": 3,
"selected": true,
"text": "<p>This usually happens, if you do not have the development versions of those interpreters installed. It's not enoug... | 2022/06/16 | [
"https://vi.stackexchange.com/questions/37731",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/14813/"
] | I recently upgraded from Unbuntu 18.x to 20.x and I'm trying to compile vim with the following features:
* `+lua`
* `+python`
* `+python3`
* `+ruby`
but I haven't been able to get it to go through.
Looking through the output, I notice the following lines:
```
checking --enable-fail-if-missing argument... no
checkin... | This usually happens, if you do not have the development versions of those interpreters installed. It's not enough to have those interpreters available, but during the compilation of Vim, the compiler needs to understand the interfaces and structures for including those features. That's why your compilation succeeds wi... |
37,735 | <p>Is it possible to use word under cursor in shell command? Say:</p>
<pre><code>Elvis
^ cursor here
then
:r! echo <word_under_cursor>
</code></pre>
<p>and get "Elvis" read in.</p>
| [
{
"answer_id": 37736,
"author": "Vivian De Smedt",
"author_id": 23502,
"author_profile": "https://vi.stackexchange.com/users/23502",
"pm_score": 3,
"selected": true,
"text": "<p>If you are typing interactively in the vim command line you can hit <kbd>Ctrl</kbd><kbd>r</kbd><kbd>Ctrl</kbd>... | 2022/06/17 | [
"https://vi.stackexchange.com/questions/37735",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/25325/"
] | Is it possible to use word under cursor in shell command? Say:
```
Elvis
^ cursor here
then
:r! echo <word_under_cursor>
```
and get "Elvis" read in. | If you are typing interactively in the vim command line you can hit `Ctrl``r``Ctrl``w` to include the current word or `Ctrl``r``Ctrl``a` to include the current WORD.
If you are writing a function or a command you can use `expand('<cword>')` or `expand('<cWORD>')` for the current WORD version.
Like in:
```
function! ... |
37,756 | <p>Is there a way to control the opened instance of Vim from outside?</p>
<p>Let me clarify, I saw many posts about controlling an external program from Vim by simply executing commands on special key strokes occasions. But what I need is the complete opposite, sending instructions to modify how things look in the cur... | [
{
"answer_id": 37758,
"author": "Vivian De Smedt",
"author_id": 23502,
"author_profile": "https://vi.stackexchange.com/users/23502",
"pm_score": 2,
"selected": false,
"text": "<p>For Vim you can use the <code>--remote-send</code> flag. It takes as an argument the Vim command that you wou... | 2022/06/20 | [
"https://vi.stackexchange.com/questions/37756",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/42464/"
] | Is there a way to control the opened instance of Vim from outside?
Let me clarify, I saw many posts about controlling an external program from Vim by simply executing commands on special key strokes occasions. But what I need is the complete opposite, sending instructions to modify how things look in the currently ope... | For Vim you can use the `--remote-send` flag. It takes as an argument the Vim command that you would like to be executed.
For example:
```
vim --remote-send ":echo 'hello'<CR>"
```
Will echo `hello` into your running Vim.
You can execute any command you would like instead of `:echo` this way.
You can use `--serve... |
37,764 | <p>I'm using msys + vim + ninja + MSVC on windows.</p>
<p>When building, the quickfix list has errors that use the windows path, ie
c:\work\folder\file.cpp</p>
<p>Vim handles it ok-ish, it can open the files, but ideally it should translate those into msys style paths, ie
/c/work/folder/file.cpp</p>
<p>and better yet, ... | [
{
"answer_id": 37758,
"author": "Vivian De Smedt",
"author_id": 23502,
"author_profile": "https://vi.stackexchange.com/users/23502",
"pm_score": 2,
"selected": false,
"text": "<p>For Vim you can use the <code>--remote-send</code> flag. It takes as an argument the Vim command that you wou... | 2022/06/21 | [
"https://vi.stackexchange.com/questions/37764",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/42399/"
] | I'm using msys + vim + ninja + MSVC on windows.
When building, the quickfix list has errors that use the windows path, ie
c:\work\folder\file.cpp
Vim handles it ok-ish, it can open the files, but ideally it should translate those into msys style paths, ie
/c/work/folder/file.cpp
and better yet, I'm in the C:\work fo... | For Vim you can use the `--remote-send` flag. It takes as an argument the Vim command that you would like to be executed.
For example:
```
vim --remote-send ":echo 'hello'<CR>"
```
Will echo `hello` into your running Vim.
You can execute any command you would like instead of `:echo` this way.
You can use `--serve... |
37,784 | <p>I need to save all lines of a terminal buffer into a list after its job finishes asynchronously. I,m opening the terminal buffer like this:</p>
<pre><code> let term_buf_no = term_start(cmd, {'term_name': name, 'term_rows': 10, 'exit_cb': 'ValidateQuickfix'})
</code></pre>
<p>and the function</p>
<pre><code>functio... | [
{
"answer_id": 37758,
"author": "Vivian De Smedt",
"author_id": 23502,
"author_profile": "https://vi.stackexchange.com/users/23502",
"pm_score": 2,
"selected": false,
"text": "<p>For Vim you can use the <code>--remote-send</code> flag. It takes as an argument the Vim command that you wou... | 2022/06/24 | [
"https://vi.stackexchange.com/questions/37784",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/38801/"
] | I need to save all lines of a terminal buffer into a list after its job finishes asynchronously. I,m opening the terminal buffer like this:
```
let term_buf_no = term_start(cmd, {'term_name': name, 'term_rows': 10, 'exit_cb': 'ValidateQuickfix'})
```
and the function
```
function ValidateQuickfix(job, exit_status... | For Vim you can use the `--remote-send` flag. It takes as an argument the Vim command that you would like to be executed.
For example:
```
vim --remote-send ":echo 'hello'<CR>"
```
Will echo `hello` into your running Vim.
You can execute any command you would like instead of `:echo` this way.
You can use `--serve... |
37,813 | <p>I am using vscode + vim. Consider a common scenario where I have to yank/delete some text from one place and replace it with some text anywhere else. But as I need to replace I have to first delete the other text. This results into lost of the previously deleted text.</p>
<p>The solution I thought of it that I can m... | [
{
"answer_id": 37967,
"author": "Vivian De Smedt",
"author_id": 23502,
"author_profile": "https://vi.stackexchange.com/users/23502",
"pm_score": 3,
"selected": true,
"text": "<p>A solution to your use case is to:</p>\n<ol>\n<li>yank the text you want (using the <code>y</code> command)</l... | 2022/06/28 | [
"https://vi.stackexchange.com/questions/37813",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/25893/"
] | I am using vscode + vim. Consider a common scenario where I have to yank/delete some text from one place and replace it with some text anywhere else. But as I need to replace I have to first delete the other text. This results into lost of the previously deleted text.
The solution I thought of it that I can map some k... | A solution to your use case is to:
1. yank the text you want (using the `y` command)
2. select the text you want to replace in visual mode (e.g.: `viw`, `vi"` and their friends)
3. past the text you have copied (using the `p` command)
Remark: If you repeat the operation, because the `"` buffer has been changed to the... |
37,817 | <p>Is there a way to keep the buffer list open so I can select a buffer?</p>
<p>I.e., I do <code>ls</code>, then the buffer list shows up with the 'enter a command or press enter' prompt - I would like to press, for example, :5 <em>but have the buffer list stay visible for this single command</em>.</p>
<p>I'm pretty su... | [
{
"answer_id": 37835,
"author": "r_31415",
"author_id": 210,
"author_profile": "https://vi.stackexchange.com/users/210",
"pm_score": 1,
"selected": false,
"text": "<p>If I understood correctly your question, this is a very popular request and not surprisingly, there is an equally popular... | 2022/06/29 | [
"https://vi.stackexchange.com/questions/37817",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/42550/"
] | Is there a way to keep the buffer list open so I can select a buffer?
I.e., I do `ls`, then the buffer list shows up with the 'enter a command or press enter' prompt - I would like to press, for example, :5 *but have the buffer list stay visible for this single command*.
I'm pretty sure I've had this working before b... | If I understood correctly your question, this is a very popular request and not surprisingly, there is an equally popular mapping for it:
```
nnoremap <Leader>b :ls<CR>:b<Space>
```
(this assumes you already set `mapleader`, but you can change it if you want)
I have set `<Leader>` to `\<space>`, so when I press `Sp... |
37,843 | <p>I have <code>auto_pairs_gentle</code> plugin installed and <code>vim-repeat</code> but the bracket insertion automatically generated by <code>auto_pairs_gentle</code> are not repeated by the dot command.</p>
<p>e.g.: Suppose I insert <code>f(x)</code> by typing <code>if(x<Esc></code> if I repeat the command us... | [
{
"answer_id": 37835,
"author": "r_31415",
"author_id": 210,
"author_profile": "https://vi.stackexchange.com/users/210",
"pm_score": 1,
"selected": false,
"text": "<p>If I understood correctly your question, this is a very popular request and not surprisingly, there is an equally popular... | 2022/06/30 | [
"https://vi.stackexchange.com/questions/37843",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/23502/"
] | I have `auto_pairs_gentle` plugin installed and `vim-repeat` but the bracket insertion automatically generated by `auto_pairs_gentle` are not repeated by the dot command.
e.g.: Suppose I insert `f(x)` by typing `if(x<Esc>` if I repeat the command using the dot command `.` the only things that is inserted is `x` | If I understood correctly your question, this is a very popular request and not surprisingly, there is an equally popular mapping for it:
```
nnoremap <Leader>b :ls<CR>:b<Space>
```
(this assumes you already set `mapleader`, but you can change it if you want)
I have set `<Leader>` to `\<space>`, so when I press `Sp... |
37,888 | <p>I use Ctags and vim to browse by C source code. Quite often than not I am in middle of a long function and want to quickly check the name of the function that the browsing. I use the "{" to jump to the start of the function that I am in and <code>''</code> to jump back to location in the function that I ca... | [
{
"answer_id": 37889,
"author": "Biggybi",
"author_id": 22375,
"author_profile": "https://vi.stackexchange.com/users/22375",
"pm_score": 2,
"selected": false,
"text": "<p>If you don't mind a plugin, <a href=\"https://github.com/wellle/context.vim\" rel=\"nofollow noreferrer\">context.vim... | 2022/07/06 | [
"https://vi.stackexchange.com/questions/37888",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/42671/"
] | I use Ctags and vim to browse by C source code. Quite often than not I am in middle of a long function and want to quickly check the name of the function that the browsing. I use the "{" to jump to the start of the function that I am in and `''` to jump back to location in the function that I came from.
Is there any e... | The simplest solution is to find the first unindented line that starts with a letter (by the way, this is exactly what `diff -p` does).
I'm sure I borrowed this trick somewhere, but I can't remember the origin. Anyway, here it is:
```
" '\p' to show what function we are in (like 'diff -p')
nmap <leader>p <cmd>echo ge... |
37,891 | <p><strong>tl;dr</strong></p>
<p>Is there a Vim plugin that allows me to save/load registers to/from files with minimal typing, preview of registers, and other amenities?</p>
<hr />
<p><strong>Long version</strong></p>
<p>Vim has a lot of registers. However, the "only" ones that serve a "storage" pu... | [
{
"answer_id": 37889,
"author": "Biggybi",
"author_id": 22375,
"author_profile": "https://vi.stackexchange.com/users/22375",
"pm_score": 2,
"selected": false,
"text": "<p>If you don't mind a plugin, <a href=\"https://github.com/wellle/context.vim\" rel=\"nofollow noreferrer\">context.vim... | 2022/07/06 | [
"https://vi.stackexchange.com/questions/37891",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/6498/"
] | **tl;dr**
Is there a Vim plugin that allows me to save/load registers to/from files with minimal typing, preview of registers, and other amenities?
---
**Long version**
Vim has a lot of registers. However, the "only" ones that serve a "storage" purpose are registers `a` to `z`. Indeed
* only the user can edit them... | The simplest solution is to find the first unindented line that starts with a letter (by the way, this is exactly what `diff -p` does).
I'm sure I borrowed this trick somewhere, but I can't remember the origin. Anyway, here it is:
```
" '\p' to show what function we are in (like 'diff -p')
nmap <leader>p <cmd>echo ge... |
37,909 | <p>I am using the following regex to find the first letter of the last word on each line in a file:</p>
<p><code>%s/.* .\zs/</code></p>
<p>I want to now lower case this match on every line in a file. How do I do it?</p>
<p>For eg.</p>
<p>Before: Insomnia Cures</p>
<p>After : Insomnia cures</p>
| [
{
"answer_id": 37889,
"author": "Biggybi",
"author_id": 22375,
"author_profile": "https://vi.stackexchange.com/users/22375",
"pm_score": 2,
"selected": false,
"text": "<p>If you don't mind a plugin, <a href=\"https://github.com/wellle/context.vim\" rel=\"nofollow noreferrer\">context.vim... | 2022/07/09 | [
"https://vi.stackexchange.com/questions/37909",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/42715/"
] | I am using the following regex to find the first letter of the last word on each line in a file:
`%s/.* .\zs/`
I want to now lower case this match on every line in a file. How do I do it?
For eg.
Before: Insomnia Cures
After : Insomnia cures | The simplest solution is to find the first unindented line that starts with a letter (by the way, this is exactly what `diff -p` does).
I'm sure I borrowed this trick somewhere, but I can't remember the origin. Anyway, here it is:
```
" '\p' to show what function we are in (like 'diff -p')
nmap <leader>p <cmd>echo ge... |
37,924 | <p>Once I'm in 'terminal <strong>normal</strong> mode' (where VIM has control on the terminal display), i can't come back to simple 'terminal mode' (where i can write BASH or launch process).</p>
<p>How to leave the "terminal normal mode" (and be able again to write BASH code or launch process...) ?</p>
| [
{
"answer_id": 37889,
"author": "Biggybi",
"author_id": 22375,
"author_profile": "https://vi.stackexchange.com/users/22375",
"pm_score": 2,
"selected": false,
"text": "<p>If you don't mind a plugin, <a href=\"https://github.com/wellle/context.vim\" rel=\"nofollow noreferrer\">context.vim... | 2022/07/11 | [
"https://vi.stackexchange.com/questions/37924",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/42740/"
] | Once I'm in 'terminal **normal** mode' (where VIM has control on the terminal display), i can't come back to simple 'terminal mode' (where i can write BASH or launch process).
How to leave the "terminal normal mode" (and be able again to write BASH code or launch process...) ? | The simplest solution is to find the first unindented line that starts with a letter (by the way, this is exactly what `diff -p` does).
I'm sure I borrowed this trick somewhere, but I can't remember the origin. Anyway, here it is:
```
" '\p' to show what function we are in (like 'diff -p')
nmap <leader>p <cmd>echo ge... |
37,960 | <p>I want to write a simple function that will toggle syntax highlighting, I imagine it'll just be a simple if-else.</p>
<p>Is there a condition I can check? If "syntax is on"?</p>
| [
{
"answer_id": 37964,
"author": "filbranden",
"author_id": 18609,
"author_profile": "https://vi.stackexchange.com/users/18609",
"pm_score": 3,
"selected": true,
"text": "<p>You can use global variable <code>g:syntax_on</code> (more specifically, the existence of such variable) to determi... | 2022/07/14 | [
"https://vi.stackexchange.com/questions/37960",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/42550/"
] | I want to write a simple function that will toggle syntax highlighting, I imagine it'll just be a simple if-else.
Is there a condition I can check? If "syntax is on"? | You can use global variable `g:syntax_on` (more specifically, the existence of such variable) to determine whether syntax highlighting is on or off.
See [`:help g:syntax_on`](https://vimhelp.org/syntax.txt.html#g%3Asyntax_on), which actually even includes an example of a mapping that toggles syntax highlighting:
```
... |
37,995 | <p><code>/\<</code> matches beginning of all words as expected.</p>
<p><code>/\<a</code> matches beginning of all words starting with <code>a</code></p>
<p>but <code>/\<#</code> doesn't match words starting with <code>#</code></p>
<p>what am I missing here?</p>
<p>Was planning on using this search pattern to n... | [
{
"answer_id": 37964,
"author": "filbranden",
"author_id": 18609,
"author_profile": "https://vi.stackexchange.com/users/18609",
"pm_score": 3,
"selected": true,
"text": "<p>You can use global variable <code>g:syntax_on</code> (more specifically, the existence of such variable) to determi... | 2022/07/19 | [
"https://vi.stackexchange.com/questions/37995",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/29128/"
] | `/\<` matches beginning of all words as expected.
`/\<a` matches beginning of all words starting with `a`
but `/\<#` doesn't match words starting with `#`
what am I missing here?
Was planning on using this search pattern to navigate sections in a markdown document. | You can use global variable `g:syntax_on` (more specifically, the existence of such variable) to determine whether syntax highlighting is on or off.
See [`:help g:syntax_on`](https://vimhelp.org/syntax.txt.html#g%3Asyntax_on), which actually even includes an example of a mapping that toggles syntax highlighting:
```
... |
38,003 | <p>I often use UltiSnips for other file types, but for HTML I'd like to use Emmet-vim.</p>
<p>However, I'd like to use the same trigger for both. For this I have</p>
<pre><code>let g:user_emmet_expandabbr_key='<C-j>'
let g:UltiSnipsExpandTrigger='<C-j>'
</code></pre>
<p>in my <code>.vimrc</code>.</p>
<p>Unf... | [
{
"answer_id": 38005,
"author": "Vivian De Smedt",
"author_id": 23502,
"author_profile": "https://vi.stackexchange.com/users/23502",
"pm_score": 0,
"selected": false,
"text": "<p>I propose you the following:</p>\n<pre><code>let g:UltiSnipsExpandTrigger='<C-F11>'\nlet g:user_emmet_e... | 2022/07/20 | [
"https://vi.stackexchange.com/questions/38003",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/42835/"
] | I often use UltiSnips for other file types, but for HTML I'd like to use Emmet-vim.
However, I'd like to use the same trigger for both. For this I have
```
let g:user_emmet_expandabbr_key='<C-j>'
let g:UltiSnipsExpandTrigger='<C-j>'
```
in my `.vimrc`.
Unfortunately, it seems that by assigning the same trigger to ... | Following the suggestion of @MartinTournoij
```
let g:UltiSnipsExpandTrigger='<C-F12>'
let g:user_emmet_expandabbr_key='<C-S-F12>'
function! IsEmmet(filetype)
echom a:filetype
if a:filetype == 'html'
return v:true
endif
if a:filetype == 'css'
return v:true
endif
return v:false
endf
imap <expr>... |
38,018 | <p>I often need to access a machine-generated file. This file is always in the same folder, and is created each day with a timestamp, e.g. <code>$HOME/foo/bar/target-2022-07-21.txt</code>.</p>
<p>Currently I use <code>fzf</code> to open the file once a day (then use buffer navigation or set a mark to jump to it the res... | [
{
"answer_id": 38019,
"author": "Vivian De Smedt",
"author_id": 23502,
"author_profile": "https://vi.stackexchange.com/users/23502",
"pm_score": 3,
"selected": true,
"text": "<p>You can use the command:</p>\n<pre><code>:execute "e $HOME/foo/bar/target-" . strftime("%Y-%m-%... | 2022/07/21 | [
"https://vi.stackexchange.com/questions/38018",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/8427/"
] | I often need to access a machine-generated file. This file is always in the same folder, and is created each day with a timestamp, e.g. `$HOME/foo/bar/target-2022-07-21.txt`.
Currently I use `fzf` to open the file once a day (then use buffer navigation or set a mark to jump to it the rest of the day), but I'd like to ... | You can use the command:
```
:execute "e $HOME/foo/bar/target-" . strftime("%Y-%m-%d") . ".txt"
```
If you like you can create a custom command for it:
```
:command! OpenTarget execute "e $HOME/foo/bar/target-" . strftime("%Y-%m-%d") . ".txt"
```
Or map it to a keystroke:
```
nnoremap <C-s> :execute "e $HOME/foo... |
38,047 | <p>I know that plugin that can do it almost certainly exists. Or maybe I could use something like LSP for this. But I want to make my simple command, that will go to file with definition of component / function / class in JS. It's not difficult, because in JS all imports are explicitly, so I wrote this command in my .v... | [
{
"answer_id": 38062,
"author": "Matt",
"author_id": 22797,
"author_profile": "https://vi.stackexchange.com/users/22797",
"pm_score": 1,
"selected": false,
"text": "<ol>\n<li>Save cursor position into <code>:h 'quote</code> mark. For example,</li>\n</ol>\n<blockquote>\n<p>~/.vim/after/ft... | 2022/07/25 | [
"https://vi.stackexchange.com/questions/38047",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/42898/"
] | I know that plugin that can do it almost certainly exists. Or maybe I could use something like LSP for this. But I want to make my simple command, that will go to file with definition of component / function / class in JS. It's not difficult, because in JS all imports are explicitly, so I wrote this command in my .vimr... | Try this:
```
nnoremap gd m':keepjumps normal!gd$Bgf<CR>:noh<CR>
```
`:keepjumps` allows you to perform command-line commands without changing the jumplist, but your mapping uses normal-mode commands and searches. You can run normal-mode commands from the command-line with the `:normal` command, and then you can app... |
38,059 | <p>I want to modify the first word of each line: remove underscore character and capitalize the next character.</p>
<h3>Input:</h3>
<pre><code> word_example_one other_words ...
word_example_two other_words ...
word_example_three other_words ...
</code></pre>
<h3>Expected output:</h3>
<pre><code> wordE... | [
{
"answer_id": 38062,
"author": "Matt",
"author_id": 22797,
"author_profile": "https://vi.stackexchange.com/users/22797",
"pm_score": 1,
"selected": false,
"text": "<ol>\n<li>Save cursor position into <code>:h 'quote</code> mark. For example,</li>\n</ol>\n<blockquote>\n<p>~/.vim/after/ft... | 2022/07/26 | [
"https://vi.stackexchange.com/questions/38059",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/13402/"
] | I want to modify the first word of each line: remove underscore character and capitalize the next character.
### Input:
```
word_example_one other_words ...
word_example_two other_words ...
word_example_three other_words ...
```
### Expected output:
```
wordExampleOne other_words ...
wordE... | Try this:
```
nnoremap gd m':keepjumps normal!gd$Bgf<CR>:noh<CR>
```
`:keepjumps` allows you to perform command-line commands without changing the jumplist, but your mapping uses normal-mode commands and searches. You can run normal-mode commands from the command-line with the `:normal` command, and then you can app... |
38,077 | <p>I want to make more use of <code>fF</code> to navigate, but find the <code>f</code> to be clumsy. Eg. jump to "a" is <code>fa</code>.</p>
<p>Instead, I'd like <code>aaa</code> to map to <code>fa</code>, <code>bbb</code>to map to <code>fb</code> etc.</p>
<p>Is there an easy way to do this other than lots of... | [
{
"answer_id": 38079,
"author": "Luc Hermitte",
"author_id": 626,
"author_profile": "https://vi.stackexchange.com/users/626",
"pm_score": 2,
"selected": false,
"text": "<p>Something like</p>\n<pre><code>for c in ['a', 'b' ......]\n exe "noremap " . repeat(c, 3) . " f&qu... | 2022/07/27 | [
"https://vi.stackexchange.com/questions/38077",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/21422/"
] | I want to make more use of `fF` to navigate, but find the `f` to be clumsy. Eg. jump to "a" is `fa`.
Instead, I'd like `aaa` to map to `fa`, `bbb`to map to `fb` etc.
Is there an easy way to do this other than lots of `:nmap aaa fa`?
I'm all in on Neovim, so lua solutions are ok.
Alternative approaches also welcome. | You can do this with a loop:
```
for c in range(97, 122)
for offset in [0, 32]
let key = nr2char(c - offset)
execute "nnoremap " .. repeat(key, 3) .. " f" .. key
endfor
endfor
```
Personally, I would find this unusable, though, as now every normal-mode command you issue will have a delay while Vim waits ... |
38,090 | <p>I want to write a function which allows me to execute different movement commands using the same key pressed repeatedly. So, I wrote a function <code>Jumptails</code> and mapped it to the key <code><End></code>. The first time I press <code><End></code> it jumps to the end of line (<code>$</code>), next ... | [
{
"answer_id": 38091,
"author": "Rich",
"author_id": 343,
"author_profile": "https://vi.stackexchange.com/users/343",
"pm_score": 2,
"selected": false,
"text": "<p>An interesting idea!</p>\n<h2>The problem</h2>\n<p>It's not really possible to implement your mapping <em>in the way you sug... | 2022/07/28 | [
"https://vi.stackexchange.com/questions/38090",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/42939/"
] | I want to write a function which allows me to execute different movement commands using the same key pressed repeatedly. So, I wrote a function `Jumptails` and mapped it to the key `<End>`. The first time I press `<End>` it jumps to the end of line (`$`), next to the end of the visible window (`L`) and finally to the e... | An interesting idea!
The problem
-----------
It's not really possible to implement your mapping *in the way you suggest*.
Vim only stores the last executed command internally (for use with the dot
command), and even then, motions are not stored anywhere. It's possible to
knock something up that allows you to track th... |
38,094 | <p>This is the current state of my autocmds.vim file.</p>
<pre><code>" Option for specific filetypes
autocmd BufRead,BufNewFile *.md setlocal textwidth=80 spell spelllang=en_gb
autocmd BufRead,BufNewFile *.txt setlocal textwidth=80 spell s... | [
{
"answer_id": 38096,
"author": "Vivian De Smedt",
"author_id": 23502,
"author_profile": "https://vi.stackexchange.com/users/23502",
"pm_score": 1,
"selected": false,
"text": "<p>I believe your autocmd miss à command:</p>\n<pre><code>" yaml\naugroup filetype_yaml\n autocmd!\n auto... | 2022/07/28 | [
"https://vi.stackexchange.com/questions/38094",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/37532/"
] | This is the current state of my autocmds.vim file.
```
" Option for specific filetypes
autocmd BufRead,BufNewFile *.md setlocal textwidth=80 spell spelllang=en_gb
autocmd BufRead,BufNewFile *.txt setlocal textwidth=80 spell spelllang=en_gb ... | The syntax for defining an autocmd is:
```
autocmd [event-list] [pattern] [commands]
```
Where [event-list] is a comma-separated list of events, the [pattern] is what to apply it to (what exactly it matches depends on the event(s), but it's often the filename), and [commands] is one or more commands; where multiple ... |
38,102 | <p>Here is what I use for indentation:</p>
<pre><code>set autoindent
set breakindent
set expandtab
set smarttab
set shiftround
set shiftwidth=2 softtabstop=-1 " or maybe shiftwidth=2 softtabstop=8
" https://vi.stackexchange.com/a/15557
inoremap <tab> <c-v><tab>
</code></pre>
<p>When I pres... | [
{
"answer_id": 38110,
"author": "Matt",
"author_id": 22797,
"author_profile": "https://vi.stackexchange.com/users/22797",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n<ol>\n<li>When I press >>, it will indent code with 2 spaces</li>\n</ol>\n</blockquote>\n<pre><code>set... | 2022/07/29 | [
"https://vi.stackexchange.com/questions/38102",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/7200/"
] | Here is what I use for indentation:
```
set autoindent
set breakindent
set expandtab
set smarttab
set shiftround
set shiftwidth=2 softtabstop=-1 " or maybe shiftwidth=2 softtabstop=8
" https://vi.stackexchange.com/a/15557
inoremap <tab> <c-v><tab>
```
When I press >>, this indents my code 2 spaces; and when I pres... | As you described in your question, and [as Matt confirmed in his answer](https://vi.stackexchange.com/a/38110/343), you cannot do this using only Vim's options.
We are, therefore, going to have to set up a mapping. There are several ways you could go about this, but here's how I'd do it:
```
set shiftwidth=2 softtabs... |
38,116 | <p>I am using Putty on Windows to connect to a Linux server.</p>
<p>On the Linux server I am using vim to edit code files.</p>
<p>I am using my mouse to select an area to copy and then right click to paste the copied code.</p>
<p>So far I am aware of 2 settings that alter this copy/paste behaviour:</p>
<ul>
<li>:set pa... | [
{
"answer_id": 38110,
"author": "Matt",
"author_id": 22797,
"author_profile": "https://vi.stackexchange.com/users/22797",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n<ol>\n<li>When I press >>, it will indent code with 2 spaces</li>\n</ol>\n</blockquote>\n<pre><code>set... | 2022/07/30 | [
"https://vi.stackexchange.com/questions/38116",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/42962/"
] | I am using Putty on Windows to connect to a Linux server.
On the Linux server I am using vim to edit code files.
I am using my mouse to select an area to copy and then right click to paste the copied code.
So far I am aware of 2 settings that alter this copy/paste behaviour:
* :set paste
* :set autoindent
**Sample... | As you described in your question, and [as Matt confirmed in his answer](https://vi.stackexchange.com/a/38110/343), you cannot do this using only Vim's options.
We are, therefore, going to have to set up a mapping. There are several ways you could go about this, but here's how I'd do it:
```
set shiftwidth=2 softtabs... |
38,121 | <p>I need a text editor for universal use and I decided that vim has the such potential. Vim is great software, but I as a new user find it difficult to get into, but I am determined to use it.
The only way I can use vim is through custom keybinds. I want to go for the windows generic keybinds since I am very used to i... | [
{
"answer_id": 38110,
"author": "Matt",
"author_id": 22797,
"author_profile": "https://vi.stackexchange.com/users/22797",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n<ol>\n<li>When I press >>, it will indent code with 2 spaces</li>\n</ol>\n</blockquote>\n<pre><code>set... | 2022/07/30 | [
"https://vi.stackexchange.com/questions/38121",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/42966/"
] | I need a text editor for universal use and I decided that vim has the such potential. Vim is great software, but I as a new user find it difficult to get into, but I am determined to use it.
The only way I can use vim is through custom keybinds. I want to go for the windows generic keybinds since I am very used to it. ... | As you described in your question, and [as Matt confirmed in his answer](https://vi.stackexchange.com/a/38110/343), you cannot do this using only Vim's options.
We are, therefore, going to have to set up a mapping. There are several ways you could go about this, but here's how I'd do it:
```
set shiftwidth=2 softtabs... |
38,146 | <p>In vim, there is a way to yank between two quotations by using <code>yi'</code>. And there is a way to yank between two square brackets by using <code>yi]</code>.</p>
<p>I want to do this between two <code>##</code>:</p>
<pre><code>some_text
## Point #1 --> Copy this
some_code --> Copy this (cursor here)
so... | [
{
"answer_id": 38150,
"author": "Al-Baraa El-Hag",
"author_id": 30308,
"author_profile": "https://vi.stackexchange.com/users/30308",
"pm_score": 0,
"selected": false,
"text": "<p>I got it, I used this <a href=\"https://thevaluable.dev/vim-create-text-objects/\" rel=\"nofollow noreferrer\... | 2022/08/01 | [
"https://vi.stackexchange.com/questions/38146",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/30308/"
] | In vim, there is a way to yank between two quotations by using `yi'`. And there is a way to yank between two square brackets by using `yi]`.
I want to do this between two `##`:
```
some_text
## Point #1 --> Copy this
some_code --> Copy this (cursor here)
some_code2 --> Copy this
## Point #2
```
Also, I would li... | I think your approach is correct, but some tweaks might be needed:
```
function! BlockCopy(pattern)
call search('^' .. a:pattern, 'cbW')
normal! 0V
let l:bottom = search('^' .. a:pattern, 'nW')
if l:bottom == 0
normal! G
call search('.', 'cb')
else
execute l:bottom-1
en... |
38,147 | <p>Lets say I have a buffer with the following content:</p>
<pre><code><property name="sfgiusfgsnffgdsb" value="arbitraryvalue1"/>
<property name="sfsergggsnfgdfgs" value="arbitraryvalue2"/>
<property name="sfggdsssgdshsdhg" value="arbitraryvalue3&qu... | [
{
"answer_id": 38150,
"author": "Al-Baraa El-Hag",
"author_id": 30308,
"author_profile": "https://vi.stackexchange.com/users/30308",
"pm_score": 0,
"selected": false,
"text": "<p>I got it, I used this <a href=\"https://thevaluable.dev/vim-create-text-objects/\" rel=\"nofollow noreferrer\... | 2022/08/01 | [
"https://vi.stackexchange.com/questions/38147",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/42996/"
] | Lets say I have a buffer with the following content:
```
<property name="sfgiusfgsnffgdsb" value="arbitraryvalue1"/>
<property name="sfsergggsnfgdfgs" value="arbitraryvalue2"/>
<property name="sfggdsssgdshsdhg" value="arbitraryvalue3"/>
<property name="sfgisdfggngsdfgf" value="arbitraryvalue4"/>
<property name="sfgsdg... | I think your approach is correct, but some tweaks might be needed:
```
function! BlockCopy(pattern)
call search('^' .. a:pattern, 'cbW')
normal! 0V
let l:bottom = search('^' .. a:pattern, 'nW')
if l:bottom == 0
normal! G
call search('.', 'cb')
else
execute l:bottom-1
en... |
38,191 | <p>Normally, if you add something like</p>
<pre><code>set setting+=value
</code></pre>
<p>into your .vimrc, the value will be appended to the existing ones. For example:</p>
<pre><code>set formatoptions+=j " => tcqj
</code></pre>
<p>However, it seems it doesn't work the same for status line.</p>
<pre><code>set... | [
{
"answer_id": 38193,
"author": "romainl",
"author_id": 54,
"author_profile": "https://vi.stackexchange.com/users/54",
"pm_score": 4,
"selected": true,
"text": "<p>By default, <code>:help 'statusline'</code> is empty and Vim uses a hardcoded routine to fill the status line. When it is no... | 2022/08/07 | [
"https://vi.stackexchange.com/questions/38191",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/7169/"
] | Normally, if you add something like
```
set setting+=value
```
into your .vimrc, the value will be appended to the existing ones. For example:
```
set formatoptions+=j " => tcqj
```
However, it seems it doesn't work the same for status line.
```
set statusline=2
set statusline+=\ %{&filetype}
for the javascrip... | By default, `:help 'statusline'` is empty and Vim uses a hardcoded routine to fill the status line. When it is non-empty, the hardcoded value is ignored, leaving you with a blank slate.
When you do any of the following, you effectively set `statusline` to a non-empty value which makes the hardcoded one disappear:
```... |
38,192 | <p>I have <code>set spelllang=en_us,ru_ru</code> in my .vimrc, and when I enable spell check by typing <code>:set spell</code>, Vim shows me a pop-up window that says that the dictionary for the second language is not installed.</p>
<p><a href="https://i.stack.imgur.com/RAmlQ.png" rel="nofollow noreferrer"><img src="ht... | [
{
"answer_id": 38193,
"author": "romainl",
"author_id": 54,
"author_profile": "https://vi.stackexchange.com/users/54",
"pm_score": 4,
"selected": true,
"text": "<p>By default, <code>:help 'statusline'</code> is empty and Vim uses a hardcoded routine to fill the status line. When it is no... | 2022/08/07 | [
"https://vi.stackexchange.com/questions/38192",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/7200/"
] | I have `set spelllang=en_us,ru_ru` in my .vimrc, and when I enable spell check by typing `:set spell`, Vim shows me a pop-up window that says that the dictionary for the second language is not installed.
[](https://i.stack.imgur.com/RAmlQ.png)
Yes, m... | By default, `:help 'statusline'` is empty and Vim uses a hardcoded routine to fill the status line. When it is non-empty, the hardcoded value is ignored, leaving you with a blank slate.
When you do any of the following, you effectively set `statusline` to a non-empty value which makes the hardcoded one disappear:
```... |
38,246 | <p>I try arrange settings in my .vimrc in the exact order and by using the same sectioning as if you click "Edit" (in the menu) and then "Settings Window".</p>
<p>There is problem that when I arrange settings in such a way, some of them don't work properly. For example:</p>
<pre><code>" 5. Synt... | [
{
"answer_id": 38243,
"author": "Martin Tournoij",
"author_id": 51,
"author_profile": "https://vi.stackexchange.com/users/51",
"pm_score": 5,
"selected": false,
"text": "<p>The <code>+</code> and <code>*</code> registers can be used to access the clipboard; and you can assign values to r... | 2022/08/11 | [
"https://vi.stackexchange.com/questions/38246",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/7169/"
] | I try arrange settings in my .vimrc in the exact order and by using the same sectioning as if you click "Edit" (in the menu) and then "Settings Window".
There is problem that when I arrange settings in such a way, some of them don't work properly. For example:
```
" 5. Syntax, highlighting and spelling
let &colorcolu... | I’m going to go ahead and infer from your use of the word “select”, that you yanked via visual mode.
If that’s the case, then you can use `gv` to reselect the previous selection. You can then yank to the clipboard as usual `"+y`. |
38,303 | <pre><code>Paragraph 1.
Paragraph 2.
Paragraph 3.
Paragraph 4.
</code></pre>
<p>Here is how <code>}</code> and <code>{</code> currently work for me:</p>
<ol>
<li>Put the cursor on the <code>P</code> of the 2nd paragraph.</li>
<li>Press <code>}</code>. The cursor will jump to the position between paragraphs 2 and 3.<... | [
{
"answer_id": 38305,
"author": "Vivian De Smedt",
"author_id": 23502,
"author_profile": "https://vi.stackexchange.com/users/23502",
"pm_score": 1,
"selected": false,
"text": "<p>I understand that you would like that the paragraph starts after a empty line.\nAnd that in presence of multi... | 2022/08/17 | [
"https://vi.stackexchange.com/questions/38303",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/7169/"
] | ```
Paragraph 1.
Paragraph 2.
Paragraph 3.
Paragraph 4.
```
Here is how `}` and `{` currently work for me:
1. Put the cursor on the `P` of the 2nd paragraph.
2. Press `}`. The cursor will jump to the position between paragraphs 2 and 3.
3. Press `}` again. The cursor will jump to the position between paragraphs 3... | Does the default Vim behaviour make sense? I guess that depends on your preferences. One downside of your proposed behaviour is that something like `d}` will now delete the first line of the next paragraph too, and visually selecting paragraphs with `v}}` is harder, as it will select the first line of the next paragrap... |
38,318 | <p>For example, if I do:</p>
<pre><code>% vim file
:tabedit one
:split two
</code></pre>
<p>I end up with two tabs, and one tab with two windows.</p>
<p>How can I get the active window of the second tab? My goal is to get a list of all tabs with the currently active window/buffer, and should work in any context (i.e. n... | [
{
"answer_id": 38324,
"author": "Cydmium",
"author_id": 22394,
"author_profile": "https://vi.stackexchange.com/users/22394",
"pm_score": 0,
"selected": false,
"text": "<p>I am not aware of a native method for doing this with :e/:e!, but it is doable with a new user command.</p>\n<p>Since... | 2022/08/18 | [
"https://vi.stackexchange.com/questions/38318",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/51/"
] | For example, if I do:
```
% vim file
:tabedit one
:split two
```
I end up with two tabs, and one tab with two windows.
How can I get the active window of the second tab? My goal is to get a list of all tabs with the currently active window/buffer, and should work in any context (i.e. not just when that tab is activ... | Possibly I’m misunderstanding you, but I’m going to ignore most of your question and focus on this part which I *think* describes your main goal?
>
> I open a new buffer, play with it for a bit, and then want to discard it to edit an actual file. I can't close the buffer without quitting the whole editor
>
>
>
Yo... |
38,344 | <p>For using the terminal while working with Rust. I've added this config (NVIM) (TTerm one).</p>
<pre><code>if has('nvim')
command Ter vsplit term://zsh
command Tter tabe term://zsh
else
command Terminal vert term
command TerminalTab tab ter
endif
</code></pre>
<p>It opens the terminal in a different t... | [
{
"answer_id": 38345,
"author": "3N4N",
"author_id": 16280,
"author_profile": "https://vi.stackexchange.com/users/16280",
"pm_score": 4,
"selected": true,
"text": "<p>(This answer pertains to neovim specifically. If you find anything conflicting with vim, let me know and I'll edit the an... | 2022/08/21 | [
"https://vi.stackexchange.com/questions/38344",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/43240/"
] | For using the terminal while working with Rust. I've added this config (NVIM) (TTerm one).
```
if has('nvim')
command Ter vsplit term://zsh
command Tter tabe term://zsh
else
command Terminal vert term
command TerminalTab tab ter
endif
```
It opens the terminal in a different tab as expected. Normally... | (This answer pertains to neovim specifically. If you find anything conflicting with vim, let me know and I'll edit the answer.)
`:h term` operates in a separate mode: the terminal model. It's somewhat like the insert mode in that you have to `ESC` out of it before you can go into command-line mode with `:` key. Only t... |
38,351 | <p>I started writing a help file for various vim commands that I know I'll forget.
<a href="https://i.stack.imgur.com/HwFV1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HwFV1.png" alt="external file sf-search.txt" /></a></p>
<p>Over the last 7+ years it's grown to ~1600 lines and is starting to be... | [
{
"answer_id": 38354,
"author": "Martin Tournoij",
"author_id": 51,
"author_profile": "https://vi.stackexchange.com/users/51",
"pm_score": 2,
"selected": false,
"text": "<p>The way Vim looks up the references in helpfiles is through a <code>tags</code> file which records where each tag i... | 2022/08/22 | [
"https://vi.stackexchange.com/questions/38351",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1313/"
] | I started writing a help file for various vim commands that I know I'll forget.
[](https://i.stack.imgur.com/HwFV1.png)
Over the last 7+ years it's grown to ~1600 lines and is starting to become unwieldy
I've been trying to split it into one file per ... | I can see a handful of potential problems here.
In rough order of the likelihood that they are what's breaking things for you. I'm trying to cover all the possibilities, so apologies for anything that you are already aware of in the below:
Tag naming consistency
----------------------
In your screenshots, it looks a... |
38,368 | <p>I am writing my .tex files in vim and have automatic linebreaks at 80 characters. I would like the linebreak to automatically perform a concatenation <code>J</code> if there is text below it, so that I don't get the following output:</p>
<pre><code>This line gets line-broken. This line gets line-broken. This line ge... | [
{
"answer_id": 38369,
"author": "Vivian De Smedt",
"author_id": 23502,
"author_profile": "https://vi.stackexchange.com/users/23502",
"pm_score": 3,
"selected": true,
"text": "<p>A solution to review the paragraph you are in is:</p>\n<pre><code>gqip\n</code></pre>\n<p>Where:</p>\n<ul>\n<l... | 2022/08/24 | [
"https://vi.stackexchange.com/questions/38368",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/43284/"
] | I am writing my .tex files in vim and have automatic linebreaks at 80 characters. I would like the linebreak to automatically perform a concatenation `J` if there is text below it, so that I don't get the following output:
```
This line gets line-broken. This line gets line-broken. This line gets
line-broken.
This lin... | A solution to review the paragraph you are in is:
```
gqip
```
Where:
* `gq` reformat them according to `textwidth`
* `ip` current paragraph
If you want that to be made for all paragraph while they are edited a solution, as mentioned by @Ben, is to have `a` within `formatoptions`
```
setlocal formatoptions+=a
``... |
38,385 | <p>What are the commands to move to the very beginning and to move the last non-whitespace character of the current visual line?
Do they exist at all?</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th></th>
<th>Commands for normal lines</th>
<th>Commands for visual lines</th>
</tr>
</thead>
<... | [
{
"answer_id": 38398,
"author": "karlh",
"author_id": 42581,
"author_profile": "https://vi.stackexchange.com/users/42581",
"pm_score": 3,
"selected": true,
"text": "<p>g0 moves to the very beginning of the visual line, whereas g^ moves to the first non-whitespace character on the current... | 2022/08/25 | [
"https://vi.stackexchange.com/questions/38385",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/7169/"
] | What are the commands to move to the very beginning and to move the last non-whitespace character of the current visual line?
Do they exist at all?
| | Commands for normal lines | Commands for visual lines |
| --- | --- | --- |
| To move to the very beginning of a current line | `0` | ? |
| To move to the very end of... | g0 moves to the very beginning of the visual line, whereas g^ moves to the first non-whitespace character on the current visual line. (At least, that's what the help file says and that's what it does for me.)
g$ and g<End> seem to do the same thing; g0 and g<Home> also do the same thing.
I don't think there is an equ... |
38,407 | <p>I'd like to copy these to a file, but in a speculative future case,
I might want to delete them. I might need to find a regex to substitute
intervening data with a single blank line.</p>
<p>The highlighting shows it's matching a multiline block but <code>global</code>
<code>yank</code> only gets the first line in th... | [
{
"answer_id": 38409,
"author": "Vivian De Smedt",
"author_id": 23502,
"author_profile": "https://vi.stackexchange.com/users/23502",
"pm_score": 0,
"selected": false,
"text": "<p>The problem you have is that <code>g</code> command applies on all the lines even if it has been part of a pr... | 2022/08/29 | [
"https://vi.stackexchange.com/questions/38407",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/43320/"
] | I'd like to copy these to a file, but in a speculative future case,
I might want to delete them. I might need to find a regex to substitute
intervening data with a single blank line.
The highlighting shows it's matching a multiline block but `global`
`yank` only gets the first line in the block.
These blocks can cont... | Problem 1: How `:global` interacts with multiline matches
---------------------------------------------------------
The main problem that you're seeing is that you're slightly misunderstanding how `:global` works. It *doesn't* run the commands on the matched text. Instead, it runs the commands on *the lines where a ma... |
38,438 | <p>I use Vim with two keyboard layouts, English and Russian, and to be able to use Vim commands irrespective to the current layout, I have the following snippet in my .vimrc:</p>
<pre><code>" To switch between keyboard layouts, use Control+^ or Control+Space
if g:os ==# 'Darwin'
set keymap=russian-jcukenmac
... | [
{
"answer_id": 38409,
"author": "Vivian De Smedt",
"author_id": 23502,
"author_profile": "https://vi.stackexchange.com/users/23502",
"pm_score": 0,
"selected": false,
"text": "<p>The problem you have is that <code>g</code> command applies on all the lines even if it has been part of a pr... | 2022/09/01 | [
"https://vi.stackexchange.com/questions/38438",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/7169/"
] | I use Vim with two keyboard layouts, English and Russian, and to be able to use Vim commands irrespective to the current layout, I have the following snippet in my .vimrc:
```
" To switch between keyboard layouts, use Control+^ or Control+Space
if g:os ==# 'Darwin'
set keymap=russian-jcukenmac
elseif g:os ==# 'L... | Problem 1: How `:global` interacts with multiline matches
---------------------------------------------------------
The main problem that you're seeing is that you're slightly misunderstanding how `:global` works. It *doesn't* run the commands on the matched text. Instead, it runs the commands on *the lines where a ma... |
38,456 | <p>I would like to try out some fancy plugins, debug my own configuration and plugins, try out new neovim versions. But I do want to keep my daily used nvim stable (with fixed set of settings and plugins), I do not want to test them out in my normal home dir. I wonder if there is a way to provide me this convenience li... | [
{
"answer_id": 38457,
"author": "Rich",
"author_id": 343,
"author_profile": "https://vi.stackexchange.com/users/343",
"pm_score": 0,
"selected": false,
"text": "<p>For regular Vim, <a href=\"https://vi.stackexchange.com/a/6114/343\">muru's suggestion of running with a different <code>$HO... | 2022/09/05 | [
"https://vi.stackexchange.com/questions/38456",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/43416/"
] | I would like to try out some fancy plugins, debug my own configuration and plugins, try out new neovim versions. But I do want to keep my daily used nvim stable (with fixed set of settings and plugins), I do not want to test them out in my normal home dir. I wonder if there is a way to provide me this convenience like ... | Specifically, Neovim supports `:h xdg` set of directories. That is, you need to do something like
```
MYCFG=~/foo
export XDG_CONFIG_HOME=$MYCFG/config
export XDG_DATA_HOME=$MYCFG/data
export XDG_CACHE_HOME=$MYCFG/data
export XDG_STATE_HOME=$MYCFG/data
# this is for temporary files, so better to leave as is
#export XD... |
38,462 | <p>In many cases, I have to replace a line by another in multiple places.</p>
<p>I can yank my desired line, go do the replacement location, do a <code>pdd</code>, move on, and of course I don't have the same line available for pasting.</p>
<p>Is there a better way of doing this?</p>
| [
{
"answer_id": 38466,
"author": "D. Ben Knoble",
"author_id": 10604,
"author_profile": "https://vi.stackexchange.com/users/10604",
"pm_score": 2,
"selected": false,
"text": "<p>Assuming you grabbed the first line with a <code>y</code> command, it should be in register 0. So you can do <c... | 2022/09/06 | [
"https://vi.stackexchange.com/questions/38462",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/2938/"
] | In many cases, I have to replace a line by another in multiple places.
I can yank my desired line, go do the replacement location, do a `pdd`, move on, and of course I don't have the same line available for pasting.
Is there a better way of doing this? | Assuming you grabbed the first line with a `y` command, it should be in register 0. So you can do `"0pdd` every time (or, `let @q = '"0pdd'` and run `@q`/`@@` for slightly less typing).
If the target lines are all in the same buffer as the original line, you can use a command like
```
:[from line]copy [to line] | [to... |
38,490 | <p>Say I have <a href="https://github.com/junegunn/vim-plug" rel="nofollow noreferrer">vim-plug</a> installed</p>
<p>But before calling <code>call plug#begin()</code>, I want to check if this function exists</p>
<p>How to perform this check?</p>
<p>I tried the following:</p>
<pre><code>echom empty(g:plug)
echom empty(p... | [
{
"answer_id": 38491,
"author": "D. Ben Knoble",
"author_id": 10604,
"author_profile": "https://vi.stackexchange.com/users/10604",
"pm_score": 3,
"selected": true,
"text": "<p>For a function specifically, you can write</p>\n<pre><code>if exists('*funcname')\n …\nendif\n</code></pre>\n<p... | 2022/09/09 | [
"https://vi.stackexchange.com/questions/38490",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/43480/"
] | Say I have [vim-plug](https://github.com/junegunn/vim-plug) installed
But before calling `call plug#begin()`, I want to check if this function exists
How to perform this check?
I tried the following:
```
echom empty(g:plug)
echom empty(plug)
echom empty(plug#begin)
```
But all of the above led to an "Undefined va... | For a function specifically, you can write
```
if exists('*funcname')
…
endif
```
(that would be `exists('*plug#begin')` here). More generally, see the documentation for `:help exists()`. |
38,521 | <p>I have installed nvim using scoop on two Windows 11 systems. The installation works fine on my laptop (Surface Laptop 3). On my desktop, when I run <code>git commit</code> with nvim set as my editor, the terminal (Powershell or cmd) is in black and white (see images below). The problem persists with or without my lu... | [
{
"answer_id": 38491,
"author": "D. Ben Knoble",
"author_id": 10604,
"author_profile": "https://vi.stackexchange.com/users/10604",
"pm_score": 3,
"selected": true,
"text": "<p>For a function specifically, you can write</p>\n<pre><code>if exists('*funcname')\n …\nendif\n</code></pre>\n<p... | 2022/09/14 | [
"https://vi.stackexchange.com/questions/38521",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/43537/"
] | I have installed nvim using scoop on two Windows 11 systems. The installation works fine on my laptop (Surface Laptop 3). On my desktop, when I run `git commit` with nvim set as my editor, the terminal (Powershell or cmd) is in black and white (see images below). The problem persists with or without my lua config (whic... | For a function specifically, you can write
```
if exists('*funcname')
…
endif
```
(that would be `exists('*plug#begin')` here). More generally, see the documentation for `:help exists()`. |
38,523 | <p>I'm working on some HTML files that are formatted weirdly. Each individual class is on a separate line which makes the file (imo) difficult to read.</p>
<p>Something like:</p>
<pre><code><div class="
classA
classB
classC
" id="xxx">
</code></pre>
<p>I would like to use a macro that do... | [
{
"answer_id": 38524,
"author": "Vivian De Smedt",
"author_id": 23502,
"author_profile": "https://vi.stackexchange.com/users/23502",
"pm_score": 1,
"selected": false,
"text": "<p>One solution would be to install the <a href=\"https://github.com/kana/vim-textobj-user\" rel=\"nofollow nore... | 2022/09/14 | [
"https://vi.stackexchange.com/questions/38523",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/42942/"
] | I'm working on some HTML files that are formatted weirdly. Each individual class is on a separate line which makes the file (imo) difficult to read.
Something like:
```
<div class="
classA
classB
classC
" id="xxx">
```
I would like to use a macro that does the following:
1. find the next occurence of `class=... | *(N.B. I'm not sure if by "macro" you mean a mapping or a recording, so I've just included the keystrokes in the below, to match what you did in your question.)*
It might not work in general, but for the specific example given, you can use a regular search: `/``"``Enter``v``n``J` |
38,528 | <p>More in general I'm always in doubt about what's the meaning of the <code>{aupat}</code> argument of <code>autocmd</code> for a given <code>{event}</code>.</p>
<p>From <code>:help :autocmd</code> I read (my emphasis)</p>
<blockquote>
<p>Add {cmd} to the list of commands that Vim will execute automatically on {event}... | [
{
"answer_id": 38530,
"author": "romainl",
"author_id": 54,
"author_profile": "https://vi.stackexchange.com/users/54",
"pm_score": 3,
"selected": true,
"text": "<p>Those things are easy to test with <code>:help <amatch></code>:</p>\n<pre><code>autocmd! CmdWinLeave * echomsg expand(... | 2022/09/14 | [
"https://vi.stackexchange.com/questions/38528",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/6498/"
] | More in general I'm always in doubt about what's the meaning of the `{aupat}` argument of `autocmd` for a given `{event}`.
From `:help :autocmd` I read (my emphasis)
>
> Add {cmd} to the list of commands that Vim will execute automatically on {event} **for a file matching {aupat} autocmd-patterns**.
>
>
>
So fro... | Those things are easy to test with `:help <amatch>`:
```
autocmd! CmdWinLeave * echomsg expand('<amatch>')
```
Where you use a wildcard to catch every possible case and echo `<amatch>` in the messages.
You get `:` when leaving `q:` and `/` when leaving `q/`, which lets you know what `{aupat}` to use in your autocom... |
38,543 | <p>Today I had that old feeling of wonder on how powerful VIM is: I needed a number sequence in the start of some fields and <a href="https://vim.fandom.com/wiki/Making_a_list_of_numbers" rel="nofollow noreferrer">discovered the power of g CTRL-A</a>.</p>
<p>So as I always do when I discover something new in VIM I trie... | [
{
"answer_id": 38544,
"author": "MDeBusk",
"author_id": 42263,
"author_profile": "https://vi.stackexchange.com/users/42263",
"pm_score": 3,
"selected": false,
"text": "<p>You're looking at the help for <code>g_CTRL-A</code> in <em>normal</em> mode, but when you're incrementing a list of ... | 2022/09/16 | [
"https://vi.stackexchange.com/questions/38543",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/5944/"
] | Today I had that old feeling of wonder on how powerful VIM is: I needed a number sequence in the start of some fields and [discovered the power of g CTRL-A](https://vim.fandom.com/wiki/Making_a_list_of_numbers).
So as I always do when I discover something new in VIM I tried to find exactly what this command does, but ... | >
> But the question remains: what does g CTRL-A on normal mode does ? What's a memory profile ? Anyone knows ?
>
>
>
This refers to [this bit of code](https://github.com/vim/vim/blob/c8ac3a072f18d4b250e55e91f610fe517e218777/src/feature.h#L651-L654) from `src/feature.h`:
```
/*
* MEM_PROFILE Debugging of me... |
38,555 | <p>How to remove 2 characters from the beginning of a string after using filename-modifiers?
So assume that I have a files that looks like this:</p>
<pre><code>/home/drskoolie/projects/examples/ex40.c
/home/drskoolie/projects/examples/ex1.c
</code></pre>
<p>What I want is to get the number 40 and 1 out of the file nam... | [
{
"answer_id": 38566,
"author": "D. Ben Knoble",
"author_id": 10604,
"author_profile": "https://vi.stackexchange.com/users/10604",
"pm_score": 1,
"selected": false,
"text": "<p>Any of the following would work with your specific examples:</p>\n<pre><code>:echo expand('%:p:t:r')->matchs... | 2022/09/17 | [
"https://vi.stackexchange.com/questions/38555",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/30308/"
] | How to remove 2 characters from the beginning of a string after using filename-modifiers?
So assume that I have a files that looks like this:
```
/home/drskoolie/projects/examples/ex40.c
/home/drskoolie/projects/examples/ex1.c
```
What I want is to get the number 40 and 1 out of the file names respectively using fi... | Any of the following would work with your specific examples:
```
:echo expand('%:p:t:r')->matchstr('\d\+$')
:echo expand('%:p:t:r')->trim('ex', 1) " the third direction argument might be new?
:echo expand('%:p:t:r')[2:]
``` |
38,558 | <p>I'm using neovim v0.8.0 (nightly build) on Arch Linux.</p>
<p>When in my <code>plugins.lua</code> where I have all my nvim plugins listed, I want to be able to use <code>gX</code> to open <code>user/repo</code> in my browser as <code>https://github.com/user/repo</code>.</p>
<p>Since the plugins are not listed as ful... | [
{
"answer_id": 38694,
"author": "husB",
"author_id": 21495,
"author_profile": "https://vi.stackexchange.com/users/21495",
"pm_score": 0,
"selected": false,
"text": "<p>As mentioned in the comments, you can put the contents with <code><C-r>{register}</code>. Thus, the RHS of the map... | 2022/09/17 | [
"https://vi.stackexchange.com/questions/38558",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/25859/"
] | I'm using neovim v0.8.0 (nightly build) on Arch Linux.
When in my `plugins.lua` where I have all my nvim plugins listed, I want to be able to use `gX` to open `user/repo` in my browser as `https://github.com/user/repo`.
Since the plugins are not listed as full URLs, I can't use the normal `gx`. I know they're always ... | It is not necessary to yank your path first. You can use `<C-r><C-f>`
instead:
```
CTRL-R CTRL-F *c_CTRL-R_CTRL-F* *c_<C-R>_<C-F>*
CTRL-F the Filename under the cursor
``` |
38,602 | <p>In my vimrc I have:</p>
<pre><code>set backupdir=~/.cache/vim/backup |call mkdir(&backupdir, 'p', 0o700)
set undodir=~/.cache/vim/undo |call mkdir(&undodir, 'p', 0o700)
</code></pre>
<p>This stores a backup file in <code>~/.cache/vim/backup</code> on every write, which is useful if I accidentally remov... | [
{
"answer_id": 38603,
"author": "Martin Tournoij",
"author_id": 51,
"author_profile": "https://vi.stackexchange.com/users/51",
"pm_score": 0,
"selected": false,
"text": "<p>The best way I could figure out is (abusing) the <code>backupext</code> setting for this:</p>\n<pre><code>au BufWri... | 2022/09/20 | [
"https://vi.stackexchange.com/questions/38602",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/51/"
] | In my vimrc I have:
```
set backupdir=~/.cache/vim/backup |call mkdir(&backupdir, 'p', 0o700)
set undodir=~/.cache/vim/undo |call mkdir(&undodir, 'p', 0o700)
```
This stores a backup file in `~/.cache/vim/backup` on every write, which is useful if I accidentally remove something, or remove something that I end... | If you look into `:h 'backupdir'`, you will find in the description:
```
- For Unix and Win32, if a directory ends in two path separators "//",
the backup file name will be built from the complete path to the
file with all path separators changed to percent '%' signs. This
will ensure file name u... |
38,623 | <p>Quite often I copy or remove content inside brackets <code>d%</code> or <code>y%</code>.</p>
<pre><code>MyAwesomeClass(
///content
)
</code></pre>
<p>But this way I get:</p>
<pre><code>(
///content
)
</code></pre>
<p>Is there a way to copy word in front of the bracket too? So that the copied result is:</p>
<pr... | [
{
"answer_id": 38625,
"author": "mattb",
"author_id": 31858,
"author_profile": "https://vi.stackexchange.com/users/31858",
"pm_score": 3,
"selected": true,
"text": "<h2>Vim only solution</h2>\n<p>The simplest thing for the example you posted is probably to use visual\nlinewise mode - <co... | 2022/09/22 | [
"https://vi.stackexchange.com/questions/38623",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/30700/"
] | Quite often I copy or remove content inside brackets `d%` or `y%`.
```
MyAwesomeClass(
///content
)
```
But this way I get:
```
(
///content
)
```
Is there a way to copy word in front of the bracket too? So that the copied result is:
```
MyAwesomeClass(
///content
)
``` | Vim only solution
-----------------
The simplest thing for the example you posted is probably to use visual
linewise mode - `va)V`will first select the content and the surrounding
parenthesis (but not the word in front) and the final `V` will switch to
linewise mode (thus additionally selecting everything before/after... |
38,642 | <p>Whenever I do undo and redo in vim, I saw this output, the #number changes.. but what is it ? Where to see the #number .. ?</p>
<p>Also, I find it hard to know what. I have accidentally changed or undo sometime. Hence I have to keep undo and redo, until I am sure what is the correct status before I dare to write the... | [
{
"answer_id": 38644,
"author": "Vivian De Smedt",
"author_id": 23502,
"author_profile": "https://vi.stackexchange.com/users/23502",
"pm_score": 0,
"selected": false,
"text": "<p>May be the following plugin: <a href=\"https://github.com/mbbill/undotree\" rel=\"nofollow noreferrer\">undot... | 2022/09/24 | [
"https://vi.stackexchange.com/questions/38642",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/30744/"
] | Whenever I do undo and redo in vim, I saw this output, the #number changes.. but what is it ? Where to see the #number .. ?
Also, I find it hard to know what. I have accidentally changed or undo sometime. Hence I have to keep undo and redo, until I am sure what is the correct status before I dare to write the buffer, ... | Vim keeps track of the operations we perform as a list of changes. From `:h :undolist`:
```
:undol[ist] List the leafs in the tree of changes. Example:
number changes when saved ~
88 88 2010/01/04 14:25:53
108 107 08/07 12:47:51
... |
38,671 | <p>I'm aware of <code>:help variable-scope</code>, which describes the following:</p>
<pre><code>buffer-variable b: Local to the current buffer.
window-variable w: Local to the current window.
tabpage-variable t: Local to the current tab page.
global-variable g: Global.
local-variable l: Local to a ... | [
{
"answer_id": 38689,
"author": "3N4N",
"author_id": 16280,
"author_profile": "https://vi.stackexchange.com/users/16280",
"pm_score": 3,
"selected": true,
"text": "<p>All the lualine readme is stating is that <em>lualine</em> supports variables from those scopes. It doesn't mean that n/v... | 2022/09/26 | [
"https://vi.stackexchange.com/questions/38671",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/16613/"
] | I'm aware of `:help variable-scope`, which describes the following:
```
buffer-variable b: Local to the current buffer.
window-variable w: Local to the current window.
tabpage-variable t: Local to the current tab page.
global-variable g: Global.
local-variable l: Local to a function.
script-variabl... | All the lualine readme is stating is that *lualine* supports variables from those scopes. It doesn't mean that n/vim has those variable scopes. n/vim has only the scopes mentioned in `:h variable-scopes` and nvim provides some options, e.g., `:h vim.o`, `:h vim.go`, and `:h vim.bo`, and `:h vim.wo` (see `:h lua-vim-opt... |
38,676 | <p>I used to use <code>gvimfullscreen.dll</code> to toggle a full screen window state on gvim for Windows. It made gvim full screen, not maximised, with no titlebar.</p>
<p>I have not used gvim on Windows for some time until recently and it's no longer working for me. The many mentions of this file I have found on the ... | [
{
"answer_id": 38689,
"author": "3N4N",
"author_id": 16280,
"author_profile": "https://vi.stackexchange.com/users/16280",
"pm_score": 3,
"selected": true,
"text": "<p>All the lualine readme is stating is that <em>lualine</em> supports variables from those scopes. It doesn't mean that n/v... | 2022/09/27 | [
"https://vi.stackexchange.com/questions/38676",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/37532/"
] | I used to use `gvimfullscreen.dll` to toggle a full screen window state on gvim for Windows. It made gvim full screen, not maximised, with no titlebar.
I have not used gvim on Windows for some time until recently and it's no longer working for me. The many mentions of this file I have found on the internet are old and... | All the lualine readme is stating is that *lualine* supports variables from those scopes. It doesn't mean that n/vim has those variable scopes. n/vim has only the scopes mentioned in `:h variable-scopes` and nvim provides some options, e.g., `:h vim.o`, `:h vim.go`, and `:h vim.bo`, and `:h vim.wo` (see `:h lua-vim-opt... |