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
38,705
<p>I am trying to remap the line-completion command (<code>^X^L</code>) to the simpler <code>^L</code> (or <code>Ctrl-L</code>, or <code>&lt;C-L&gt;</code>). VIM's help (see <code>:h ins-completion</code>) suggests the following :</p> <pre><code>:inoremap ^L ^X^L </code></pre> <p>I tried adding this to my <code>.vimrc<...
[ { "answer_id": 38706, "author": "Feffe", "author_id": 7128, "author_profile": "https://vi.stackexchange.com/users/7128", "pm_score": 0, "selected": false, "text": "<p>I was &quot;naively&quot; copy-pasting the remapping line, which did not properly input the keys as wanted.</p>\n<p>To pr...
2022/09/29
[ "https://vi.stackexchange.com/questions/38705", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/7128/" ]
I am trying to remap the line-completion command (`^X^L`) to the simpler `^L` (or `Ctrl-L`, or `<C-L>`). VIM's help (see `:h ins-completion`) suggests the following : ``` :inoremap ^L ^X^L ``` I tried adding this to my `.vimrc`, but so far pressing Ctrl-L in insert mode only inserts "^L" at the cursor's position.
Those keys are intended to be control characters, which are some of the special keys in Vim. As you have mentioned, `^X`, `^L`, are meant to represent `Ctrl-x` and `Ctrl-l` respectively. \* There is an alternative angle bracket notation, which is documented in `:h key-notation` and `:h <>`. This notation is used in vi...
38,708
<p>Is there a Vim regex to delete all leading blank lines in the file?</p> <pre><code> text more text some more text </code></pre> <p>Should become:</p> <pre><code>text more text some more text </code></pre>
[ { "answer_id": 38709, "author": "Vivian De Smedt", "author_id": 23502, "author_profile": "https://vi.stackexchange.com/users/23502", "pm_score": 4, "selected": true, "text": "<p>The following should do the job:</p>\n<pre><code>:%s/\\%^\\_\\s*\\n//\n</code></pre>\n<p>Here is an explanatio...
2022/09/30
[ "https://vi.stackexchange.com/questions/38708", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/43126/" ]
Is there a Vim regex to delete all leading blank lines in the file? ``` text more text some more text ``` Should become: ``` text more text some more text ```
The following should do the job: ``` :%s/\%^\_\s*\n// ``` Here is an explanation: * `\%^` match the beginning of the file * `\_\s` match any space character including new line * `*` repeat the match * `\n` match the last new line I include the `\n` to not match the leading space on the first non white-space line (...
38,713
<p>It seems that the QuickFix window is created on the bottom of the upmost right vertical split.</p> <p>If I start with two splits:</p> <p><a href="https://i.stack.imgur.com/qq4dl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qq4dl.png" alt="two buffer splits" /></a></p> <p>When I open the QuickFi...
[ { "answer_id": 38716, "author": "Matt", "author_id": 22797, "author_profile": "https://vi.stackexchange.com/users/22797", "pm_score": 3, "selected": true, "text": "<pre><code>bot copen\n</code></pre>\n<p>Don't have anything to add to it.</p>\n" }, { "answer_id": 38726, "autho...
2022/09/30
[ "https://vi.stackexchange.com/questions/38713", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/23502/" ]
It seems that the QuickFix window is created on the bottom of the upmost right vertical split. If I start with two splits: [![two buffer splits](https://i.stack.imgur.com/qq4dl.png)](https://i.stack.imgur.com/qq4dl.png) When I open the QuickFix window (`:copen`) the QuickFix windows is created as a horizontal split ...
``` bot copen ``` Don't have anything to add to it.
38,722
<p>I'm a little confused. Is <code>vim.cmd</code> just a shorthand for <code>vim.api.nvim_command</code> or are they used for different things?</p>
[ { "answer_id": 38723, "author": "Mass", "author_id": 13728, "author_profile": "https://vi.stackexchange.com/users/13728", "pm_score": 1, "selected": false, "text": "<p><code>vim.cmd(·)</code> is the same as <code>vim.api.nvim_exec(·, false)</code> when passed a string. However, when pas...
2022/09/30
[ "https://vi.stackexchange.com/questions/38722", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/41143/" ]
I'm a little confused. Is `vim.cmd` just a shorthand for `vim.api.nvim_command` or are they used for different things?
`vim.cmd(command)` calls either of these two lua APIs: * `vim.api.nvim_cmd`: when `command` is a table * `vim.api.nvim_exec`: when `command` is a string [The lua code for `vim.cmd`](https://github.com/neovim/neovim/blob/afb7efb3733962649f3c0897a25dc5fff60a66c6/runtime/lua/vim/_editor.lua#L335-L368): ```lua vim.cmd =...
38,748
<p>The use case is to copy citations from pdf files to markdown documents in vim. I'd create a dotted list of important copied text and then I'd like to replace the end of line hyphenation that appears in the copy text as such</p> <pre><code>- &quot;bla bla bla bla bla bla bla bla bla bla, ex- cept bla bla bla bla bla...
[ { "answer_id": 38735, "author": "Vivian De Smedt", "author_id": 23502, "author_profile": "https://vi.stackexchange.com/users/23502", "pm_score": 3, "selected": true, "text": "<p>You could do the replace in two steps:</p>\n<ol>\n<li>You prepare a search command using <code>*</code> (<code...
2022/10/03
[ "https://vi.stackexchange.com/questions/38748", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/6671/" ]
The use case is to copy citations from pdf files to markdown documents in vim. I'd create a dotted list of important copied text and then I'd like to replace the end of line hyphenation that appears in the copy text as such ``` - "bla bla bla bla bla bla bla bla bla bla, ex- cept bla bla bla bla bla bla bla bla bla b...
You could do the replace in two steps: 1. You prepare a search command using `*` (`/\<the\>`) 2. You do your replace with an empty search (`:%s//the only/g`) The replace will default the search to the last one. It has the advantage over the `Ctrl``r``Ctrl``w` trick that the word boundary are included in the search. ...
38,768
<p>I'm using a vim script to quickly edit some text. I have a large list from an api endpoint that looks like this:</p> <pre><code> save: presets.api + 'campaign/:campaignId/settings', accept: presets.api + 'campaign/:campaignId/acceptContractTerms', list: presets.api ...
[ { "answer_id": 38769, "author": "3N4N", "author_id": 16280, "author_profile": "https://vi.stackexchange.com/users/16280", "pm_score": 2, "selected": false, "text": "<p>If it's given that only one single-quoted text will appear in a line, then the regex is simple:</p>\n<pre><code>%s:\\v.{...
2022/10/04
[ "https://vi.stackexchange.com/questions/38768", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/43337/" ]
I'm using a vim script to quickly edit some text. I have a large list from an api endpoint that looks like this: ``` save: presets.api + 'campaign/:campaignId/settings', accept: presets.api + 'campaign/:campaignId/acceptContractTerms', list: presets.api + 'campaign/:...
It's arguably even easier to do this *without* regular expressions, by using the [`:normal`](https://vimhelp.org/various.txt.html#%3Anormal) command. To delete the text on one line you would type: `d``f``'``;``D`, which deletes to the first quote (`df'`), moves to the next quote (`;`), and then deletes the rest of the ...
38,774
<p>I have a couple of plugins which use Python. They work fine on Linux but on Windows I am having difficulty in getting Python recognised.</p> <pre><code>&quot; Language Providers if has('unix') let g:python3_host_prog = '/usr/bin/python3' elseif has('win32') let g:python3_host_prog = 'C:\Program Files\Python37\py...
[ { "answer_id": 38769, "author": "3N4N", "author_id": 16280, "author_profile": "https://vi.stackexchange.com/users/16280", "pm_score": 2, "selected": false, "text": "<p>If it's given that only one single-quoted text will appear in a line, then the regex is simple:</p>\n<pre><code>%s:\\v.{...
2022/10/05
[ "https://vi.stackexchange.com/questions/38774", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/37532/" ]
I have a couple of plugins which use Python. They work fine on Linux but on Windows I am having difficulty in getting Python recognised. ``` " Language Providers if has('unix') let g:python3_host_prog = '/usr/bin/python3' elseif has('win32') let g:python3_host_prog = 'C:\Program Files\Python37\python.exe' endif `...
It's arguably even easier to do this *without* regular expressions, by using the [`:normal`](https://vimhelp.org/various.txt.html#%3Anormal) command. To delete the text on one line you would type: `d``f``'``;``D`, which deletes to the first quote (`df'`), moves to the next quote (`;`), and then deletes the rest of the ...
38,783
<p>I have a <code>syn match</code> item like this:</p> <pre><code>syn match txr_num &quot;[+\-]\?\([0-9]\|[0-9][,0-9]*[0-9]\)\?[.]\([0-9]\|[0-9][,0-9]*[0-9]\)\([eE][+\-]\?[0-9]\+\)\?&quot; </code></pre> <p>Given an input like <code>1.234e13</code> it matches only one digit after the decimal point, causing only <code>1....
[ { "answer_id": 38784, "author": "Matt", "author_id": 22797, "author_profile": "https://vi.stackexchange.com/users/22797", "pm_score": 2, "selected": false, "text": "<p>Obviously, this is your bug.</p>\n<p>Why so? Well, let's suppose we have input of <code>12.34</code>. The &quot;left&quo...
2022/10/06
[ "https://vi.stackexchange.com/questions/38783", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/13611/" ]
I have a `syn match` item like this: ``` syn match txr_num "[+\-]\?\([0-9]\|[0-9][,0-9]*[0-9]\)\?[.]\([0-9]\|[0-9][,0-9]*[0-9]\)\([eE][+\-]\?[0-9]\+\)\?" ``` Given an input like `1.234e13` it matches only one digit after the decimal point, causing only `1.2` to be colored, regardless of what combination of digits, c...
Obviously, this is your bug. Why so? Well, let's suppose we have input of `12.34`. The "left" expression could match "one" only, but then it can't match "dot". So the engine steps back and re-matches "twelve" and then also "dot" successfully. Then "right" expression matches "three" and... that's all. No one will care ...
38,796
<p>If I'm anywhere on a line that contains e.g.:</p> <pre><code>[text1](link to text1) </code></pre> <p>How do I cut from <code>[</code> to <code>)</code> ?</p>
[ { "answer_id": 38802, "author": "Vivian De Smedt", "author_id": 23502, "author_profile": "https://vi.stackexchange.com/users/23502", "pm_score": 1, "selected": false, "text": "<p>This command copy the first Markdown link of the current line:</p>\n<pre><code>exe 's/\\[.*)/&amp;/' | norm g...
2022/10/07
[ "https://vi.stackexchange.com/questions/38796", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/43834/" ]
If I'm anywhere on a line that contains e.g.: ``` [text1](link to text1) ``` How do I cut from `[` to `)` ?
I'd just do this in normal mode: `0``f``[``d``f``)`. If this is something you're doing a lot, then you could create a mapping: ``` :nnoremap <leader>d 0f[df) ``` But once you're going that far, you probably want something a bit more sophisticated, such as a [custom text object](https://stackoverflow.com/q/73912649/...
38,798
<p>I am trying to write a command that changes author lists of the form</p> <pre><code>R. L. Rivest, A. Shamir, and L. Adleman </code></pre> <p>Into one nice for BibTeX, namely:</p> <pre><code>Rivest, R. L. and Shamir, A. and Adleman, L </code></pre> <p>I have figured out how to do it in two commands:</p> <pre><code>&q...
[ { "answer_id": 38800, "author": "jhoran", "author_id": 43780, "author_profile": "https://vi.stackexchange.com/users/43780", "pm_score": 2, "selected": true, "text": "<p>The following command works on a single line. The command itself would need some refinement but it works. You may adapt...
2022/10/07
[ "https://vi.stackexchange.com/questions/38798", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/43833/" ]
I am trying to write a command that changes author lists of the form ``` R. L. Rivest, A. Shamir, and L. Adleman ``` Into one nice for BibTeX, namely: ``` Rivest, R. L. and Shamir, A. and Adleman, L ``` I have figured out how to do it in two commands: ``` " This command will split the names so they are one per l...
The following command works on a single line. The command itself would need some refinement but it works. You may adapt it into a range function or a range command. ``` s/,\? and \|, \|$/,/g | s/\(.\{-}\) \(\S\+\(,\|$\)\)/\2 \1 and/g | s/ and$// | s/ and/ and\r/g ``` And a multiline command: ``` '<,'>s/\n/,/g | s/,...
38,828
<p>How can I convert a column of words (one word per line) to a paragraph using vim?</p> <p>For example, before:</p> <pre><code>how to convert </code></pre> <p>After:</p> <pre><code>how to convert </code></pre>
[ { "answer_id": 38829, "author": "Maxim Kim", "author_id": 9333, "author_profile": "https://vi.stackexchange.com/users/9333", "pm_score": 1, "selected": false, "text": "<p>Visually select a range of words and press <code>J</code> to join them:</p>\n<ol>\n<li>select 3 lines and <code>J</co...
2022/10/10
[ "https://vi.stackexchange.com/questions/38828", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/43874/" ]
How can I convert a column of words (one word per line) to a paragraph using vim? For example, before: ``` how to convert ``` After: ``` how to convert ```
With fairly default settings, `gqip` or `gwip` should do the trick. This applies the `gq` or `gw` formatting/wrapping operators to the `ip` in-paragraph text object.
38,837
<p>When in terminal mode, I would like that <code>&lt;c-i&gt;</code> and <code>&lt;c-o&gt;</code> work like in insert mode, i.e. the cursor jumps to its next/previous position in accordance with the <code>jumplist</code>.</p> <p>How to make this to happen?</p> <p>EDIT: this becomes very annoying when you jump into a te...
[ { "answer_id": 38838, "author": "paradroid", "author_id": 37532, "author_profile": "https://vi.stackexchange.com/users/37532", "pm_score": 0, "selected": false, "text": "<p>As it's likely not possible to do what you want, if it's a *nix terminal you could use <code>tmux</code> to jump ba...
2022/10/10
[ "https://vi.stackexchange.com/questions/38837", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/38077/" ]
When in terminal mode, I would like that `<c-i>` and `<c-o>` work like in insert mode, i.e. the cursor jumps to its next/previous position in accordance with the `jumplist`. How to make this to happen? EDIT: this becomes very annoying when you jump into a terminal window with `<c-o>` (or with `<c-i>`) and then can't ...
Looking at the [source code](https://github.com/vim/vim/blob/56564964e6d0/src/mark.c#L143-L144), it looks like there is no way other than `:h keepjump` to avoid adding to jumplist (which you *can* do: most of the movements can be done through `:h :norm`, and when in terminal buffer, prepending those commands with `:kee...
38,870
<p>I am using a command like this:</p> <pre><code>:redir @+ | set guifont | redir END </code></pre> <p>The output of the command above is:</p> <pre><code> guifont=Source Code Pro:h14 </code></pre> <p>Note the blank line at the beginning. How can I remove it? I tried the following:</p> <pre><code>:redir @+ | set guifo...
[ { "answer_id": 38871, "author": "3N4N", "author_id": 16280, "author_profile": "https://vi.stackexchange.com/users/16280", "pm_score": 4, "selected": true, "text": "<p>You were on the right track trying to substitute the newline with nil, but <code>:%s</code> works on a buffer. What you n...
2022/10/13
[ "https://vi.stackexchange.com/questions/38870", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/8747/" ]
I am using a command like this: ``` :redir @+ | set guifont | redir END ``` The output of the command above is: ``` guifont=Source Code Pro:h14 ``` Note the blank line at the beginning. How can I remove it? I tried the following: ``` :redir @+ | set guifont | redir END | %s/^\n// ``` But it doesn't work.
You were on the right track trying to substitute the newline with nil, but `:%s` works on a buffer. What you needed to execute the substitution on is the content of the clipboard, which resides in the clipboard register (see `:h @r`). The correct way to capture the clean output of a command then is this: ``` redir @+...
38,873
<p>Is there a way to turn on an indicator that states that this is the beginning or the end of the file in VIM?</p> <p>You can do it in SEU on the iSeries, see below:</p> <p><a href="https://i.stack.imgur.com/fnRMZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fnRMZ.png" alt="The SEU editor display...
[ { "answer_id": 38871, "author": "3N4N", "author_id": 16280, "author_profile": "https://vi.stackexchange.com/users/16280", "pm_score": 4, "selected": true, "text": "<p>You were on the right track trying to substitute the newline with nil, but <code>:%s</code> works on a buffer. What you n...
2022/10/13
[ "https://vi.stackexchange.com/questions/38873", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/1065/" ]
Is there a way to turn on an indicator that states that this is the beginning or the end of the file in VIM? You can do it in SEU on the iSeries, see below: [![The SEU editor displaying Beginning of data, End of data](https://i.stack.imgur.com/fnRMZ.png)](https://i.stack.imgur.com/fnRMZ.png)
You were on the right track trying to substitute the newline with nil, but `:%s` works on a buffer. What you needed to execute the substitution on is the content of the clipboard, which resides in the clipboard register (see `:h @r`). The correct way to capture the clean output of a command then is this: ``` redir @+...
38,905
<p>Upon launching vim, if I enter <code>colorscheme</code> the output is <code>default</code>. If I enter <code>colorscheme default</code> the colorscheme changes. If I change the colorscheme from the default to any other colorscheme and then enter <code>colorscheme default</code> the behavior is the same as before. Th...
[ { "answer_id": 38907, "author": "Rich", "author_id": 343, "author_profile": "https://vi.stackexchange.com/users/343", "pm_score": 1, "selected": false, "text": "<p>If you are using a version of Vim earlier than 8.2.1693, you may be experiencing <a href=\"https://github.com/vim/vim/issues...
2022/10/18
[ "https://vi.stackexchange.com/questions/38905", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/14980/" ]
Upon launching vim, if I enter `colorscheme` the output is `default`. If I enter `colorscheme default` the colorscheme changes. If I change the colorscheme from the default to any other colorscheme and then enter `colorscheme default` the behavior is the same as before. The only way I know of to restore the original co...
When you do `colorscheme default` vim tries to detect background (whether it is dark or light) and apply dark or light syntax highlighting. Very often it detects background as light. Usually `set background=dark` or `set background=light` depending on what is your terminal background color should work to fix the color...
38,912
<p>I'm using Vim 8.2 to edit some text files for a very old <a href="https://en.wikipedia.org/wiki/MSX-DOS" rel="nofollow noreferrer">MSX-DOS</a> system; these have a Ctrl-Z (0x1A) character after the final CR LF to indicate the end of the file, as is usual with CP/M and similar disk operating systems.</p> <p>I normall...
[ { "answer_id": 38913, "author": "Vivian De Smedt", "author_id": 23502, "author_profile": "https://vi.stackexchange.com/users/23502", "pm_score": -1, "selected": false, "text": "<p>Probably this option can help you:</p>\n<pre><code>:set nofixendofline\n</code></pre>\n<p>It prevent Vim for...
2022/10/18
[ "https://vi.stackexchange.com/questions/38912", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/15666/" ]
I'm using Vim 8.2 to edit some text files for a very old [MSX-DOS](https://en.wikipedia.org/wiki/MSX-DOS) system; these have a Ctrl-Z (0x1A) character after the final CR LF to indicate the end of the file, as is usual with CP/M and similar disk operating systems. I normally edit with `fileformats=unix` and `nofixendof...
Vim unconditionally removes the ^Z unless 'binary' is set, but then Vim always uses Unix line endings. See [`readfile()` in `fileio.c`](https://github.com/vim/vim/blob/bf72e0c67f26ea7c8fd941fdd1533c24c7b6cb43/src/fileio.c#L2272-L2284): ``` /* * If we get EOF in the middle of a line, note the fact and * complete the ...
38,922
<p>This is a follow up to <a href="https://vi.stackexchange.com/questions/37623/how-can-i-inhibit-the-effect-of-hitting-ctrlmenu">this question of mine</a>.</p> <p>I found out that having <code>:noremap ^[[29^ &lt;Nop&gt;</code> in my vimrc is not enough to disable the unwanted effect of <kbd>Ctrl</kbd>+<kbd>Menu</kbd>...
[ { "answer_id": 38931, "author": "D. Ben Knoble", "author_id": 10604, "author_profile": "https://vi.stackexchange.com/users/10604", "pm_score": 0, "selected": false, "text": "<p>Simply:</p>\n<pre><code>:inoremap … &lt;Nop&gt;\n</code></pre>\n<p>But be careful with mappings with <code>&lt;...
2022/10/19
[ "https://vi.stackexchange.com/questions/38922", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/6498/" ]
This is a follow up to [this question of mine](https://vi.stackexchange.com/questions/37623/how-can-i-inhibit-the-effect-of-hitting-ctrlmenu). I found out that having `:noremap ^[[29^ <Nop>` in my vimrc is not enough to disable the unwanted effect of `Ctrl`+`Menu` in insert mode, so I looked at [`:help map-table`](htt...
The `l` in `:lmap` is for "language". `:lmap` is only effective when an input method is set. See `:help 'iminsert'` and related options. If you want to cover the most modes with the least number of commands, you will need the following lines: ``` " Normal, Visual, Select, Operator-pending noremap ^[[29^ <NOP> " Inse...
38,932
<p>As title. I want to define an event via <code>autocmd User MyEvent ...</code>. Then when some internal state of my plugin is reached, I will trigger the event with <code>doautocmd User MyEvent</code>. So, how to write the part <code>...</code>?</p>
[ { "answer_id": 38934, "author": "D. Ben Knoble", "author_id": 10604, "author_profile": "https://vi.stackexchange.com/users/10604", "pm_score": 1, "selected": false, "text": "<p>There is no code that defines a <code>User</code> event. You simply invoke it when you wish, and autocommands e...
2022/10/19
[ "https://vi.stackexchange.com/questions/38932", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/10189/" ]
As title. I want to define an event via `autocmd User MyEvent ...`. Then when some internal state of my plugin is reached, I will trigger the event with `doautocmd User MyEvent`. So, how to write the part `...`?
There is no API for defining custom events. What you define are autocommands that are meant to be executed manually. Executing those autocommands manually is the closest you can get from having custom events. In their simplest form, autocommands look like this: ``` autocmd <event> <pattern> <command> ``` where: * ...
38,938
<p>As you can see in the image below, I have this weird highlight on my gutter. I'd be great if I could make that transparent. How can I do it?</p> <p><a href="https://i.stack.imgur.com/MpiBv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MpiBv.png" alt="" /></a></p> <p><strong>EDIT:</strong></p> <p...
[ { "answer_id": 38945, "author": "Christian Brabandt", "author_id": 71, "author_profile": "https://vi.stackexchange.com/users/71", "pm_score": 3, "selected": true, "text": "<p>To make the Gutter Column transparent, I suggest you define it like the following:</p>\n<pre><code>:hi SignColumn...
2022/10/20
[ "https://vi.stackexchange.com/questions/38938", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/43739/" ]
As you can see in the image below, I have this weird highlight on my gutter. I'd be great if I could make that transparent. How can I do it? [![](https://i.stack.imgur.com/MpiBv.png)](https://i.stack.imgur.com/MpiBv.png) **EDIT:** I just found out that I can do `:higlight SignColumn guibg=#ff0000` to change the colo...
To make the Gutter Column transparent, I suggest you define it like the following: ``` :hi SignColumn guibg=NONE cterm=NONE term=NONE ``` This should come after any colorscheme command, so that it can override it, in case your colorscheme sets it. You can also place it into an `ColorScheme` autocommand, so that it w...
38,951
<p>I have the following situation a lot, where I always end up having to yank two things in a row: For example, I want to yank a function call:</p> <pre><code>func(a, b) </code></pre> <p>Okay, here I can go to <code>f</code> and press <code>vf)</code>.</p> <p>But when the call is nested, this does not work anymore:</p>...
[ { "answer_id": 38953, "author": "Vivian De Smedt", "author_id": 23502, "author_profile": "https://vi.stackexchange.com/users/23502", "pm_score": 1, "selected": false, "text": "<p>You can do:</p>\n<pre><code>vf(%`\n</code></pre>\n<p><code>f(</code> moves the the first parenthesis</p>\n<p>...
2022/10/21
[ "https://vi.stackexchange.com/questions/38951", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/18689/" ]
I have the following situation a lot, where I always end up having to yank two things in a row: For example, I want to yank a function call: ``` func(a, b) ``` Okay, here I can go to `f` and press `vf)`. But when the call is nested, this does not work anymore: ``` func(gunk(a), b) ``` Here I always end up going ...
For ``` func(gunk(a, b)) ``` with the cursor on the `f` of `func`, I would press `y%` or `d%`. The `%` command jumps between matching pairs (roughly; depending on configuration, optional plugins that ship with Vim, etc.), but it also *first* finds an opening pair if not already on one. That means `v%` in this situat...
38,969
<p>I want to replace b by a in visual selection.</p> <p>I have vimscript like this:</p> <pre><code>execute(&quot;normal! vip:s/a/b/g&quot;) </code></pre> <p>It works in command line mode. But not work in vimscript.</p> <p>How to fix it?</p> <p>How to replace the text directly on original text in vimscript?</p>
[ { "answer_id": 38973, "author": "Vivian De Smedt", "author_id": 23502, "author_profile": "https://vi.stackexchange.com/users/23502", "pm_score": 3, "selected": true, "text": "<p>I would do:</p>\n<pre><code>execute 'normal! vip' | s/a/b/g\n</code></pre>\n" }, { "answer_id": 38976,...
2022/10/22
[ "https://vi.stackexchange.com/questions/38969", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/8747/" ]
I want to replace b by a in visual selection. I have vimscript like this: ``` execute("normal! vip:s/a/b/g") ``` It works in command line mode. But not work in vimscript. How to fix it? How to replace the text directly on original text in vimscript?
I would do: ``` execute 'normal! vip' | s/a/b/g ```
38,971
<p>I've been configuring my Neovim for quite a while now. This command menu seems a little ugly with the transparent background. I'd be great if I could add a border for this menu. How can I do that ?</p> <p><a href="https://i.stack.imgur.com/Ldt5E.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ldt5...
[ { "answer_id": 38975, "author": "Vivian De Smedt", "author_id": 23502, "author_profile": "https://vi.stackexchange.com/users/23502", "pm_score": 3, "selected": true, "text": "<p>I would propose you to use the <a href=\"https://github.com/gelguy/wilder.nvim\" rel=\"nofollow noreferrer\">w...
2022/10/22
[ "https://vi.stackexchange.com/questions/38971", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/43739/" ]
I've been configuring my Neovim for quite a while now. This command menu seems a little ugly with the transparent background. I'd be great if I could add a border for this menu. How can I do that ? [![enter image description here](https://i.stack.imgur.com/Ldt5E.png)](https://i.stack.imgur.com/Ldt5E.png) I'll accept ...
I would propose you to use the [wilder plugin](https://github.com/gelguy/wilder.nvim) With the following settings: ``` call wilder#set_option('renderer', wilder#popupmenu_renderer(wilder#popupmenu_border_theme({ \ 'highlights': { \ 'border': 'Normal', \ }, \ 'border': 'single', \ }))) ...
39,028
<p>Given a neovim setup with a plugin installed in <code>.local/share/nvim/site/pack/&lt;x&gt;/start/</code>. From what I understand from the (neo)vim runtimepath, that plugin will automatically be loaded (otherwise it should have been put in <code>pack/&lt;x&gt;/opt/</code>). So if I have config related to that plugin...
[ { "answer_id": 39011, "author": "Georg Berky", "author_id": 44064, "author_profile": "https://vi.stackexchange.com/users/44064", "pm_score": 4, "selected": false, "text": "<p>What helped me was to vocalize the commands I'm issuing in my head while keying them into Vim, e.g.:</p>\n<ul>\n<...
2022/10/25
[ "https://vi.stackexchange.com/questions/39028", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/44027/" ]
Given a neovim setup with a plugin installed in `.local/share/nvim/site/pack/<x>/start/`. From what I understand from the (neo)vim runtimepath, that plugin will automatically be loaded (otherwise it should have been put in `pack/<x>/opt/`). So if I have config related to that plugin, should that be added to `$XDG_CONFI...
I think for me the key was (and the optimization-happy engineer in me is aghast at this) **not** trying to *vim-golf* my motions. Because once you have to think about the motion it takes you out of the flow. Find key combos that work for you. Then, *when you're ready to focus on improving efficiency*, pick **one** thi...
39,044
<p>At the moment I use prettier for formatting with vim (via Coc). The issue I have is that prettier is opinionated and, at the same time, inconsistent.</p> <p>With javascript, functions look like this:</p> <pre class="lang-javascript prettyprint-override"><code> function cheese() { // stuff here } </code></pre> <p>...
[ { "answer_id": 39048, "author": "Vivian De Smedt", "author_id": 23502, "author_profile": "https://vi.stackexchange.com/users/23502", "pm_score": 2, "selected": true, "text": "<p>There are no builtin way to format code with Vim.</p>\n<p>However Vim has two formatting commands:</p>\n<ol>\n...
2022/10/26
[ "https://vi.stackexchange.com/questions/39044", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/41513/" ]
At the moment I use prettier for formatting with vim (via Coc). The issue I have is that prettier is opinionated and, at the same time, inconsistent. With javascript, functions look like this: ```javascript function cheese() { // stuff here } ``` In PHP they look like this: ```php function cheese() { // stu...
There are no builtin way to format code with Vim. However Vim has two formatting commands: 1. `=` 2. `gq` The first re-indent the content based on the file type. The second reformat the content using either a VimScript or an external command. How to associate an external command to a filetype is explained in the f...
39,071
<p>I use neovim (0.8) with built-in LSP, and I program in typescript</p> <p>I would like to highlight variables that have type <code>any</code> in a clearly visible color (maybe even background color instead of just foreground). Instances of type <code>any</code> can be intentional or unintentional, but either way, it ...
[ { "answer_id": 39072, "author": "Martin Tournoij", "author_id": 51, "author_profile": "https://vi.stackexchange.com/users/51", "pm_score": 1, "selected": false, "text": "<p>Normally I'd modify the syntax rules a bit, but looking at the syntax file in <code>$VIMRUNTIME/syntax/shared/types...
2022/10/28
[ "https://vi.stackexchange.com/questions/39071", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/21883/" ]
I use neovim (0.8) with built-in LSP, and I program in typescript I would like to highlight variables that have type `any` in a clearly visible color (maybe even background color instead of just foreground). Instances of type `any` can be intentional or unintentional, but either way, it is often concerning, so it is g...
Normally I'd modify the syntax rules a bit, but looking at the syntax file in `$VIMRUNTIME/syntax/shared/typescriptcommon.vim` it seems this would require overriding/duplicating quite a lot of stuff in your local vimrc, which isn't easy and may break on future updates. The easier option here would probably to use `matc...
39,108
<p>For my Latex setup in VIM I want to map different text modules where the cursor is automatic placed in between <code>(&lt;&gt;)</code>, when I press twice <code>&lt;space&gt;</code> and when the cursor arrives there the <code>(&lt;&gt;)</code> will be removed.</p> <p>As an example the mapping would look like:</p> <p...
[ { "answer_id": 39072, "author": "Martin Tournoij", "author_id": 51, "author_profile": "https://vi.stackexchange.com/users/51", "pm_score": 1, "selected": false, "text": "<p>Normally I'd modify the syntax rules a bit, but looking at the syntax file in <code>$VIMRUNTIME/syntax/shared/types...
2022/11/01
[ "https://vi.stackexchange.com/questions/39108", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/44199/" ]
For my Latex setup in VIM I want to map different text modules where the cursor is automatic placed in between `(<>)`, when I press twice `<space>` and when the cursor arrives there the `(<>)` will be removed. As an example the mapping would look like: ``` imap ;b \bold{(<>)} ``` Which command does it need in my vi...
Normally I'd modify the syntax rules a bit, but looking at the syntax file in `$VIMRUNTIME/syntax/shared/typescriptcommon.vim` it seems this would require overriding/duplicating quite a lot of stuff in your local vimrc, which isn't easy and may break on future updates. The easier option here would probably to use `matc...
39,117
<p>I am currently running the following configuration for latex: NVim 0.9, Vmitex and Evince.</p> <p>I have been trying to map a key to open <code>&lt;current-file&gt;.log</code>, while the <code>current-file</code> is a name taken from a currently opened file without extension, e.g. from <code>something.tex</code>.</...
[ { "answer_id": 39118, "author": "Chris Heithoff", "author_id": 36840, "author_profile": "https://vi.stackexchange.com/users/36840", "pm_score": 0, "selected": false, "text": "<p>I think you just need to change your pattern in the autocmd to <code>*.tex</code></p>\n<p>A file like <code>ab...
2022/11/02
[ "https://vi.stackexchange.com/questions/39117", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/43801/" ]
I am currently running the following configuration for latex: NVim 0.9, Vmitex and Evince. I have been trying to map a key to open `<current-file>.log`, while the `current-file` is a name taken from a currently opened file without extension, e.g. from `something.tex`. Here is my first attempt: ``` autocmd FileType t...
Try using `<bar>` with `:*map` commands: ``` autocmd FileType tex nmap <buffer> <F5> if !empty(glob(expand("%:p:r.log"))) <bar> view <bar> split %:p:r.log<CR> <bar> else <bar> echo expand("%:p:r").'.log does not exist!' <bar> endif ``` and consider writing `nnoremap`, and using ftplugins with functions: ``` " ~/.vi...
39,123
<p>I've been reading a lot about split screens in vim, but actually getting your cursor over to the other document is still a problem.</p> <p>You can create a vertical split screen with <code>:vsplit &lt;file-name&gt;</code>, and a blank horizontal split screen with <code>ctrl+w n</code>, and a horizontal help split sc...
[ { "answer_id": 39124, "author": "Maxim Kim", "author_id": 9333, "author_profile": "https://vi.stackexchange.com/users/9333", "pm_score": 3, "selected": true, "text": "<p>It is there in <code>:help window-move-cursor</code>, it also helps to at least skim <code>:h window</code>.</p>\n<pre...
2022/11/03
[ "https://vi.stackexchange.com/questions/39123", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/8919/" ]
I've been reading a lot about split screens in vim, but actually getting your cursor over to the other document is still a problem. You can create a vertical split screen with `:vsplit <file-name>`, and a blank horizontal split screen with `ctrl+w n`, and a horizontal help split screen with `:help`, but none of the re...
It is there in `:help window-move-cursor`, it also helps to at least skim `:h window`. ``` 4. Moving cursor to other windows *window-move-cursor* CTRL-W <Down> *CTRL-W_<Down>* CTRL-W CTRL-J *CTRL-W_CTRL-J* *CTRL-W_j* CTRL-W j Move cursor to Nth window below current one...
39,130
<p>Alright, so I have two recursion functions with the exact same purpose:</p> <pre><code>let Fac = { n -&gt; n == 0 ? 1 : n * Fac(n - 1) } function! Fact(n) return a:n == 0 ? 1 : a:n * Fact(a:n - 1) endfunction </code></pre> <p>While <code>Fact</code> works fine, recursive use of <code>Fac</code> seems to confuse...
[ { "answer_id": 39131, "author": "Mass", "author_id": 13728, "author_profile": "https://vi.stackexchange.com/users/13728", "pm_score": 3, "selected": true, "text": "<p>It is possible, but you must refer to Fac as a &quot;global&quot; with <code>g:</code> to allow the lambda to refer to &q...
2022/11/03
[ "https://vi.stackexchange.com/questions/39130", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/41773/" ]
Alright, so I have two recursion functions with the exact same purpose: ``` let Fac = { n -> n == 0 ? 1 : n * Fac(n - 1) } function! Fact(n) return a:n == 0 ? 1 : a:n * Fact(a:n - 1) endfunction ``` While `Fact` works fine, recursive use of `Fac` seems to confuse vim: ``` :echo Fac(10) Error detected while pro...
It is possible, but you must refer to Fac as a "global" with `g:` to allow the lambda to refer to "itself," even if it is not actually defined already. ``` let Fac = { n -> n == 0 ? 1 : n * g:Fac(n - 1) } echo Fac(6) ``` If we want to avoid global variables there are two issues: 1. Fac needs to be "dummy defined" f...
39,144
<pre><code>echo getcompletion('', 'filetype') </code></pre> <p>The ex-command above lists all supported filetypes in vim. How can I output it into a file?</p> <p>I tried these two ways but none worked.</p> <pre><code>echo getcompletion('', 'filetype') &gt; /tmp/type.txt !echo getcompletion('', 'filetype') &gt; /tmp/typ...
[ { "answer_id": 39146, "author": "3N4N", "author_id": 16280, "author_profile": "https://vi.stackexchange.com/users/16280", "pm_score": 1, "selected": false, "text": "<p>You seem to be in a misunderstanding of how commands work in Vim versus how they work in a shell. The redirection operat...
2022/11/06
[ "https://vi.stackexchange.com/questions/39144", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/44094/" ]
``` echo getcompletion('', 'filetype') ``` The ex-command above lists all supported filetypes in vim. How can I output it into a file? I tried these two ways but none worked. ``` echo getcompletion('', 'filetype') > /tmp/type.txt !echo getcompletion('', 'filetype') > /tmp/type.txt ```
Just use [`writefile()`](http://vimhelp.appspot.com/eval.txt.html#writefile%28%29) ``` :call writefile(getcompletion('', 'filetype'), '/tmp/type.txt') ``` See [`:h functions`](http://vimhelp.appspot.com/eval.txt.html#functions)
39,149
<p>I want to make Neovim stop yanking the text I paste over into my register (mapped to system clipboard with <code>vim.opt.clipboard = 'unnamedplus'</code>), eg</p> <p>If I have the text:</p> <pre><code>asdfghjkl asdfghjkl asdfghjkl </code></pre> <p>and I v over 'sdfgh', hit y, then go to the second line and v over 'a...
[ { "answer_id": 39151, "author": "Mass", "author_id": 13728, "author_profile": "https://vi.stackexchange.com/users/13728", "pm_score": 3, "selected": true, "text": "<p>Just use <code>P</code> instead of <code>p</code> in visual mode. This will preserve the register.</p>\n<p>To make this ...
2022/11/06
[ "https://vi.stackexchange.com/questions/39149", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/44257/" ]
I want to make Neovim stop yanking the text I paste over into my register (mapped to system clipboard with `vim.opt.clipboard = 'unnamedplus'`), eg If I have the text: ``` asdfghjkl asdfghjkl asdfghjkl ``` and I v over 'sdfgh', hit y, then go to the second line and v over 'as' and hit paste it will copy 'as' to my ...
Just use `P` instead of `p` in visual mode. This will preserve the register. To make this default, you can use a map such as ``` xnoremap p P ```
39,157
<p>To execute and debug different kind of programs, I mapped the function keys in the .vimrc-file.</p> <p>E.g.</p> <pre><code>&quot; save and execute perl :noremap &lt;F5&gt; :w&lt;CR&gt;:!./%&lt;CR&gt; &quot; save and execute aql :noremap &lt;F9&gt; :w&lt;CR&gt;:!db&lt;%&lt;CR&gt; &quot; ... </code></pre> <p>Works so ...
[ { "answer_id": 39158, "author": "Vivian De Smedt", "author_id": 23502, "author_profile": "https://vi.stackexchange.com/users/23502", "pm_score": 2, "selected": true, "text": "<p>I would suggest you to define the variable <code>syn_exec</code> as a buffer variable</p>\n<pre><code>&quot; -...
2022/11/07
[ "https://vi.stackexchange.com/questions/39157", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/34453/" ]
To execute and debug different kind of programs, I mapped the function keys in the .vimrc-file. E.g. ``` " save and execute perl :noremap <F5> :w<CR>:!./%<CR> " save and execute aql :noremap <F9> :w<CR>:!db<%<CR> " ... ``` Works so far. But I would like do press always `F5` to save and execute. No matter which prog...
I would suggest you to define the variable `syn_exec` as a buffer variable ``` " -- Syntax-File -- let b:syn_exec = [ '', '', '', '', '!db < %', '!db -E < %', '!db -csv < % | ~/db_tools/dev.pl' ] ``` ``` " -- .vimrc -- :noremap <F5> :w<CR>:execute b:syn_exec[4]<CR> :noremap <F6> :w<CR>:execute b:syn_exec[5]<CR> " .....
39,182
<p>I have a mapping that comments/uncomments lines like <code>5gc</code> to comment/uncomment five lines, and I would like to make it repeatable with <code>.</code>.</p> <p>Here is my mapping and the function it uses:</p> <pre><code>function! Comment() range let l:prefix = split(&amp;commentstring, '%s', 1)[0] ...
[ { "answer_id": 39188, "author": "Matt", "author_id": 22797, "author_profile": "https://vi.stackexchange.com/users/22797", "pm_score": 1, "selected": false, "text": "<p>Obviously, your mapping executes two commands, not one. Therefore, the second call (i.e. repeat-set) needs to have <code...
2022/11/09
[ "https://vi.stackexchange.com/questions/39182", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/44312/" ]
I have a mapping that comments/uncomments lines like `5gc` to comment/uncomment five lines, and I would like to make it repeatable with `.`. Here is my mapping and the function it uses: ``` function! Comment() range let l:prefix = split(&commentstring, '%s', 1)[0] let l:suffix = split(&commentstring, '%s', 1)...
Obviously, your mapping executes two commands, not one. Therefore, the second call (i.e. repeat-set) needs to have `v:prevcount` passed as argument. As of "without plugins", a plugin in Vim is simply a piece of script written by another person. So you can read through it and re-implement it in a more elegant and compa...
39,217
<p>When I substitute text within a paragraph, I've always visually selected (e.g. <code>vap</code>), then <code>:s/ ...</code>.</p> <p>How to do this without the visual selection? More generally, how to apply a colon command on a movement / text object like <code>ap</code>?</p>
[ { "answer_id": 39218, "author": "Mass", "author_id": 13728, "author_profile": "https://vi.stackexchange.com/users/13728", "pm_score": 0, "selected": false, "text": "<p>Here is a relatively simple implementation where <code>g:{motion|object}</code> will prompt for a command, and run it ov...
2022/11/13
[ "https://vi.stackexchange.com/questions/39217", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/44355/" ]
When I substitute text within a paragraph, I've always visually selected (e.g. `vap`), then `:s/ ...`. How to do this without the visual selection? More generally, how to apply a colon command on a movement / text object like `ap`?
Some (not all) text objects have corresponding marks. In this case, the equivalent is roughly ``` :'{,'}substitute… ``` See `:help motion.txt` or `:help mark-motions` for some of these. In general, `:help [range]`.
39,235
<p>I'll try to illustrate as clear as I can.</p> <p>Suppose I have the following text open in vim/nvim</p> <pre><code> _________ | | | 9999 | | | --------- </code></pre> <p>If select <code>9999</code> visually and then hit <code>r8</code>, this will happen</p> <pre><code> _________ | | | 88...
[ { "answer_id": 39218, "author": "Mass", "author_id": 13728, "author_profile": "https://vi.stackexchange.com/users/13728", "pm_score": 0, "selected": false, "text": "<p>Here is a relatively simple implementation where <code>g:{motion|object}</code> will prompt for a command, and run it ov...
2022/11/16
[ "https://vi.stackexchange.com/questions/39235", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/43739/" ]
I'll try to illustrate as clear as I can. Suppose I have the following text open in vim/nvim ``` _________ | | | 9999 | | | --------- ``` If select `9999` visually and then hit `r8`, this will happen ``` _________ | | | 8888 | | | --------- ``` Can I do the same replacin...
Some (not all) text objects have corresponding marks. In this case, the equivalent is roughly ``` :'{,'}substitute… ``` See `:help motion.txt` or `:help mark-motions` for some of these. In general, `:help [range]`.
39,247
<p>I'm on macOS Ventura with iTerm2.</p> <p>I've made a color scheme for Vim in <code>~/.vim/colors/myowncolorscheme.vim</code>.<br /> Is it possible to use it in Neovim? If yes, how do I do that?</p> <p>In my <code>~.vimrc</code> I integrate it this way:</p> <pre><code>&quot; Set the color scheme of Vim: colorscheme m...
[ { "answer_id": 39254, "author": "Pixelbog", "author_id": 43725, "author_profile": "https://vi.stackexchange.com/users/43725", "pm_score": 1, "selected": false, "text": "<p>Yes. simply <strong>create</strong> the this directory:</p>\n<p><code>mkdir -p ~/.config/nvim/colors</code></p>\n<p>...
2022/11/17
[ "https://vi.stackexchange.com/questions/39247", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/38579/" ]
I'm on macOS Ventura with iTerm2. I've made a color scheme for Vim in `~/.vim/colors/myowncolorscheme.vim`. Is it possible to use it in Neovim? If yes, how do I do that? In my `~.vimrc` I integrate it this way: ``` " Set the color scheme of Vim: colorscheme myowncolorscheme set termguicolors ``` In Vim, my own ...
Solution 1 - .vimrc as source ----------------------------- If in Vim everything works properly and if you have Neovim already installed, create the file `init.vim` in Neovim directory with the command: ``` touch ~/.config/nvim/init.vim ``` Now open this file with any editor you like (I use Neovim for this example)...
39,263
<p>Not long ago, I discovered the modeline feature that sets up options on a per-file basis. I wonder if it is possible to extend this functionality with other possibilities?</p> <p>For example, setting up a variable:</p> <pre><code>-- vim: let b:sql_flavor = 'mysql' </code></pre> <p>Or to call a command:</p> <pre><cod...
[ { "answer_id": 39265, "author": "romainl", "author_id": 54, "author_profile": "https://vi.stackexchange.com/users/54", "pm_score": 2, "selected": false, "text": "<p>What can and can't be done with modelines is documented under <code>:help modeline</code>.</p>\n<p>Your two examples are cu...
2022/11/19
[ "https://vi.stackexchange.com/questions/39263", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/41773/" ]
Not long ago, I discovered the modeline feature that sets up options on a per-file basis. I wonder if it is possible to extend this functionality with other possibilities? For example, setting up a variable: ``` -- vim: let b:sql_flavor = 'mysql' ``` Or to call a command: ``` -- vim: SQLSetType mysql ```
What can and can't be done with modelines is documented under `:help modeline`. Your two examples are currently impossible with the built-in modeline feature but nothing is stopping you from devising your own modeline-like syntax and writing your own parsing logic. There's an example in the same help section.
39,287
<p>During insert mode my <kbd>Home</kbd> key is set to toggle case of character which is very annoying. I tried this command to search for any settings, but failed to solve the problem. I would like to set it to go at the beginning of a line (&quot;0&quot;).</p> <pre><code>:redir! &gt; vim_key_setting.txt silent verbos...
[ { "answer_id": 39265, "author": "romainl", "author_id": 54, "author_profile": "https://vi.stackexchange.com/users/54", "pm_score": 2, "selected": false, "text": "<p>What can and can't be done with modelines is documented under <code>:help modeline</code>.</p>\n<p>Your two examples are cu...
2022/11/21
[ "https://vi.stackexchange.com/questions/39287", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/17864/" ]
During insert mode my `Home` key is set to toggle case of character which is very annoying. I tried this command to search for any settings, but failed to solve the problem. I would like to set it to go at the beginning of a line ("0"). ``` :redir! > vim_key_setting.txt silent verbose imap redir END ``` I pasted thi...
What can and can't be done with modelines is documented under `:help modeline`. Your two examples are currently impossible with the built-in modeline feature but nothing is stopping you from devising your own modeline-like syntax and writing your own parsing logic. There's an example in the same help section.
39,307
<p>How to convert the output of the <code>type()</code> function, which is a number, into a verbal format, e.g. as described in help v:t_...?</p> <p>To write my own mappings seems to be too cumbersome.</p> <p>Presumably there exists a ready solution, but by googling I cannot find any.</p> <p>Thanks, Regards Anton Wess...
[ { "answer_id": 39308, "author": "Martin Tournoij", "author_id": 51, "author_profile": "https://vi.stackexchange.com/users/51", "pm_score": 1, "selected": false, "text": "<p>There is the <code>typename()</code> function for this:</p>\n<pre><code>:echo typename('str')\nstring\n</code></pre...
2022/11/22
[ "https://vi.stackexchange.com/questions/39307", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/30757/" ]
How to convert the output of the `type()` function, which is a number, into a verbal format, e.g. as described in help v:t\_...? To write my own mappings seems to be too cumbersome. Presumably there exists a ready solution, but by googling I cannot find any. Thanks, Regards Anton Wessel === addendum, Wessel, 23.11....
There is the `typename()` function for this: ``` :echo typename('str') string ``` You need Vim 8.2.2339 or newer for this. It does display "Vim 9" type information: ``` :echo typename([]) list<unknown> :echo typename([1]) list<number> :echo typename(['', 1]) list<any> ``` Which may or may not be desired depend...
39,319
<p>As title. I just randomly come up with this question. To do so one would need to iterate over all autocmds in the augroup. Is this possible?</p>
[ { "answer_id": 39320, "author": "romainl", "author_id": 54, "author_profile": "https://vi.stackexchange.com/users/54", "pm_score": 3, "selected": true, "text": "<blockquote>\n<p>To do so one would need to iterate over all autocmds in the augroup.</p>\n</blockquote>\n<p>No. Operating on a...
2022/11/23
[ "https://vi.stackexchange.com/questions/39319", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/10189/" ]
As title. I just randomly come up with this question. To do so one would need to iterate over all autocmds in the augroup. Is this possible?
> > To do so one would need to iterate over all autocmds in the augroup. > > > No. Operating on a bunch of autocommands in one go is precisely why autocommand groups exist, as explained under `:help autocmd-group`: ``` Autocommands can be put together in a group. This is useful for removing or executing a group ...
39,341
<p>Currently my Vim layout is this one :</p> <pre><code>________________________ | N | | | | E | | | | R | | | | D | | | | T |---------| | | r | | | | e | | | | e | | | |-----------------------| | ...
[ { "answer_id": 39343, "author": "Vivian De Smedt", "author_id": 23502, "author_profile": "https://vi.stackexchange.com/users/23502", "pm_score": 0, "selected": false, "text": "<p>I believe you can't.</p>\n<p>In the first figure you have 1 partial horizontal split. In the second you have ...
2022/11/24
[ "https://vi.stackexchange.com/questions/39341", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/42740/" ]
Currently my Vim layout is this one : ``` ________________________ | N | | | | E | | | | R | | | | D | | | | T |---------| | | r | | | | e | | | | e | | | |-----------------------| | ...
The simplest built-in way to do this is the function `win_splitmove`. Given the layout you start with, ``` call win_splitmove(5, 4) ``` will result in the desired layout, up to specific windows chosen. In other words, we are moving window 5, bottommost, to become a new split window of window 4, rightmost (technicall...
39,363
<p>I made the regex:</p> <pre><code>/^\n\t(\n|.)*?\n$/gm </code></pre> <p>(prepended with \v inside Vim) to select consecutively indented lines (with tab) separated by a top blank line.</p> <p>But while it works in other languages it doesn't seem to do in Vim.</p> <p>I expect to get the following &quot;underlined&quot;...
[ { "answer_id": 39343, "author": "Vivian De Smedt", "author_id": 23502, "author_profile": "https://vi.stackexchange.com/users/23502", "pm_score": 0, "selected": false, "text": "<p>I believe you can't.</p>\n<p>In the first figure you have 1 partial horizontal split. In the second you have ...
2022/11/28
[ "https://vi.stackexchange.com/questions/39363", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/44531/" ]
I made the regex: ``` /^\n\t(\n|.)*?\n$/gm ``` (prepended with \v inside Vim) to select consecutively indented lines (with tab) separated by a top blank line. But while it works in other languages it doesn't seem to do in Vim. I expect to get the following "underlined" parts highlighted: ``` A random fact: _ ____...
The simplest built-in way to do this is the function `win_splitmove`. Given the layout you start with, ``` call win_splitmove(5, 4) ``` will result in the desired layout, up to specific windows chosen. In other words, we are moving window 5, bottommost, to become a new split window of window 4, rightmost (technicall...
39,369
<h2>Question</h2> <p>I want to have basically the same as <code>:read ![external command]</code>, but instead the <strong>external command</strong> I want to read the output from an <strong>internal command</strong>.</p> <h2>Example</h2> <p><strong>Shells echo / external command:</strong> <code>:read !echo 0x539</code>...
[ { "answer_id": 39343, "author": "Vivian De Smedt", "author_id": 23502, "author_profile": "https://vi.stackexchange.com/users/23502", "pm_score": 0, "selected": false, "text": "<p>I believe you can't.</p>\n<p>In the first figure you have 1 partial horizontal split. In the second you have ...
2022/11/28
[ "https://vi.stackexchange.com/questions/39369", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/43725/" ]
Question -------- I want to have basically the same as `:read ![external command]`, but instead the **external command** I want to read the output from an **internal command**. Example ------- **Shells echo / external command:** `:read !echo 0x539` -> `output: 0x539` **Vims echo / internal command:** `:read echo 0x...
The simplest built-in way to do this is the function `win_splitmove`. Given the layout you start with, ``` call win_splitmove(5, 4) ``` will result in the desired layout, up to specific windows chosen. In other words, we are moving window 5, bottommost, to become a new split window of window 4, rightmost (technicall...
39,395
<p>We can get help on Vim functions by typing the following from within Vim.</p> <pre><code>:help somecommand </code></pre> <p>For example, the following sends us to the help text for the unmap functionality.:</p> <pre><code>:help unmap </code></pre> <p>Is there any way to get Vim help directly in the terminal? If I co...
[ { "answer_id": 39396, "author": "Christian Brabandt", "author_id": 71, "author_profile": "https://vi.stackexchange.com/users/71", "pm_score": 3, "selected": true, "text": "<p>This is more likely a Shell-scripting question. You could define the following function in your .bashrc:</p>\n<pr...
2022/12/01
[ "https://vi.stackexchange.com/questions/39395", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/605/" ]
We can get help on Vim functions by typing the following from within Vim. ``` :help somecommand ``` For example, the following sends us to the help text for the unmap functionality.: ``` :help unmap ``` Is there any way to get Vim help directly in the terminal? If I could put that functionality into a function, c...
This is more likely a Shell-scripting question. You could define the following function in your .bashrc: ```bash vimhelp() { if [ -n "$1" ]; then vim -i NONE -c "set bt=help|help $1" -c 'nnoremap q :q!<cr>' else echo "please give help-topic to jump to" fi } ``` after resourcing your `.bashr...
39,411
<p>Let's say you have this text:</p> <pre><code>sed -n '1,4p' Commas are used in every sed expression to target a range. </code></pre> <p>It's part of some notes i have...</p> <p>The cursor is right behind the <code>to</code>, but I want to get the cursor to the comma in <code>'1,4p'</code>. What is the quickest way t...
[ { "answer_id": 39412, "author": "Alex Roberts", "author_id": 37099, "author_profile": "https://vi.stackexchange.com/users/37099", "pm_score": 2, "selected": false, "text": "<p>You could use the plugin <code>vim-sneak</code> with the following in your <code>.vimrc</code> (see the <a href=...
2022/12/03
[ "https://vi.stackexchange.com/questions/39411", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/8919/" ]
Let's say you have this text: ``` sed -n '1,4p' Commas are used in every sed expression to target a range. ``` It's part of some notes i have... The cursor is right behind the `to`, but I want to get the cursor to the comma in `'1,4p'`. What is the quickest way to do that? I typically have stayed with nano because...
> > What is the quickest way to do that? > > > If such things as "purity" or "efficiency" are important to you, then the fastest native method is: ``` ?,<CR> ``` where: * `:help ?` starts backward search, * `,` is your target, * `<CR>` is the Enter key. See also `:help 'incsearch'`. [![pure](https://i.stack....
39,431
<p>As title. I want to call a command to all existing tabs to close all windows of specific filetype. How to do so efficiently?</p>
[ { "answer_id": 39437, "author": "job_start", "author_id": 10189, "author_profile": "https://vi.stackexchange.com/users/10189", "pm_score": 0, "selected": false, "text": "<blockquote>\n<p>[...] to close all windows of specific filetype.</p>\n</blockquote>\n<p>To achieve this in neovim you...
2022/12/05
[ "https://vi.stackexchange.com/questions/39431", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/10189/" ]
As title. I want to call a command to all existing tabs to close all windows of specific filetype. How to do so efficiently?
Essentially ``` :tabdo windo if &filetype is# 'bad' | close | endif ```
39,435
<p>In the middle of a Vim session, I need to call a particular plugin's function via:</p> <pre><code>:call UltiSnips#RefreshSnippets() </code></pre> <p>When from normal mode I type <code>:call UltiS&lt;Tab&gt;</code>, it auto-expands to alphabetically the first offered function:</p> <pre><code>:call UltiSnips#AddFilety...
[ { "answer_id": 39436, "author": "Vivian De Smedt", "author_id": 23502, "author_profile": "https://vi.stackexchange.com/users/23502", "pm_score": 2, "selected": true, "text": "<p>In command mode you can use: <kbd>Ctrl</kbd><kbd>w</kbd></p>\n<p>It delete the previous 'word'</p>\n" }, {...
2022/12/06
[ "https://vi.stackexchange.com/questions/39435", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/31759/" ]
In the middle of a Vim session, I need to call a particular plugin's function via: ``` :call UltiSnips#RefreshSnippets() ``` When from normal mode I type `:call UltiS<Tab>`, it auto-expands to alphabetically the first offered function: ``` :call UltiSnips#AddFiletypes( ``` From here, I have to delete backward one...
In command mode you can use: `Ctrl``w` It delete the previous 'word'
39,457
<p>If a path is written in form <code>filepath:line</code> (i.e. python exception), I want <code>gf</code> to jump straight to the line.</p>
[ { "answer_id": 39458, "author": "eyal karni", "author_id": 18375, "author_profile": "https://vi.stackexchange.com/users/18375", "pm_score": 0, "selected": false, "text": "<p>This is the implementation.\nI haven't completed it for vmap, though not complicated.</p>\n<p>I didn't check it is...
2022/12/08
[ "https://vi.stackexchange.com/questions/39457", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/18375/" ]
If a path is written in form `filepath:line` (i.e. python exception), I want `gf` to jump straight to the line.
What you want already exists: `:help gF`. Note that `gF` behaves like `gf` in the absence of a line number so you can default to `gF` if you don't want to think too much about which command to use in which case. --- EDIT --- Note that Python exceptions are actually in the form: ``` File "/path/to/file", line 10, in...
39,466
<p>This is what it says in the help:</p> <pre><code>'x' Execute commands until typeahead is empty. This is similar to using &quot;:normal!&quot;. You can call feedkeys() several times without 'x' and then one time with 'x' (possibly with an empty {string}) to execute all the typeahead. Note that when...
[ { "answer_id": 39458, "author": "eyal karni", "author_id": 18375, "author_profile": "https://vi.stackexchange.com/users/18375", "pm_score": 0, "selected": false, "text": "<p>This is the implementation.\nI haven't completed it for vmap, though not complicated.</p>\n<p>I didn't check it is...
2022/12/08
[ "https://vi.stackexchange.com/questions/39466", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/43492/" ]
This is what it says in the help: ``` 'x' Execute commands until typeahead is empty. This is similar to using ":normal!". You can call feedkeys() several times without 'x' and then one time with 'x' (possibly with an empty {string}) to execute all the typeahead. Note that when Vim ends in Insert mod...
What you want already exists: `:help gF`. Note that `gF` behaves like `gf` in the absence of a line number so you can default to `gF` if you don't want to think too much about which command to use in which case. --- EDIT --- Note that Python exceptions are actually in the form: ``` File "/path/to/file", line 10, in...
39,498
<p>I have <code>incsearch</code> on, so when I type <code>:s/thingS</code> it will highlight the <code>thingS</code> part of <code>thingSoFar</code> in the below text</p> <pre><code>see, this thing is the thingSoFar thing </code></pre> <p>When I am typing that command line with my cursor at the first column, first the ...
[ { "answer_id": 39501, "author": "romainl", "author_id": 54, "author_profile": "https://vi.stackexchange.com/users/54", "pm_score": 2, "selected": false, "text": "<p>There is <code>:help c_ctrl-l</code>, which inserts one character of the first match:</p>\n<pre><code>:s/thingS\n:s/thingSo...
2022/12/10
[ "https://vi.stackexchange.com/questions/39498", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/9024/" ]
I have `incsearch` on, so when I type `:s/thingS` it will highlight the `thingS` part of `thingSoFar` in the below text ``` see, this thing is the thingSoFar thing ``` When I am typing that command line with my cursor at the first column, first the `t`, then `th`, then `thi` of "this" are highlighted. When I type th...
There is `:help c_ctrl-l`, which inserts one character of the first match: ``` :s/thingS :s/thingSo " <C-l> :s/thingSoF " <C-l> :s/thingSoFa " <C-l> :s/thingSoFar " <C-l> ``` but a) the characters come from the first match, which is probably not that useful, and b) it only inserts one character, wh...
39,516
<p>Let's say that I have a file of 100 lines, and all of the lines are folded. How would I unfold only line number 51?</p> <ul> <li>foldmethod is <code>manual</code></li> <li>All lines were folded with <code>1,$fold</code></li> </ul>
[ { "answer_id": 39501, "author": "romainl", "author_id": 54, "author_profile": "https://vi.stackexchange.com/users/54", "pm_score": 2, "selected": false, "text": "<p>There is <code>:help c_ctrl-l</code>, which inserts one character of the first match:</p>\n<pre><code>:s/thingS\n:s/thingSo...
2022/12/11
[ "https://vi.stackexchange.com/questions/39516", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/1363/" ]
Let's say that I have a file of 100 lines, and all of the lines are folded. How would I unfold only line number 51? * foldmethod is `manual` * All lines were folded with `1,$fold`
There is `:help c_ctrl-l`, which inserts one character of the first match: ``` :s/thingS :s/thingSo " <C-l> :s/thingSoF " <C-l> :s/thingSoFa " <C-l> :s/thingSoFar " <C-l> ``` but a) the characters come from the first match, which is probably not that useful, and b) it only inserts one character, wh...
39,519
<p>As a lot of people, I have removed <code>_</code> from <code>iskeyword</code>, so it considers it kind of like whitespace. This is really useful for changing part of an identifier in languages like Python and Rust with normal commands like <code>w</code>, <code>e</code> and <code>b</code>. However, it also breaks <c...
[ { "answer_id": 39521, "author": "Mass", "author_id": 13728, "author_profile": "https://vi.stackexchange.com/users/13728", "pm_score": 3, "selected": true, "text": "<p><code>*</code> is <em>roughly</em> equivalent to searching for the string:</p>\n<pre><code>'\\&lt;' . escape(expand('&lt;...
2022/12/11
[ "https://vi.stackexchange.com/questions/39519", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/43570/" ]
As a lot of people, I have removed `_` from `iskeyword`, so it considers it kind of like whitespace. This is really useful for changing part of an identifier in languages like Python and Rust with normal commands like `w`, `e` and `b`. However, it also breaks `*` and `#`. Does (Neo)Vim have an option / plugin to force ...
`*` is *roughly* equivalent to searching for the string: ``` '\<' . escape(expand('<cword>'), '/.*~[^$\') . '\>' ``` (the escape is slightly different for #). So, one option is to create a custom mapping which uses WORDs instead of words (`<c-r><c-a>` means cWORD). ``` nnoremap <silent> * /<c-r>=escape('<c-r><c-a>'...
39,537
<p>I have memorized <code>dip</code> as the command to delete a paragraph. However, I now see that <code>dap</code> is also a thing.</p> <p>The docs say:</p> <pre><code>&quot;dip&quot; delete inner paragraph &quot;dap&quot; delete a paragraph </code></pre> <p>When I try the two commands, the difference is not <em>i...
[ { "answer_id": 39521, "author": "Mass", "author_id": 13728, "author_profile": "https://vi.stackexchange.com/users/13728", "pm_score": 3, "selected": true, "text": "<p><code>*</code> is <em>roughly</em> equivalent to searching for the string:</p>\n<pre><code>'\\&lt;' . escape(expand('&lt;...
2022/12/13
[ "https://vi.stackexchange.com/questions/39537", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/40432/" ]
I have memorized `dip` as the command to delete a paragraph. However, I now see that `dap` is also a thing. The docs say: ``` "dip" delete inner paragraph "dap" delete a paragraph ``` When I try the two commands, the difference is not *immediately* obvious. I tried searching the docs for "inner paragraph" and I...
`*` is *roughly* equivalent to searching for the string: ``` '\<' . escape(expand('<cword>'), '/.*~[^$\') . '\>' ``` (the escape is slightly different for #). So, one option is to create a custom mapping which uses WORDs instead of words (`<c-r><c-a>` means cWORD). ``` nnoremap <silent> * /<c-r>=escape('<c-r><c-a>'...
39,548
<p>I got:</p> <pre><code>set shada=!,'100,&lt;50,s10,h,f1,s100,% </code></pre> <p>Which make Vim reload last buffers when I exit (or :wshada was called ) .</p> <p>However, the buffers are loaded without syntax and highlighting. I need to reload each buffer, and <code>:bufdo :e</code> didn't work.</p> <p>I wish to someh...
[ { "answer_id": 39549, "author": "Vivian De Smedt", "author_id": 23502, "author_profile": "https://vi.stackexchange.com/users/23502", "pm_score": 2, "selected": false, "text": "<p>I would suggest you:</p>\n<pre><code>:windo filetype detect\n</code></pre>\n" }, { "answer_id": 39565...
2022/12/14
[ "https://vi.stackexchange.com/questions/39548", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/18375/" ]
I got: ``` set shada=!,'100,<50,s10,h,f1,s100,% ``` Which make Vim reload last buffers when I exit (or :wshada was called ) . However, the buffers are loaded without syntax and highlighting. I need to reload each buffer, and `:bufdo :e` didn't work. I wish to somehow reload all buffers on start.
My solution based on @vivian ``` function! OnWinEnter() if !&filetype filetype detect endif endfunction autocmd BufWinEnter * call OnWinEnter() ```
39,557
<p>I often open the results of an external project-wide <code>find | xargs grep</code> command into a new tab like this <code>:tabnew|read !find . -iname \*.py | xargs grep -n 'pattern'</code></p> <p>I then use <code>gf</code> to open the matching files and perform edits. While this is handy, the file opens with the c...
[ { "answer_id": 39549, "author": "Vivian De Smedt", "author_id": 23502, "author_profile": "https://vi.stackexchange.com/users/23502", "pm_score": 2, "selected": false, "text": "<p>I would suggest you:</p>\n<pre><code>:windo filetype detect\n</code></pre>\n" }, { "answer_id": 39565...
2022/12/16
[ "https://vi.stackexchange.com/questions/39557", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/44764/" ]
I often open the results of an external project-wide `find | xargs grep` command into a new tab like this `:tabnew|read !find . -iname \*.py | xargs grep -n 'pattern'` I then use `gf` to open the matching files and perform edits. While this is handy, the file opens with the cursor on the top-most line of the file. I ...
My solution based on @vivian ``` function! OnWinEnter() if !&filetype filetype detect endif endfunction autocmd BufWinEnter * call OnWinEnter() ```
39,560
<p>When I edit a .html file I get this when pressing enter key:</p> <pre><code>&lt;div&gt;|&lt;/div&gt; &lt;div&gt; | &lt;/div&gt; </code></pre> <p>and while I edit a react file, the behavior is not what I was expecting:</p> <pre><code>&lt;div&gt;|&lt;/div&gt; &lt;div&gt; | &lt;/div&gt; /* Or sometimes is just lik...
[ { "answer_id": 39561, "author": "Vivian De Smedt", "author_id": 23502, "author_profile": "https://vi.stackexchange.com/users/23502", "pm_score": 1, "selected": false, "text": "<p>The reason is that the <code>indentexpr</code> of react file is indenting the file as a javascript (javascrip...
2022/12/16
[ "https://vi.stackexchange.com/questions/39560", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/44767/" ]
When I edit a .html file I get this when pressing enter key: ``` <div>|</div> <div> | </div> ``` and while I edit a react file, the behavior is not what I was expecting: ``` <div>|</div> <div> | </div> /* Or sometimes is just like */ <div> | </div> ``` On the .html files it works perfectly but with react ...
I just found an solution after a lot more searching on google. using treesiter and adding this into the treesitter config got my desired behaviour: ``` require'nvim-treesitter.configs'.setup { indent = { enable = true, }, } ``` Now it works in a .js file perfectly like in a .hmtl which is: ``` <div>|</...
39,571
<p>I'm particularly interested in what the presenter, Damian Conway, in this <a href="https://www.youtube.com/watch?v=aHm36-na4-4&amp;t=36m41s" rel="nofollow noreferrer">talk</a> is doing as he selects the end of visual-block to effortlessly add quotes.</p> <p>In particular - what is happening around <a href="https://w...
[ { "answer_id": 39561, "author": "Vivian De Smedt", "author_id": 23502, "author_profile": "https://vi.stackexchange.com/users/23502", "pm_score": 1, "selected": false, "text": "<p>The reason is that the <code>indentexpr</code> of react file is indenting the file as a javascript (javascrip...
2022/12/18
[ "https://vi.stackexchange.com/questions/39571", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/12589/" ]
I'm particularly interested in what the presenter, Damian Conway, in this [talk](https://www.youtube.com/watch?v=aHm36-na4-4&t=36m41s) is doing as he selects the end of visual-block to effortlessly add quotes. In particular - what is happening around [36:57](https://www.youtube.com/watch?v=aHm36-na4-4&t=36m56s) [![en...
I just found an solution after a lot more searching on google. using treesiter and adding this into the treesitter config got my desired behaviour: ``` require'nvim-treesitter.configs'.setup { indent = { enable = true, }, } ``` Now it works in a .js file perfectly like in a .hmtl which is: ``` <div>|</...
39,575
<p>I'm trying to make semi-automatic parentheses work using vim-arpeggio and ultisnips. Everything works fine except the undo story. What I have now is this:</p> <pre><code>Arpeggioinoremap () ()&lt;c-r&gt;=UltiSnips#ExpandSnippet()&lt;cr&gt; </code></pre> <p>in the <code>.vimrc</code> and</p> <pre><code>snippet () &qu...
[ { "answer_id": 39597, "author": "husB", "author_id": 21495, "author_profile": "https://vi.stackexchange.com/users/21495", "pm_score": 2, "selected": false, "text": "<p>Besides <code>UltiSnips#ExpandSnippet()</code>, there is also <code>UltiSnips#Anon()</code>. The latter expands a snippe...
2022/12/19
[ "https://vi.stackexchange.com/questions/39575", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/12037/" ]
I'm trying to make semi-automatic parentheses work using vim-arpeggio and ultisnips. Everything works fine except the undo story. What I have now is this: ``` Arpeggioinoremap () ()<c-r>=UltiSnips#ExpandSnippet()<cr> ``` in the `.vimrc` and ``` snippet () "paren" i ($1)$0 endsnippet ``` in my snippets file. What...
Background ---------- `UltiSnips#ExpandSnippet()` actually breaks the undo sequence *twice*, once before expansion, and another after the expansion. More precisely, `UltiSnips#ExpandSnippet()` calls `snippet_manager.expand()`, which calls `snippet_manager._try_expand()`. Inspecting the [code](https://github.com/SirVer...
39,588
<p>I have bunch of strings that starts with uppercase letters. I want to change uppercase letters with lowercase letters. Strings are not aligned so visual block mode is not an option. Is it possible to use <code>substitute</code> to do this?</p> <p>Before:</p> <pre><code>'Readable &amp; writeable outside of effects' '...
[ { "answer_id": 39590, "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 <code>\\l</code> or the ´\\L´ operator in the substitution:</p>\n<p>e.g.:</p>\n<pre><code>:%s/...
2022/12/20
[ "https://vi.stackexchange.com/questions/39588", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/25016/" ]
I have bunch of strings that starts with uppercase letters. I want to change uppercase letters with lowercase letters. Strings are not aligned so visual block mode is not an option. Is it possible to use `substitute` to do this? Before: ``` 'Readable & writeable outside of effects' 'Multiple signal reads in same effe...
You can use the `\l` or the ´\L´ operator in the substitution: e.g.: ``` :%s/^\w\+/\l&/ ``` will substitute the first letter of the first words of each line to its lowercase version. ``` :%s/'\(\_[^']*\)'/'\l\1'/g ``` will substitute the first letter of a quoted string to its lowercase version
39,605
<p>I have a long list of sorted words that I would like to shuffle randomly.</p> <p>Could it be done using <code>:sort</code> and some flag?</p> <p>The list is in alphabetical order like:</p> <pre><code>abandon ability able about above ... zebra zero zone zoo </code></pre> <p>Thanks in advance</p>
[ { "answer_id": 39606, "author": "Vivian De Smedt", "author_id": 23502, "author_profile": "https://vi.stackexchange.com/users/23502", "pm_score": 0, "selected": false, "text": "<h2>Solution</h2>\n<p>I would:</p>\n<ul>\n<li><p>Select the list of words</p>\n</li>\n<li><p>Insert a random num...
2022/12/22
[ "https://vi.stackexchange.com/questions/39605", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/44238/" ]
I have a long list of sorted words that I would like to shuffle randomly. Could it be done using `:sort` and some flag? The list is in alphabetical order like: ``` abandon ability able about above ... zebra zero zone zoo ``` Thanks in advance
In Case you are using `vi` with Linux , you can use `shuf` command to "Permute" or "Shuffle" the lines , which are the technical terms to randomize the lines. When the whole file contains the lines , use `:%!shuf` & check the output lines. When the lines are in Part of the file , use `:n,m!shuf` , where the lines bet...
39,627
<p>It has been impossible for me to find an offline Spanish thesaurus in a format that worked in Vim. Libreoffice Spanish Thesaurus looks good, needs some conditional modifications and is 66000 lines long or so. Are vim macros so powerful to accomplish that task?.</p> <p>The Libreoffice thesaurus looks something like t...
[ { "answer_id": 39632, "author": "Enno", "author_id": 6416, "author_profile": "https://vi.stackexchange.com/users/6416", "pm_score": 2, "selected": true, "text": "<p><a href=\"https://github.com/grepsuzette/VIM-thesaurus-files\" rel=\"nofollow noreferrer\">VIM-thesaurus-files</a> provides...
2022/12/25
[ "https://vi.stackexchange.com/questions/39627", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/44871/" ]
It has been impossible for me to find an offline Spanish thesaurus in a format that worked in Vim. Libreoffice Spanish Thesaurus looks good, needs some conditional modifications and is 66000 lines long or so. Are vim macros so powerful to accomplish that task?. The Libreoffice thesaurus looks something like this: ```...
[VIM-thesaurus-files](https://github.com/grepsuzette/VIM-thesaurus-files) provides a script to convert a thesaurus file for Libre Office to one for Vim. You can also find thesaurus files in my repo [vim-thesauri](https://github.com/Konfekt/vim-thesauri). Please be aware of the [caveat](https://github.com/Konfekt/vim-th...
39,642
<p>Currently the default shell nvim uses is <code>cmd.exe</code> I tried changing it by setting shell to powershell in my nvim config but that didn't work, so I tried this command in the nvim command line:</p> <pre><code>:let &amp;shell = 'path/to/powershell.exe' </code></pre> <p>Echo shell command output the powershel...
[ { "answer_id": 39685, "author": "GreatGaja", "author_id": 26340, "author_profile": "https://vi.stackexchange.com/users/26340", "pm_score": 0, "selected": false, "text": "<p>I don't have access to a windows computer or powershell atm. Also my rep is too low to add this as a comment. But h...
2022/12/27
[ "https://vi.stackexchange.com/questions/39642", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/42010/" ]
Currently the default shell nvim uses is `cmd.exe` I tried changing it by setting shell to powershell in my nvim config but that didn't work, so I tried this command in the nvim command line: ``` :let &shell = 'path/to/powershell.exe' ``` Echo shell command output the powershell path and when I executed `:terminal` ...
Permanently means puting it in your `_vimrc`. Open it (or create it if it doesn't exist yet) and add the line ``` set shell=path/to/powershell.exe ``` or maybe ``` let &shell = 'path/to/powershell.exe' ``` You may need to ajust some other parameters also: `shellcmdflag`, `shellquote`, `shellxquote`, `shellpipe`, ...
39,686
<p>I'm new to vim and install that in windows 10.</p> <p>I write this instructions in Vim then in normal mode pressed <code>u</code> and all the instructions disappeared.</p> <pre class="lang-js prettyprint-override"><code>console.log(899) hello you can write some simple Javascript instructions here.... </code></pre> <...
[ { "answer_id": 39687, "author": "Gustav Blomqvist", "author_id": 2689, "author_profile": "https://vi.stackexchange.com/users/2689", "pm_score": 2, "selected": true, "text": "<p>The undo action is per-line if you write a bunch of lines in insert-mode.\nThis is natural as most languages us...
2023/01/03
[ "https://vi.stackexchange.com/questions/39686", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/43603/" ]
I'm new to vim and install that in windows 10. I write this instructions in Vim then in normal mode pressed `u` and all the instructions disappeared. ```js console.log(899) hello you can write some simple Javascript instructions here.... ``` But when I use VsCode and press `Ctrl-z` all the instructions will not dis...
The undo action is per-line if you write a bunch of lines in insert-mode. This is natural as most languages use 1 statement per line (usally). To override this behavior while in insert mode use `Ctrl-g u` to manually add an undo point.
39,720
<p>I need a project manager like VsCode in Vim. This link is the extention that I use in VsCode. <a href="https://marketplace.visualstudio.com/items?itemName=alefragnani.project-manager" rel="nofollow noreferrer">https://marketplace.visualstudio.com/items?itemName=alefragnani.project-manager</a></p> <p>In this extensio...
[ { "answer_id": 39722, "author": "Vivian De Smedt", "author_id": 23502, "author_profile": "https://vi.stackexchange.com/users/23502", "pm_score": 0, "selected": false, "text": "<p>In Vim you have the concept of sessions.\nRestoring a session restores the state of Vim when you saved your s...
2023/01/07
[ "https://vi.stackexchange.com/questions/39720", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/43603/" ]
I need a project manager like VsCode in Vim. This link is the extention that I use in VsCode. <https://marketplace.visualstudio.com/items?itemName=alefragnani.project-manager> In this extension I can bookmark all of my workspaces in a json file, and open them quickly whenever I need.
I am not aware of an existing vim plugin for this, but here are 2 ways you can accomplish similar functionality. --- ### With fzf.vim I accomplished similar functionality to the [Project Manager](https://marketplace.visualstudio.com/items?itemName=alefragnani.project-manager) extension with the [fzf.vim](https://git...
39,721
<p>In <a href="https://github.com/Aster89/vim-softwrap" rel="nofollow noreferrer">this plugin for (soft-)wrapping only the current line</a>, I have defined a highlight group, <a href="https://github.com/Aster89/vim-softwrap/blob/7fb148e19f884594767d94d9c8109ec76b2a08ba/plugin/softwrap.vim#L9" rel="nofollow noreferrer">...
[ { "answer_id": 39722, "author": "Vivian De Smedt", "author_id": 23502, "author_profile": "https://vi.stackexchange.com/users/23502", "pm_score": 0, "selected": false, "text": "<p>In Vim you have the concept of sessions.\nRestoring a session restores the state of Vim when you saved your s...
2023/01/07
[ "https://vi.stackexchange.com/questions/39721", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/6498/" ]
In [this plugin for (soft-)wrapping only the current line](https://github.com/Aster89/vim-softwrap), I have defined a highlight group, [`au ColorScheme * hi SoftWrapHighlightGroup ctermbg=NONE ctermfg=NONE`](https://github.com/Aster89/vim-softwrap/blob/7fb148e19f884594767d94d9c8109ec76b2a08ba/plugin/softwrap.vim#L9), w...
I am not aware of an existing vim plugin for this, but here are 2 ways you can accomplish similar functionality. --- ### With fzf.vim I accomplished similar functionality to the [Project Manager](https://marketplace.visualstudio.com/items?itemName=alefragnani.project-manager) extension with the [fzf.vim](https://git...
39,739
<p>I'm trying to use <a href="https://github.com/davidhalter/jedi-vim" rel="nofollow noreferrer">Jedi</a> to do &quot;jump-to-definition&quot;. For example, if my cursor is on <code>MLPClassifier</code>, I want to be able jump to the place where that class is defined in Python code from the imported library <code>sklea...
[ { "answer_id": 39722, "author": "Vivian De Smedt", "author_id": 23502, "author_profile": "https://vi.stackexchange.com/users/23502", "pm_score": 0, "selected": false, "text": "<p>In Vim you have the concept of sessions.\nRestoring a session restores the state of Vim when you saved your s...
2023/01/10
[ "https://vi.stackexchange.com/questions/39739", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/45006/" ]
I'm trying to use [Jedi](https://github.com/davidhalter/jedi-vim) to do "jump-to-definition". For example, if my cursor is on `MLPClassifier`, I want to be able jump to the place where that class is defined in Python code from the imported library `sklearn`. The [documentation](https://github.com/davidhalter/jedi-vim)...
I am not aware of an existing vim plugin for this, but here are 2 ways you can accomplish similar functionality. --- ### With fzf.vim I accomplished similar functionality to the [Project Manager](https://marketplace.visualstudio.com/items?itemName=alefragnani.project-manager) extension with the [fzf.vim](https://git...
39,749
<p>With <a href="https://vi.stackexchange.com/questions/39721/how-do-i-let-the-user-of-my-plugin-customize-a-custom-highlight-group-i-define">this question</a> I've learned of the existence of <code>hlget</code> and <code>hlID</code>, which I use in <a href="https://github.com/Aster89/vim-softwrap" rel="nofollow norefe...
[ { "answer_id": 39750, "author": "Enlico", "author_id": 6498, "author_profile": "https://vi.stackexchange.com/users/6498", "pm_score": 0, "selected": false, "text": "<p>I've decided to branch on <code>v:versionlong</code> and, in case of old versions, I'm retrieving what <code>hlget</code...
2023/01/10
[ "https://vi.stackexchange.com/questions/39749", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/6498/" ]
With [this question](https://vi.stackexchange.com/questions/39721/how-do-i-let-the-user-of-my-plugin-customize-a-custom-highlight-group-i-define) I've learned of the existence of `hlget` and `hlID`, which I use in [a plugin of mine](https://github.com/Aster89/vim-softwrap) like this: ``` if empty(hlget('SoftWrapHighli...
So Vim Patch [8.2.3578](https://github.com/vim/vim/releases/tag/v8.2.3578) added the ability to get and set the various attributes for highlighting groups in a more efficient manner. This is strictly speaking not required to check whether or not a highlighting group exists, for which Vim has already before that patch ...
39,751
<p>I use <code>BibDesk</code> on a Mac to edit <code>.bib</code> files (in biblatex, using <code>biber</code> to compile). This generally works, but for various reasons it would be nice to be able to edit them in <code>nvim</code> too. My current setup lets me do that reasonably well (I think because of <code>vimtex</c...
[ { "answer_id": 39750, "author": "Enlico", "author_id": 6498, "author_profile": "https://vi.stackexchange.com/users/6498", "pm_score": 0, "selected": false, "text": "<p>I've decided to branch on <code>v:versionlong</code> and, in case of old versions, I'm retrieving what <code>hlget</code...
2023/01/10
[ "https://vi.stackexchange.com/questions/39751", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/37099/" ]
I use `BibDesk` on a Mac to edit `.bib` files (in biblatex, using `biber` to compile). This generally works, but for various reasons it would be nice to be able to edit them in `nvim` too. My current setup lets me do that reasonably well (I think because of `vimtex` and `vim-snippets`), but I haven't figured out a way ...
So Vim Patch [8.2.3578](https://github.com/vim/vim/releases/tag/v8.2.3578) added the ability to get and set the various attributes for highlighting groups in a more efficient manner. This is strictly speaking not required to check whether or not a highlighting group exists, for which Vim has already before that patch ...
39,773
<p>I would like to the present working directory (<code>:pwd</code>) be changed across all tabs and subwindows at the same time. I tried:</p> <pre><code>let PreferredPWD=expand('%:p:h') &quot; The desired working directory &quot; Need to replace PreferredPWD with its string. &quot; None of the following work: tabdo ...
[ { "answer_id": 39750, "author": "Enlico", "author_id": 6498, "author_profile": "https://vi.stackexchange.com/users/6498", "pm_score": 0, "selected": false, "text": "<p>I've decided to branch on <code>v:versionlong</code> and, in case of old versions, I'm retrieving what <code>hlget</code...
2023/01/12
[ "https://vi.stackexchange.com/questions/39773", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/7041/" ]
I would like to the present working directory (`:pwd`) be changed across all tabs and subwindows at the same time. I tried: ``` let PreferredPWD=expand('%:p:h') " The desired working directory " Need to replace PreferredPWD with its string. " None of the following work: tabdo windo cd PreferredPWD cd(PreferredPWD) c...
So Vim Patch [8.2.3578](https://github.com/vim/vim/releases/tag/v8.2.3578) added the ability to get and set the various attributes for highlighting groups in a more efficient manner. This is strictly speaking not required to check whether or not a highlighting group exists, for which Vim has already before that patch ...
39,787
<p>Consider the sentence</p> <blockquote> <p>The sky is very blue today.</p> </blockquote> <p>Let's investigate what happens when we use the vim command <code>daw</code> with the cursor placed at different positions.</p> <ol> <li>Cursor at any character of &quot;blue&quot;</li> </ol> <p><code>The sky is very today</cod...
[ { "answer_id": 39788, "author": "Vivian De Smedt", "author_id": 23502, "author_profile": "https://vi.stackexchange.com/users/23502", "pm_score": 1, "selected": false, "text": "<p>About word vs. WORD:</p>\n<p>To understand word you must group the character set into three families:</p>\n<o...
2023/01/14
[ "https://vi.stackexchange.com/questions/39787", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/45017/" ]
Consider the sentence > > The sky is very blue today. > > > Let's investigate what happens when we use the vim command `daw` with the cursor placed at different positions. 1. Cursor at any character of "blue" `The sky is very today` If we were to add a bunch of spaces between "blue" and "today", `daw` would st...
How `aw` (not `daw`) handles leading and trailing whitespace is unrelated to `word` or `WORD` so there is no reason to bring them up. The difference between `word` and `WORD` only matters when comparing `aw` and `iw` to `aW` and `iW`, which is off topic. `aw` must be considered in contrast with `iw`: if `iw` covers `b...
39,811
<p>In my vimrc I have <code>filetype indent plugin on</code></p> <p>When I write python code, the indentation mostly looks good, but in lists it is too big:</p> <pre><code>def fun(): return 'indent looks good' my_list = [ 'indent too big' ] </code></pre> <p>Why is the indent size different in lists...
[ { "answer_id": 39813, "author": "Burrito", "author_id": 40242, "author_profile": "https://vi.stackexchange.com/users/40242", "pm_score": 2, "selected": true, "text": "<p>Found this section in the python indentation file (<code>/usr/share/vim/vim82/indent/python.vim</code> on my machine):...
2023/01/16
[ "https://vi.stackexchange.com/questions/39811", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/40242/" ]
In my vimrc I have `filetype indent plugin on` When I write python code, the indentation mostly looks good, but in lists it is too big: ``` def fun(): return 'indent looks good' my_list = [ 'indent too big' ] ``` Why is the indent size different in lists from the rest of code? How can I get the...
Found this section in the python indentation file (`/usr/share/vim/vim82/indent/python.vim` on my machine): ``` " When inside parenthesis: If at the first line below the parenthesis add " two 'shiftwidth', otherwise same as previous line. ... return indent(plnum) + (exists("g:pyindent_open_paren") ? eval(g:pyindent_op...
39,847
<p><code>%retab!</code> can replace all characters with spaces.</p> <p>The <code>%</code> in command <code>%retab!</code> means the whole lines in the current file.</p> <p><code>help retab</code> show something such as:</p> <pre><code>With !, Vim also replaces strings of only normal spaces with tabs where appropriate....
[ { "answer_id": 39831, "author": "gildux", "author_id": 28771, "author_profile": "https://vi.stackexchange.com/users/28771", "pm_score": 1, "selected": false, "text": "<p>Do you have report parameter disabled? Check it with <code>:set report?</code> and set the floor value, e.g. 5 (the de...
2023/01/20
[ "https://vi.stackexchange.com/questions/39847", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/44094/" ]
`%retab!` can replace all characters with spaces. The `%` in command `%retab!` means the whole lines in the current file. `help retab` show something such as: ``` With !, Vim also replaces strings of only normal spaces with tabs where appropriate. ``` The `!` in `!ls` means to execute a shell command behind it. ...
Do you have report parameter disabled? Check it with `:set report?` and set the floor value, e.g. 5 (the default is 2) with `:set report=5` So, when you do a `200dd` or `d200d` (or any valid combinations) by accident, you should see in the status line: 200 fewer line Also set commands display with `:set showcmd` to ...
39,860
<p>I want to translate the following functions to vim9script and also combine them into one because they basically do the same</p> <pre><code>function! Hi_Py() let b:current_syntax='' unlet b:current_syntax syntax include @py syntax/python.vim syntax region pythoncode matchgroup=Snip start=&quot;#begin=py&quot...
[ { "answer_id": 39868, "author": "gildux", "author_id": 28771, "author_profile": "https://vi.stackexchange.com/users/28771", "pm_score": 1, "selected": false, "text": "<p>Your two functions looks similar, and lines that differ are the 4th and the\n5th. From there, I think you'll need two ...
2023/01/21
[ "https://vi.stackexchange.com/questions/39860", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/19351/" ]
I want to translate the following functions to vim9script and also combine them into one because they basically do the same ``` function! Hi_Py() let b:current_syntax='' unlet b:current_syntax syntax include @py syntax/python.vim syntax region pythoncode matchgroup=Snip start="#begin=py" end="#end=py" contains...
It is more readable with [`:help interpolated-string`](https://vimhelp.org/eval.txt.html#interpolated-string). Available in vim from May 2022 (> 8.2.4883). ``` vim9script def HiLang(short_name: string, long_name: string) b:current_syntax = '' unlet b:current_syntax execute $'syntax include @{short_name} s...
39,864
<p>I would like to use case-ignoring completion in the file arguments I pass to (n)vim in the internal command prompt:</p> <ol> <li><p>For example, <code>:edit case&lt;tab&gt;</code> should suggest <code>caselower.txt</code> and <code>Caseupper.txt</code>.</p> </li> <li><p>Or <code>:edit some-&lt;tab&gt;</code> should ...
[ { "answer_id": 39868, "author": "gildux", "author_id": 28771, "author_profile": "https://vi.stackexchange.com/users/28771", "pm_score": 1, "selected": false, "text": "<p>Your two functions looks similar, and lines that differ are the 4th and the\n5th. From there, I think you'll need two ...
2023/01/21
[ "https://vi.stackexchange.com/questions/39864", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/45196/" ]
I would like to use case-ignoring completion in the file arguments I pass to (n)vim in the internal command prompt: 1. For example, `:edit case<tab>` should suggest `caselower.txt` and `Caseupper.txt`. 2. Or `:edit some-<tab>` should offer completions including `some_underscore.txt` in addition to `some-dash.txt`) I'...
It is more readable with [`:help interpolated-string`](https://vimhelp.org/eval.txt.html#interpolated-string). Available in vim from May 2022 (> 8.2.4883). ``` vim9script def HiLang(short_name: string, long_name: string) b:current_syntax = '' unlet b:current_syntax execute $'syntax include @{short_name} s...
39,882
<p>As title. In fact, I just encountered a situation where I cannot change the buffer of the current window, which is created by some plugin. So I guess there might be some window/buffer option(s) to prevent the current buffer from being changed.</p>
[ { "answer_id": 39868, "author": "gildux", "author_id": 28771, "author_profile": "https://vi.stackexchange.com/users/28771", "pm_score": 1, "selected": false, "text": "<p>Your two functions looks similar, and lines that differ are the 4th and the\n5th. From there, I think you'll need two ...
2023/01/23
[ "https://vi.stackexchange.com/questions/39882", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/10189/" ]
As title. In fact, I just encountered a situation where I cannot change the buffer of the current window, which is created by some plugin. So I guess there might be some window/buffer option(s) to prevent the current buffer from being changed.
It is more readable with [`:help interpolated-string`](https://vimhelp.org/eval.txt.html#interpolated-string). Available in vim from May 2022 (> 8.2.4883). ``` vim9script def HiLang(short_name: string, long_name: string) b:current_syntax = '' unlet b:current_syntax execute $'syntax include @{short_name} s...
39,902
<p>Having to press the <code>esc</code> key every time that you want to enter <strong>normal mode</strong> is a pain. I have seen multiple answers where people map combinations like <code>jj</code>. But why use that when you can map the <code>capslock</code> key?</p>
[ { "answer_id": 39903, "author": "milintime", "author_id": 45232, "author_profile": "https://vi.stackexchange.com/users/45232", "pm_score": 0, "selected": false, "text": "<p>I did find the answer but it was split up between sites and I thought that it would be a good idea to unite them in...
2023/01/24
[ "https://vi.stackexchange.com/questions/39902", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/45232/" ]
Having to press the `esc` key every time that you want to enter **normal mode** is a pain. I have seen multiple answers where people map combinations like `jj`. But why use that when you can map the `capslock` key?
Edit: my first answer missed the question title, sorry. why vi-map instead of system keys-swap? --------------------------------------- Many people can have access to a Vi-like editor but not to system settings. Think of your university or enterprise account, or any online account in a box that's not your own compute...
39,916
<p>When I run vim with no configuration (--clean), in a bash file I cannot move the cursor before any indented tabs. I remember being annoyed by this before I regularly used vim, but early on as I grew my own configuration this stopped happening at some point.</p> <p>What is the setting that makes this happen? I would ...
[ { "answer_id": 39918, "author": "Vivian De Smedt", "author_id": 23502, "author_profile": "https://vi.stackexchange.com/users/23502", "pm_score": 2, "selected": true, "text": "<p>If you mean move your cursor by using the <kbd>Bcksp</kbd> key.</p>\n<p>The setting that control what you can ...
2023/01/25
[ "https://vi.stackexchange.com/questions/39916", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/37532/" ]
When I run vim with no configuration (--clean), in a bash file I cannot move the cursor before any indented tabs. I remember being annoyed by this before I regularly used vim, but early on as I grew my own configuration this stopped happening at some point. What is the setting that makes this happen? I would like to e...
If you mean move your cursor by using the `Bcksp` key. The setting that control what you can delete with backspace is `backspace` option: ``` set backspace=indent,eol,start ``` I you mean move the cursor using the arrows or `h`, `l` then @romainl is right and it is the `list` option: ``` set nolist ``` Actually ...
39,922
<p>I'm surprised this hasn't been asked yet, but how do I copy non-consecutive lines into the buffer at once?</p> <p>For example, let's say my file looks like this:</p> <pre><code>1 2 3 4 5 6 7 8 9 10 </code></pre> <p>What commands can I use to copy lines 1, 3, and 5 at once? Therefore, when I pasted at the end of the ...
[ { "answer_id": 39923, "author": "romainl", "author_id": 54, "author_profile": "https://vi.stackexchange.com/users/54", "pm_score": 2, "selected": false, "text": "<p>If you can only reference those lines by their number, then there is no built-in, <em>dedicated</em> command for that.</p>\...
2023/01/25
[ "https://vi.stackexchange.com/questions/39922", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/24809/" ]
I'm surprised this hasn't been asked yet, but how do I copy non-consecutive lines into the buffer at once? For example, let's say my file looks like this: ``` 1 2 3 4 5 6 7 8 9 10 ``` What commands can I use to copy lines 1, 3, and 5 at once? Therefore, when I pasted at the end of the file, it'd look like this: ``...
You can "append" to a register when you yank or delete by using its uppercase name, so `"Ayy` yanks the line into the `a` register, but keeps the old contents, too. A quick way to empty a register is `qaq`, which starts recoding in `a` and then stops without adding anything. So `qaq`, then `3G"Ayy` or `:5yank A` would...
39,924
<p>How do you detect if a directory is opened(with <code>:edit</code>) in Vimscript? I am lazy loading a file explorer and need it to load it before I open a directory.</p> <p>One approach I tried using an autocommand that fires on <code>BufRead</code> that calls a function that checks if the current buffer is a direct...
[ { "answer_id": 39923, "author": "romainl", "author_id": 54, "author_profile": "https://vi.stackexchange.com/users/54", "pm_score": 2, "selected": false, "text": "<p>If you can only reference those lines by their number, then there is no built-in, <em>dedicated</em> command for that.</p>\...
2023/01/25
[ "https://vi.stackexchange.com/questions/39924", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/35229/" ]
How do you detect if a directory is opened(with `:edit`) in Vimscript? I am lazy loading a file explorer and need it to load it before I open a directory. One approach I tried using an autocommand that fires on `BufRead` that calls a function that checks if the current buffer is a directory using `isdirectory()`, but ...
You can "append" to a register when you yank or delete by using its uppercase name, so `"Ayy` yanks the line into the `a` register, but keeps the old contents, too. A quick way to empty a register is `qaq`, which starts recoding in `a` and then stops without adding anything. So `qaq`, then `3G"Ayy` or `:5yank A` would...
39,977
<p>To display linenumbers, I can do: <code>:set number</code> in the edited file (that works) or insert <code>set number</code> in the .vimrc (that works too).</p> <p>To change the filetype, I can do: <code>:set filetype=c</code> in the edited file (that works) but when I insert: <code>set filetype=c</code> ...
[ { "answer_id": 39923, "author": "romainl", "author_id": 54, "author_profile": "https://vi.stackexchange.com/users/54", "pm_score": 2, "selected": false, "text": "<p>If you can only reference those lines by their number, then there is no built-in, <em>dedicated</em> command for that.</p>\...
2023/01/31
[ "https://vi.stackexchange.com/questions/39977", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/45322/" ]
To display linenumbers, I can do: `:set number` in the edited file (that works) or insert `set number` in the .vimrc (that works too). To change the filetype, I can do: `:set filetype=c` in the edited file (that works) but when I insert: `set filetype=c` in the .vimrc **it does not work.** I have to use `au[tocmd]`, ...
You can "append" to a register when you yank or delete by using its uppercase name, so `"Ayy` yanks the line into the `a` register, but keeps the old contents, too. A quick way to empty a register is `qaq`, which starts recoding in `a` and then stops without adding anything. So `qaq`, then `3G"Ayy` or `:5yank A` would...
39,995
<p>In general, I have makefiles setup anytime I'm working on C projects. To save and compile these projects, I've bound the <em>'</em> key to do this:</p> <pre><code>map ' :wa&lt;CR&gt;:!make&lt;CR&gt; </code></pre> <p>However, I sometimes open up test files that don't have a makefile, and want to compile those quickly...
[ { "answer_id": 39996, "author": "Maxim Kim", "author_id": 9333, "author_profile": "https://vi.stackexchange.com/users/9333", "pm_score": 3, "selected": false, "text": "<p>Wrap it into a function that should be called from your mapping, for instance:</p>\n<pre><code>func! MakeOrGcc()\n ...
2023/01/31
[ "https://vi.stackexchange.com/questions/39995", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/45331/" ]
In general, I have makefiles setup anytime I'm working on C projects. To save and compile these projects, I've bound the *'* key to do this: ``` map ' :wa<CR>:!make<CR> ``` However, I sometimes open up test files that don't have a makefile, and want to compile those quickly as well: ``` map ' :wa<CR>:!gcc % -o %< &...
Wrap it into a function that should be called from your mapping, for instance: ``` func! MakeOrGcc() :write " check in the current working directory if filereadable('Makefile') :!make else :!gcc % -o %< && ./&< endif endfunc nnoremap ' :call MakeOrGcc()<CR> ```
40,018
<p>I want <strong>/usr/local/share/vim/vimfiles/pack</strong> be used for local packages. I added the following to <strong>/etc/vimrc.local</strong></p> <pre><code>set runtimepath+=/usr/local/share/vim/vimfiles </code></pre> <p>When I start vim I see that <strong>runtimepath</strong> contains <em>/usr/local/share/vim/v...
[ { "answer_id": 40023, "author": "Gustav Blomqvist", "author_id": 2689, "author_profile": "https://vi.stackexchange.com/users/2689", "pm_score": 0, "selected": false, "text": "<p>The <code>/usr</code>directory is outside of your home directory and shared for all users.</p>\n<p>It is not r...
2023/02/02
[ "https://vi.stackexchange.com/questions/40018", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/11022/" ]
I want **/usr/local/share/vim/vimfiles/pack** be used for local packages. I added the following to **/etc/vimrc.local** ``` set runtimepath+=/usr/local/share/vim/vimfiles ``` When I start vim I see that **runtimepath** contains */usr/local/share/vim/vimfiles*, but packages and color schemes are not visible. Of cours...
While I agree with the sentiments that you should do your customization in your home directory, to affect *packages* use `packpath`, not `runtimepath`.
40,022
<p>I like doing things like <code>:b css</code> to jump to the single css file I'm working on.</p> <p>But of course this only works if I only have 1 css file in a buffer.</p> <p>I'm <a href="https://dev.to/iggredible/a-faster-vim-workflow-with-buffers-and-args-51kf" rel="nofollow noreferrer">under the impression</a> th...
[ { "answer_id": 40025, "author": "Friedrich", "author_id": 4866, "author_profile": "https://vi.stackexchange.com/users/4866", "pm_score": 0, "selected": false, "text": "<p>No need to shrug. You can jump to a buffer by its <em>number</em>.</p>\n<p>The <code>:ls</code> command lists all buf...
2023/02/02
[ "https://vi.stackexchange.com/questions/40022", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/42550/" ]
I like doing things like `:b css` to jump to the single css file I'm working on. But of course this only works if I only have 1 css file in a buffer. I'm [under the impression](https://dev.to/iggredible/a-faster-vim-workflow-with-buffers-and-args-51kf) that it is not possible to navigate the arglist via filename in t...
You can definitely navigate the argument list by filename with `:argedit name` but there are two problems with that command: * one is is that `:help :argedit` is a rather low-level command, primarily meant for "adding and editing files" to the argument list, so command-line completion only suggests directories/files a...
40,050
<p>Say I have a file with contents:</p> <pre><code>abc def https://www.google.com </code></pre> <p>and my cursor is on the 3rd line.</p> <p>How do I:</p> <ol> <li>run wget/curl with the contents of that line as argument (in particular, not pass the line as stdin)</li> <li>same as above but put the output onto the line...
[ { "answer_id": 40025, "author": "Friedrich", "author_id": 4866, "author_profile": "https://vi.stackexchange.com/users/4866", "pm_score": 0, "selected": false, "text": "<p>No need to shrug. You can jump to a buffer by its <em>number</em>.</p>\n<p>The <code>:ls</code> command lists all buf...
2023/02/05
[ "https://vi.stackexchange.com/questions/40050", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/45388/" ]
Say I have a file with contents: ``` abc def https://www.google.com ``` and my cursor is on the 3rd line. How do I: 1. run wget/curl with the contents of that line as argument (in particular, not pass the line as stdin) 2. same as above but put the output onto the line below I understand `%` represents the curre...
You can definitely navigate the argument list by filename with `:argedit name` but there are two problems with that command: * one is is that `:help :argedit` is a rather low-level command, primarily meant for "adding and editing files" to the argument list, so command-line completion only suggests directories/files a...
40,063
<p>I've been trying to configure <a href="https://github.com/lervag/vimtex" rel="nofollow noreferrer">vim-tex</a> working on the <a href="https://nvchad.com" rel="nofollow noreferrer">NvChad</a> configs. I got the <code>:VimtexCompile</code> working and giving me output pdf. But the usual <code>&lt;leader&gt;ll</code> ...
[ { "answer_id": 40025, "author": "Friedrich", "author_id": 4866, "author_profile": "https://vi.stackexchange.com/users/4866", "pm_score": 0, "selected": false, "text": "<p>No need to shrug. You can jump to a buffer by its <em>number</em>.</p>\n<p>The <code>:ls</code> command lists all buf...
2023/02/06
[ "https://vi.stackexchange.com/questions/40063", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/45396/" ]
I've been trying to configure [vim-tex](https://github.com/lervag/vimtex) working on the [NvChad](https://nvchad.com) configs. I got the `:VimtexCompile` working and giving me output pdf. But the usual `<leader>ll` is giving me [these errors](https://pastebin.com/vyeLZh4r). Also in vim `{{` would expand to `\left{ \rig...
You can definitely navigate the argument list by filename with `:argedit name` but there are two problems with that command: * one is is that `:help :argedit` is a rather low-level command, primarily meant for "adding and editing files" to the argument list, so command-line completion only suggests directories/files a...
40,071
<p>If I close all buffers, I'm left with the terminal window, which automatically opens whenever I open Vim.</p> <p>I would like it close automatically when I exit Vim.</p> <p>I see that on the NERDTree repo, they included a code that will automatically close NERDTree if it is the last window:</p> <pre><code>&quot; Exi...
[ { "answer_id": 40025, "author": "Friedrich", "author_id": 4866, "author_profile": "https://vi.stackexchange.com/users/4866", "pm_score": 0, "selected": false, "text": "<p>No need to shrug. You can jump to a buffer by its <em>number</em>.</p>\n<p>The <code>:ls</code> command lists all buf...
2023/02/07
[ "https://vi.stackexchange.com/questions/40071", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/45412/" ]
If I close all buffers, I'm left with the terminal window, which automatically opens whenever I open Vim. I would like it close automatically when I exit Vim. I see that on the NERDTree repo, they included a code that will automatically close NERDTree if it is the last window: ``` " Exit Vim if NERDTree is the only ...
You can definitely navigate the argument list by filename with `:argedit name` but there are two problems with that command: * one is is that `:help :argedit` is a rather low-level command, primarily meant for "adding and editing files" to the argument list, so command-line completion only suggests directories/files a...
40,089
<p>I download Vim-plug but I am unable to use it.</p> <p>I have downloaded NERDTree in <code>~/.vim/pack/vendor/start/nerdtree</code>.</p> <p>But when I give command <code>:NERDTree</code> in gVim editor it gives an error:</p> <pre><code>Not an editor command : NERDTree </code></pre>
[ { "answer_id": 40090, "author": "Vivian De Smedt", "author_id": 23502, "author_profile": "https://vi.stackexchange.com/users/23502", "pm_score": 0, "selected": false, "text": "<p>As @Matt suggested add to your <code>.vimrc</code> the following line:</p>\n<pre><code>set runtimepath^=~/vim...
2023/02/09
[ "https://vi.stackexchange.com/questions/40089", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/45446/" ]
I download Vim-plug but I am unable to use it. I have downloaded NERDTree in `~/.vim/pack/vendor/start/nerdtree`. But when I give command `:NERDTree` in gVim editor it gives an error: ``` Not an editor command : NERDTree ```
7th version does not support `:h packages`. Therefore, you have to update your `:h 'runtimepath'` manually. Or simply merge the plugin files/dirs into your ".vim" directory subtree (which is kind of a mess, yeah).
40,092
<p>I want to enable <a href="https://github.com/rking/ag.vim" rel="nofollow noreferrer">vim-ag</a> to search a word inside specific directory.</p> <p>Currently I have the following mapping in my <code>vimrc</code>:</p> <pre><code>noremap &lt;leader&gt;a :Ag! &lt;C-r&gt;=expand('&lt;cword&gt;')&lt;CR&gt;&lt;CR&gt; </co...
[ { "answer_id": 40093, "author": "Vivian De Smedt", "author_id": 23502, "author_profile": "https://vi.stackexchange.com/users/23502", "pm_score": 1, "selected": false, "text": "<p>I would propose you to make sure the current working directory is the directory of the git root.</p>\n<p>To a...
2023/02/09
[ "https://vi.stackexchange.com/questions/40092", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/20287/" ]
I want to enable [vim-ag](https://github.com/rking/ag.vim) to search a word inside specific directory. Currently I have the following mapping in my `vimrc`: ``` noremap <leader>a :Ag! <C-r>=expand('<cword>')<CR><CR> ``` which searchs the `cword` in the current directory. I want to expand it a bit so that I would ...
The right-hand-side of your mapping is a macro: a collection of keystroke that Vim performs for you. This means that, with the cursor on `foo`, your mapping "types" the following in the command-line: ``` Ag! foo ``` and immediately presses `<CR>`, executing the command. If you want a chance to provide a directory, ...
40,097
<p>I have a mapping in my <code>.vimrc</code>.</p> <p>It is the following:</p> <pre><code>nnoremap q; :call Add_comment_css()&lt;CR&gt; </code></pre> <p>And then I can run, say <code>10q;</code></p> <p>And then it will run 10 times.</p> <p>But my problem is that the cursor always moves as well.</p> <p>I want the cursor...
[ { "answer_id": 40098, "author": "Vivian De Smedt", "author_id": 23502, "author_profile": "https://vi.stackexchange.com/users/23502", "pm_score": 3, "selected": true, "text": "<p>You could do:</p>\n<pre><code>function! Add_comment_css(range, line1, line2)\n let l:pos = winsaveview()\n\n ...
2023/02/09
[ "https://vi.stackexchange.com/questions/40097", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/605/" ]
I have a mapping in my `.vimrc`. It is the following: ``` nnoremap q; :call Add_comment_css()<CR> ``` And then I can run, say `10q;` And then it will run 10 times. But my problem is that the cursor always moves as well. I want the cursor to stay in place. I have tried all the solutions here: <https://stackover...
You could do: ``` function! Add_comment_css(range, line1, line2) let l:pos = winsaveview() " Add At Beginning. if a:range == 2 let command = a:line1 ."," . a:line2 .'s/^/\/\*' " echo command execute command elseif a:range == 0 s/^/\/\* endif call winrestview(l:pos) endfunction command! -...
40,102
<p>I have tried to use the following</p> <pre><code>:nnoremap &lt;leader&gt;t :terminal&lt;cr&gt; &lt;c-w&gt;:call term_sendkeys('', &quot;\&lt;lt&gt;c-r&gt;&quot;)&lt;cr&gt; </code></pre> <p>To open a terminal with reverse search waiting for some input, but instead, it writes:</p> <pre><code>^R $ ▉ </code></pre> <p>I ...
[ { "answer_id": 40103, "author": "Vivian De Smedt", "author_id": 23502, "author_profile": "https://vi.stackexchange.com/users/23502", "pm_score": 1, "selected": false, "text": "<p>I would do:</p>\n<pre><code>:nnoremap &lt;leader&gt;t :terminal&lt;Cr&gt;&lt;C-w&gt;:call term_sendkeys('', &...
2023/02/09
[ "https://vi.stackexchange.com/questions/40102", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/43054/" ]
I have tried to use the following ``` :nnoremap <leader>t :terminal<cr> <c-w>:call term_sendkeys('', "\<lt>c-r>")<cr> ``` To open a terminal with reverse search waiting for some input, but instead, it writes: ``` ^R $ ▉ ``` I expected something like this: ``` (reverse-i-search)`': ▉ ``` --- ###### Note: If I...
Using `term_wait` solves the issue, I suppose that the terminal wasn't ready as soon as the keys were sent by vim (*in my slow computer*). By default `term_wait` uses 10 msec, and the problem was the same, with 20 msec `<leader>t` works fine. ``` :nnoremap <leader>t :terminal<CR> <c-w>:call term_wait('', 20)<cr><c-w>...
40,105
<p>Yeah... let me explain.</p> <p>So I have this text that has hyphens on some words at the end of the line to join words, like this:</p> <pre><code>hello, my na- me is bruh... </code></pre> <p>This is a scanned book with OCR, and on every line there's a trailing space.</p> <p>So, what I wanna do is make a shortcut, ...
[ { "answer_id": 40103, "author": "Vivian De Smedt", "author_id": 23502, "author_profile": "https://vi.stackexchange.com/users/23502", "pm_score": 1, "selected": false, "text": "<p>I would do:</p>\n<pre><code>:nnoremap &lt;leader&gt;t :terminal&lt;Cr&gt;&lt;C-w&gt;:call term_sendkeys('', &...
2023/02/09
[ "https://vi.stackexchange.com/questions/40105", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/45450/" ]
Yeah... let me explain. So I have this text that has hyphens on some words at the end of the line to join words, like this: ``` hello, my na- me is bruh... ``` This is a scanned book with OCR, and on every line there's a trailing space. So, what I wanna do is make a shortcut, or map a list of commands (normal mo...
Using `term_wait` solves the issue, I suppose that the terminal wasn't ready as soon as the keys were sent by vim (*in my slow computer*). By default `term_wait` uses 10 msec, and the problem was the same, with 20 msec `<leader>t` works fine. ``` :nnoremap <leader>t :terminal<CR> <c-w>:call term_wait('', 20)<cr><c-w>...
40,114
<p>I am going to write my nvim config in lua. I want to use this config on several computers. And vim configuration on these computers should be slightly different. For example, on some installations I want plugin X to be installed, but on others - not.</p> <p>So I want to create some installation-specific file in ~/.c...
[ { "answer_id": 40115, "author": "Vivian De Smedt", "author_id": 23502, "author_profile": "https://vi.stackexchange.com/users/23502", "pm_score": 0, "selected": false, "text": "<p>You can use <a href=\"https://luarocks.org/modules/dominicletz/lua-yaml\" rel=\"nofollow noreferrer\">lua-yam...
2023/02/10
[ "https://vi.stackexchange.com/questions/40114", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/6194/" ]
I am going to write my nvim config in lua. I want to use this config on several computers. And vim configuration on these computers should be slightly different. For example, on some installations I want plugin X to be installed, but on others - not. So I want to create some installation-specific file in ~/.config/nvi...
Instead of using a separate YAML file, one option is to just use Lua directly. Use simple Lua syntax to populate a Lua table from your local config file. Perhaps something like: ``` localconfig = {} dofile(os.getenv("HOME") .. "/.config/nvim/localconfig.lua") ``` And then in file `~/.config/nvim/localconfig.lua` yo...
40,129
<p>From time to time I accidentally create files with names like &quot;:w&quot; or &quot;:q&quot;. This happens when instead of writing <code>:wq</code> I type <code>:w:q</code> and sometimes, for some reason, even <code>:w:w</code> or <code>:w :w</code>. And this has become too frequent to ignore.</p> <p>My solution t...
[ { "answer_id": 40130, "author": "Vivian De Smedt", "author_id": 23502, "author_profile": "https://vi.stackexchange.com/users/23502", "pm_score": 1, "selected": false, "text": "<p>I would introduce an abbreviation:</p>\n<pre><code>cnoreabbrev &lt;expr&gt; :w (getcmdtype() == ':' &amp;&amp...
2023/02/12
[ "https://vi.stackexchange.com/questions/40129", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/307/" ]
From time to time I accidentally create files with names like ":w" or ":q". This happens when instead of writing `:wq` I type `:w:q` and sometimes, for some reason, even `:w:w` or `:w :w`. And this has become too frequent to ignore. My solution to this problem would be to make vim throw an error if `:w` is given a fil...
Disallow writing files matching `:*` pattern (no matter which command is used): ``` autocmd BufWritePre :* throw "Invalid name" ```
40,136
<p>I am using following mapping. The command works fine but when I open a new file, all the empty lines are highlighted. Could you please check my mapping?</p> <pre><code>vnoremap &lt;leader&gt;n :g/^$/d&lt;CR&gt;&lt;Esc&gt; </code></pre> <p>Thank you!</p>
[ { "answer_id": 40137, "author": "Vivian De Smedt", "author_id": 23502, "author_profile": "https://vi.stackexchange.com/users/23502", "pm_score": 1, "selected": false, "text": "<p>Your command is good but it set the search register <code>/</code> to <code>^$</code> that highlight the empt...
2023/02/13
[ "https://vi.stackexchange.com/questions/40136", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/10057/" ]
I am using following mapping. The command works fine but when I open a new file, all the empty lines are highlighted. Could you please check my mapping? ``` vnoremap <leader>n :g/^$/d<CR><Esc> ``` Thank you!
If you don't want your substitution to impact `hlsearch`, you can execute it within a function, which effectively creates a kind of bubble (a closure) around the commands in its body: ``` function! Trim() range execute a:firstline .. ',' .. a:lastline .. 'g/^$/d' endfunction xnoremap <leader>n :call Trim()<CR> ``...
40,149
<p>I've got a text file, containing following lines</p> <pre><code>&lt;a href=&quot;tg://proxy?server=radan.rooznameh.etellaate.rooz.romatism.sbs&amp;port=443&amp;secret=ee32b920dffb51643028e2f6b878d4eac175706c6f6164626f792e636f6d&amp;bot=@mtpro_xyz_bot#ES&quot;&gt;1&lt;p&gt; &lt;/a&gt; &lt;a href=&quot;tg://proxy?serv...
[ { "answer_id": 40150, "author": "Vivian De Smedt", "author_id": 23502, "author_profile": "https://vi.stackexchange.com/users/23502", "pm_score": 1, "selected": false, "text": "<p>I would do:</p>\n<pre><code>%s/proxy?server=\\zs\\([^&amp;]*\\)\\(&amp;.*\\)\\d\\ze&lt;p&gt;/\\1\\2\\1/\n</co...
2023/02/14
[ "https://vi.stackexchange.com/questions/40149", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/5545/" ]
I've got a text file, containing following lines ``` <a href="tg://proxy?server=radan.rooznameh.etellaate.rooz.romatism.sbs&port=443&secret=ee32b920dffb51643028e2f6b878d4eac175706c6f6164626f792e636f6d&bot=@mtpro_xyz_bot#ES">1<p> </a> <a href="tg://proxy?server=digkala-com-heneri-com.1400.melbourne&port=443&secret=ee00...
You seem to be confused about `:help :global`. The point of `:g/<pattern>/<command>` is to execute `<command>` on **the lines that match `<pattern>`**, not on the matches themselves. This means that, in this case, `:global` is largely unnecessary if you want to use a substitution. Let's simplify your sample a bit: ...
40,164
<p>I want to use <code>filetype=nasm</code> to get syntax highlighting in assembly files (ending with a <code>.asm</code> extension). I have the following autocommand for it:</p> <pre><code>augroup FileTypes au! au BufNewFile,BufRead *.asm :setlocal filetype=nasm augroup END </code></pre> <p>And it works as int...
[ { "answer_id": 40166, "author": "Vivian De Smedt", "author_id": 23502, "author_profile": "https://vi.stackexchange.com/users/23502", "pm_score": 1, "selected": false, "text": "<p>You can't prevent the standard syntax from being sourced (unless you remove the file).\nBut, by introducing y...
2023/02/15
[ "https://vi.stackexchange.com/questions/40164", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/31699/" ]
I want to use `filetype=nasm` to get syntax highlighting in assembly files (ending with a `.asm` extension). I have the following autocommand for it: ``` augroup FileTypes au! au BufNewFile,BufRead *.asm :setlocal filetype=nasm augroup END ``` And it works as intended except for the fact that vim also loads ...
To set nasm as default assembly syntax simply do ``` let g:asmsyntax = 'nasm' ``` Never forget to read help, i.e. `:h asm.vim` (or `:helpgrep nasm`, for example).
40,167
<p>I am using Vim version 9.0.1280.</p> <p>The search and replace command I am using is -</p> <pre><code>:%s/\(_\)\([1-9]\{1\}\)\(_\)/_0\1_/gc </code></pre> <p>When I run this vim offers to replace <code>_1_</code> with <code>_0\1_</code>.</p> <p>What am I doing wrong?</p>
[ { "answer_id": 40168, "author": "Vivian De Smedt", "author_id": 23502, "author_profile": "https://vi.stackexchange.com/users/23502", "pm_score": 1, "selected": true, "text": "<p>I would do:</p>\n<pre><code>:%s/\\(_\\)\\([1-9]\\{1\\}\\)\\(_\\)/_0\\2_/gc\n</code></pre>\n<p>Or more compact:...
2023/02/15
[ "https://vi.stackexchange.com/questions/40167", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/45550/" ]
I am using Vim version 9.0.1280. The search and replace command I am using is - ``` :%s/\(_\)\([1-9]\{1\}\)\(_\)/_0\1_/gc ``` When I run this vim offers to replace `_1_` with `_0\1_`. What am I doing wrong?
I would do: ``` :%s/\(_\)\([1-9]\{1\}\)\(_\)/_0\2_/gc ``` Or more compact: ``` :%s/_\zs\d\{1\}\ze_/0&/gc ``` I limit the part of the regular expression I want to replace with `\zs` and `\ze` and I can use the full pattern `\0` replacement expression. Or as @gildux mention: ``` :%s/\v_(\d{1})_/_0\1_/gc ```
40,198
<h3>Background</h3> <p>Vim uses <a href="https://vim.fandom.com/wiki/Ranges" rel="nofollow noreferrer">ranges</a> to specify which <strong>lines</strong> should be passed to a command. For example, <code>:5,10</code> will use <strong>lines</strong> 5-10, <code>:'a,'b</code> will use the <strong>lines</strong> between m...
[ { "answer_id": 40200, "author": "romainl", "author_id": 54, "author_profile": "https://vi.stackexchange.com/users/54", "pm_score": 1, "selected": false, "text": "<h2>Short answer</h2>\n<p>You can't. Ex commands are always linewise and there is no way around that.</p>\n<h2>Long answer</h2...
2023/02/17
[ "https://vi.stackexchange.com/questions/40198", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/25982/" ]
### Background Vim uses [ranges](https://vim.fandom.com/wiki/Ranges) to specify which **lines** should be passed to a command. For example, `:5,10` will use **lines** 5-10, `:'a,'b` will use the **lines** between mark `a` and mark `b`, and `:'<,'>` will use the **lines** that are selected in visual mode. ### Question...
Thanks to @romainl for the help. Here's a solution that uses yanking and seems to work well: 1. `y` to yank the selection 2. `:!echo` to start the command 3. `<C-r>=escape(substitute(shellescape(getreg('"')), '\n', '\r', 'g'), '%!')<CR>` to put the contents of the `"` register into the command line 4. `<Bar> cat` to...
40,208
<p>Since recently my syntax highlighting for <code>ft=sh</code> (also <code>syn=sh</code> is set) is broken:</p> <p><a href="https://i.stack.imgur.com/Z6stM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Z6stM.png" alt="enter image description here" /></a></p> <p>Why is that? How can I fix it?</p> <...
[ { "answer_id": 40242, "author": "VladSavitsky", "author_id": 8280, "author_profile": "https://vi.stackexchange.com/users/8280", "pm_score": 0, "selected": false, "text": "<p>Downgrade to 8.2 version of VIM because it's VIM9 bug (not ALE plugin bug):</p>\n<pre><code>mkdir ~/temp; \ngit cl...
2023/02/18
[ "https://vi.stackexchange.com/questions/40208", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/6154/" ]
Since recently my syntax highlighting for `ft=sh` (also `syn=sh` is set) is broken: [![enter image description here](https://i.stack.imgur.com/Z6stM.png)](https://i.stack.imgur.com/Z6stM.png) Why is that? How can I fix it? Edit: I'm using Vim 9.0 with patches 1-1302. I add here the code from the screenshot. The co...
It is a known bug which is fixed in the author's source code, see [author's reply](https://groups.google.com/g/vim_dev/c/qaw5JHA2zxY/m/ieLq_uMjAgAJ). It should appear sometime in the future in main vim runtime.
40,210
<p>I have tried adding this line to the init.lua but it doesn't work and I don't understand the syntax:</p> <pre><code>local g:terminal_emulator=&quot;powershell&quot; </code></pre> <p>I get an error upon running the <code>source</code> command: it says <code>unexpected symbol near :</code></p>
[ { "answer_id": 40242, "author": "VladSavitsky", "author_id": 8280, "author_profile": "https://vi.stackexchange.com/users/8280", "pm_score": 0, "selected": false, "text": "<p>Downgrade to 8.2 version of VIM because it's VIM9 bug (not ALE plugin bug):</p>\n<pre><code>mkdir ~/temp; \ngit cl...
2023/02/18
[ "https://vi.stackexchange.com/questions/40210", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/42473/" ]
I have tried adding this line to the init.lua but it doesn't work and I don't understand the syntax: ``` local g:terminal_emulator="powershell" ``` I get an error upon running the `source` command: it says `unexpected symbol near :`
It is a known bug which is fixed in the author's source code, see [author's reply](https://groups.google.com/g/vim_dev/c/qaw5JHA2zxY/m/ieLq_uMjAgAJ). It should appear sometime in the future in main vim runtime.