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
18,169
<p>Is it possible to surround a selected part of a line with <code>/*</code> and <code>*/</code>?</p> <pre><code>start COMMENT ME end start /*COMMENT ME*/ end </code></pre>
[ { "answer_id": 18170, "author": "Luc Hermitte", "author_id": 626, "author_profile": "https://vi.stackexchange.com/users/626", "pm_score": 0, "selected": false, "text": "<p>The simple (redoable version, that messes <code>*</code> register) is</p>\n\n<pre><code>xnoremap µ s/* &lt;c-r&gt;\"...
2018/12/05
[ "https://vi.stackexchange.com/questions/18169", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/19811/" ]
Is it possible to surround a selected part of a line with `/*` and `*/`? ``` start COMMENT ME end start /*COMMENT ME*/ end ```
There is a plugin name NerdCommenter provide many ways of commenting, includes `/* */`: <https://github.com/scrooloose/nerdcommenter> If you just need a quick solution, here is the macro which does the trick: **Update:** `let @j="viws/*<esc>pa */<esc>"` Let save it to your `.vimrc` file then using by moving the curs...
18,174
<p>I am making a table which has chemical formulas in the first column so I need the integers as subscripts to use it in a LaTex file.</p> <p>I want to transform <code>CH4 &amp;</code> to <code>CH$_4$ &amp;</code>, <code>C2H5 &amp;</code> to <code>C$_2$H$_5$ &amp;</code> and so on. How do I select all integers before ...
[ { "answer_id": 18176, "author": "Rich", "author_id": 343, "author_profile": "https://vi.stackexchange.com/users/343", "pm_score": 3, "selected": true, "text": "<p>Presuming you are only interested in replacing the numbers before the <em>first</em> ampersand on each line, one fairly crude...
2018/12/05
[ "https://vi.stackexchange.com/questions/18174", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/14185/" ]
I am making a table which has chemical formulas in the first column so I need the integers as subscripts to use it in a LaTex file. I want to transform `CH4 &` to `CH$_4$ &`, `C2H5 &` to `C$_2$H$_5$ &` and so on. How do I select all integers before the occurrence of `&` in a line and add the suffix and a prefix to it?
Presuming you are only interested in replacing the numbers before the *first* ampersand on each line, one fairly crude way to do it is to first split the lines on the first ampersand, then perform the substitutions, and then rejoin the lines: ``` :g/\&/norm! f&i^M :g/^[^&]/s/\d\+/$_\0$/g :g/^&/norm! kJ ``` In the fi...
18,195
<p>I have a <code>.gvimrc</code> file created to configure <code>MacVim</code>. I'm using <code>Plug</code> for package management.</p> <p>My <code>.gvimrc</code> looks as follows:</p> <pre><code>call plug#begin() Plug 'tpope/vim-sensible' " sensible defaults Plug 'joshdick/onedark.vim' Plug 'sheerun/vim-polyglot' "...
[ { "answer_id": 18196, "author": "Maxim Kim", "author_id": 9333, "author_profile": "https://vi.stackexchange.com/users/9333", "pm_score": 0, "selected": false, "text": "<p>Not sure if this is a good idea -- I think it is better to find out root cause of the problem.</p>\n\n<p>Anyway to ru...
2018/12/07
[ "https://vi.stackexchange.com/questions/18195", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/5165/" ]
I have a `.gvimrc` file created to configure `MacVim`. I'm using `Plug` for package management. My `.gvimrc` looks as follows: ``` call plug#begin() Plug 'tpope/vim-sensible' " sensible defaults Plug 'joshdick/onedark.vim' Plug 'sheerun/vim-polyglot' " syntax highlight Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeT...
From [Hotschke in the comments](https://vi.stackexchange.com/questions/18195/need-to-run-pluginstall-on-each-open#comment31342_18195): > > Please read [`:help load-plugins`](https://vimhelp.appspot.com/starting.txt.html#load-plugins): In step (4) basically `:runtime! plugin/**/*.vim` happens which is before your gvim...
18,203
<p>I find that when running <code>:echo message</code> with a message variable that contains newlines, it displays the newline character as <code>^@</code>. Often I'd prefer it to actually be split on a new line though. Do I have to split up the string manually and then make multiple calls to echo or is there a simpl...
[ { "answer_id": 18204, "author": "B Layer", "author_id": 11054, "author_profile": "https://vi.stackexchange.com/users/11054", "pm_score": 4, "selected": true, "text": "<p>You originally mention <code>:echo</code> but based on your example it's <code>:echom</code> that is causing you issu...
2018/12/08
[ "https://vi.stackexchange.com/questions/18203", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/132/" ]
I find that when running `:echo message` with a message variable that contains newlines, it displays the newline character as `^@`. Often I'd prefer it to actually be split on a new line though. Do I have to split up the string manually and then make multiple calls to echo or is there a simpler way to do that? edit: H...
You originally mention `:echo` but based on your example it's `:echom` that is causing you issues so assuming that's right... Some choices depending on your specific needs (e.g. do you care about the message being saved to the message history)... ``` :echo "foo\nbar" :echon "foo\nbar" :echom "foo" | echom "bar" ``...
18,222
<p>I have been trying to <strong>compile Vim with python3</strong> on my Mac for many hours, as a result, it looks fine now, as the following:</p> <pre><code>VIM - Vi IMproved 8.1 (2018 May 18, compiled Dec 9 2018 00:37:54) macOS version Included patches: 1-573 Huge version without GUI. +python/dyn +python3/dyn </code...
[ { "answer_id": 18653, "author": "peter", "author_id": 20653, "author_profile": "https://vi.stackexchange.com/users/20653", "pm_score": 2, "selected": false, "text": "<p>Find your dynamic python lib, for example <code>libpython3.6m.so.1.0</code>. Then put it in your <code>.vimrc</code> li...
2018/12/10
[ "https://vi.stackexchange.com/questions/18222", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/20138/" ]
I have been trying to **compile Vim with python3** on my Mac for many hours, as a result, it looks fine now, as the following: ``` VIM - Vi IMproved 8.1 (2018 May 18, compiled Dec 9 2018 00:37:54) macOS version Included patches: 1-573 Huge version without GUI. +python/dyn +python3/dyn ``` but when I tried to test us...
Find your dynamic python lib, for example `libpython3.6m.so.1.0`. Then put it in your `.vimrc` like this: ``` set pythonthreedll=/location/of/your/python/lib/libpython3.6m.so.1.0 ``` Of course, change the version of the library name accordingly.
18,231
<p>As I am setting .vimrc, I found these two code blocks have the same functionality.</p> <pre><code>au Filetype python set \ tabstop=4 \ softtabstop=4 \ shiftwidth=4 \ textwidth=79 </code></pre> <p>and</p> <pre><code>au BufNewFile,BufRead *.py \ set tabstop=4 \ set softtabstop=4 \ se...
[ { "answer_id": 18232, "author": "Rich", "author_id": 343, "author_profile": "https://vi.stackexchange.com/users/343", "pm_score": 5, "selected": true, "text": "<p>Your intuition is correct: the two autocommands are very similar.</p>\n<p>The second autocommand runs when you read or start ...
2018/12/10
[ "https://vi.stackexchange.com/questions/18231", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/20138/" ]
As I am setting .vimrc, I found these two code blocks have the same functionality. ``` au Filetype python set \ tabstop=4 \ softtabstop=4 \ shiftwidth=4 \ textwidth=79 ``` and ``` au BufNewFile,BufRead *.py \ set tabstop=4 \ set softtabstop=4 \ set shiftwidth=4 \ set textwidth=79...
Your intuition is correct: the two autocommands are very similar. The second autocommand runs when you read or start editing a new file with a name that ends in the `.py` extension. The first runs when the file type is set to Python, which Vim will generally do automatically for `.py` files. However, try running the ...
18,237
<p>This is my first-post and question here so please be gentle (but also tell me if, it I wasn't specific enough etc...) </p> <p>So my questions seems rather simple to me, but still blocks me and I can't find anything in the net helping me (for the first time in my life kind of..)</p> <p>I simply have to edit many (~...
[ { "answer_id": 18232, "author": "Rich", "author_id": 343, "author_profile": "https://vi.stackexchange.com/users/343", "pm_score": 5, "selected": true, "text": "<p>Your intuition is correct: the two autocommands are very similar.</p>\n<p>The second autocommand runs when you read or start ...
2018/12/11
[ "https://vi.stackexchange.com/questions/18237", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/20157/" ]
This is my first-post and question here so please be gentle (but also tell me if, it I wasn't specific enough etc...) So my questions seems rather simple to me, but still blocks me and I can't find anything in the net helping me (for the first time in my life kind of..) I simply have to edit many (~100) files. I hav...
Your intuition is correct: the two autocommands are very similar. The second autocommand runs when you read or start editing a new file with a name that ends in the `.py` extension. The first runs when the file type is set to Python, which Vim will generally do automatically for `.py` files. However, try running the ...
18,238
<p>If I create a file without an EOL, for example:</p> <pre><code>$ echo -n "1" &gt; test </code></pre> <p>...and then open it in vim:</p> <pre><code>$ vim --clean test </code></pre> <p>...the left hand side of the statusline looks like:</p> <pre><code>"test" [noeol] 1L, 1C </code></pre> <p>Yet when I open the fi...
[ { "answer_id": 18232, "author": "Rich", "author_id": 343, "author_profile": "https://vi.stackexchange.com/users/343", "pm_score": 5, "selected": true, "text": "<p>Your intuition is correct: the two autocommands are very similar.</p>\n<p>The second autocommand runs when you read or start ...
2018/12/11
[ "https://vi.stackexchange.com/questions/18238", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/1643/" ]
If I create a file without an EOL, for example: ``` $ echo -n "1" > test ``` ...and then open it in vim: ``` $ vim --clean test ``` ...the left hand side of the statusline looks like: ``` "test" [noeol] 1L, 1C ``` Yet when I open the file with my own statusline there is no [noeol] flag. I cannot see any inform...
Your intuition is correct: the two autocommands are very similar. The second autocommand runs when you read or start editing a new file with a name that ends in the `.py` extension. The first runs when the file type is set to Python, which Vim will generally do automatically for `.py` files. However, try running the ...
18,295
<h1>How to set a colorscheme that still shows spelling errors?</h1> <p>I am looking for two combined effects that I can acquire separately but not yet together. </p> <ol> <li><p><strong>Set Colorscheme alone: OK</strong>. If I want highlights on spelling mistakes I can use a <code>.vimrc</code> file with this single ...
[ { "answer_id": 18298, "author": "Rich", "author_id": 343, "author_profile": "https://vi.stackexchange.com/users/343", "pm_score": 4, "selected": true, "text": "<p>I'm going to take a stab in the dark and suggest that your configuration is probably resulting in no highlighting.</p>\n\n<p>...
2018/12/15
[ "https://vi.stackexchange.com/questions/18295", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/12815/" ]
How to set a colorscheme that still shows spelling errors? ========================================================== I am looking for two combined effects that I can acquire separately but not yet together. 1. **Set Colorscheme alone: OK**. If I want highlights on spelling mistakes I can use a `.vimrc` file with th...
I'm going to take a stab in the dark and suggest that your configuration is probably resulting in no highlighting. You can check this with the command `:verbose highlight SpellBad`: if the `xxx` at the start of the line is not highlighted, then badly spelled words won't be highlighted, either. If this is the problem,...
18,309
<p>Based on the accepted answer <a href="https://vi.stackexchange.com/questions/18029/get-immediate-feedback-about-a-search-string-with-no-matches-in-vim">to this previous question</a>, I put the code below in my <code>.vimrc</code>, which changes the color of my statusline depending on whether my search (started with...
[ { "answer_id": 18311, "author": "Bananach", "author_id": 18613, "author_profile": "https://vi.stackexchange.com/users/18613", "pm_score": 0, "selected": false, "text": "<pre><code>if searchString != \"\"\n let newBG = search(searchString) != 0 ? \"green\" : \"red\"\n execute(\"hi S...
2018/12/17
[ "https://vi.stackexchange.com/questions/18309", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/18613/" ]
Based on the accepted answer [to this previous question](https://vi.stackexchange.com/questions/18029/get-immediate-feedback-about-a-search-string-with-no-matches-in-vim), I put the code below in my `.vimrc`, which changes the color of my statusline depending on whether my search (started with `/` or `?`) yields result...
I think the main problem is that the [`search()`](https://vimhelp.org/eval.txt.html#search%28%29) function is moving your cursor. You can fix this by passing the `'n'` flag: ``` let newBG = search(searchString, 'n') != 0 ? "green" : "red" ``` Then you have the problem that when you first type `/` the code highlights...
18,336
<p>When the number of text lines is less than a window height, tilde (~) lines are displayed until the bottom of the window. I want to decrease the window height just enough to display all the lines and not to show any tilde lines.</p> <p>One solution is to calculate how many visible lines are required to display all....
[ { "answer_id": 18338, "author": "Christian Brabandt", "author_id": 71, "author_profile": "https://vi.stackexchange.com/users/71", "pm_score": 1, "selected": false, "text": "<p>I think this is not easily to calculate, since you have to consider e.g. wrapped lines and the winbar. </p>\n\n<...
2018/12/19
[ "https://vi.stackexchange.com/questions/18336", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/1641/" ]
When the number of text lines is less than a window height, tilde (~) lines are displayed until the bottom of the window. I want to decrease the window height just enough to display all the lines and not to show any tilde lines. One solution is to calculate how many visible lines are required to display all. However, ...
I think this is not easily to calculate, since you have to consider e.g. wrapped lines and the winbar. The closest I can think of (without taking care of wrapping and a possible winbar), is something like this: ``` echo winheight(0) - (line('w$')-line('w0')+1) ``` This calculates the height of the current window a...
18,342
<p><strong>How do I replace a visual selection with some register content without overwriting the unnamed ("") register by the visual selection?</strong></p> <p>The question</p> <p><a href="https://stackoverflow.com/questions/3837772/vim-replace-selection-with-default-buffer-without-overwriting-the-buffer">https://st...
[ { "answer_id": 18338, "author": "Christian Brabandt", "author_id": 71, "author_profile": "https://vi.stackexchange.com/users/71", "pm_score": 1, "selected": false, "text": "<p>I think this is not easily to calculate, since you have to consider e.g. wrapped lines and the winbar. </p>\n\n<...
2018/12/19
[ "https://vi.stackexchange.com/questions/18342", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/18613/" ]
**How do I replace a visual selection with some register content without overwriting the unnamed ("") register by the visual selection?** The question <https://stackoverflow.com/questions/3837772/vim-replace-selection-with-default-buffer-without-overwriting-the-buffer> is basically the same, however the answer `xnor...
I think this is not easily to calculate, since you have to consider e.g. wrapped lines and the winbar. The closest I can think of (without taking care of wrapping and a possible winbar), is something like this: ``` echo winheight(0) - (line('w$')-line('w0')+1) ``` This calculates the height of the current window a...
18,344
<p>See the following example:</p> <pre><code>" open a file with 20+ lines. 1gg " jump to line 1 3gg " jump to line 3 5gg " jump to line 5 7gg " jump to line 7 ctrl+O " back to line 5 ctrl+O " back to line 3 20gg " jump to line 20 ctrl+O " back to line 3 ctrl+O " back to line 7!!!! But what I expected is ...
[ { "answer_id": 23117, "author": "sevenever", "author_id": 27279, "author_profile": "https://vi.stackexchange.com/users/27279", "pm_score": 2, "selected": false, "text": "<p>I had exactly the same problem as yours, which annoyed me years. Now I add a <a href=\"https://github.com/sevenever...
2018/12/19
[ "https://vi.stackexchange.com/questions/18344", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/20239/" ]
See the following example: ``` " open a file with 20+ lines. 1gg " jump to line 1 3gg " jump to line 3 5gg " jump to line 5 7gg " jump to line 7 ctrl+O " back to line 5 ctrl+O " back to line 3 20gg " jump to line 20 ctrl+O " back to line 3 ctrl+O " back to line 7!!!! But what I expected is back to line 1...
Neovim has now a [jumplist-stack](https://neovim.io/doc/user/motion.html#jumplist-stack) setting that makes the jumplist behave like the tag stack: ``` set jumpoptions+=stack ``` Unfortunately I do not think vim has a similar option yet.
18,353
<p><strong>Context</strong></p> <p>Say in vim, after <code>:grep text *</code>, then <code>:copen</code>, then cursor in a quickfix window, which has contents like below</p> <pre><code>some-very-very-very-long-path/file1.txt|1 col 46| some text some-very-very-very-long-path/file2.txt|84 col 34| another text some-very...
[ { "answer_id": 18359, "author": "Rich", "author_id": 343, "author_profile": "https://vi.stackexchange.com/users/343", "pm_score": 4, "selected": true, "text": "<p>You can use the <code>conceal</code> feature for this.</p>\n<p>Add the following to the file <code>~/.vim/after/syntax/qf.vim...
2018/12/20
[ "https://vi.stackexchange.com/questions/18353", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/10254/" ]
**Context** Say in vim, after `:grep text *`, then `:copen`, then cursor in a quickfix window, which has contents like below ``` some-very-very-very-long-path/file1.txt|1 col 46| some text some-very-very-very-long-path/file2.txt|84 col 34| another text some-very-very-very-long-path/file3.txt|243 col 29| yetanother te...
You can use the `conceal` feature for this. Add the following to the file `~/.vim/after/syntax/qf.vim` (first creating the file if necessary): ``` syntax match ConcealedDetails /\v^[^|]*\|[^|]*\| / conceal setlocal conceallevel=2 setlocal concealcursor=nvic ``` The first line sets up a syntax item to conceal anythi...
18,357
<p>Is there a way to select multiple files not one by one (with <code>mf</code>)?</p> <ul> <li>I can see in the docs <code>:MF</code> command that do nothing for me. (<code>:MF *.vim</code>)</li> <li>I also have tried <code>mr</code> supplying it <code>*.vim$</code> in the folder full of vim files -- nothing happens</...
[ { "answer_id": 21951, "author": "Maxim Kim", "author_id": 9333, "author_profile": "https://vi.stackexchange.com/users/9333", "pm_score": 1, "selected": true, "text": "<p>Ok, I had a time to check netrw code.</p>\n\n<p>Looks like there is either a bug for a windows or just a bug (because ...
2018/12/20
[ "https://vi.stackexchange.com/questions/18357", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/9333/" ]
Is there a way to select multiple files not one by one (with `mf`)? * I can see in the docs `:MF` command that do nothing for me. (`:MF *.vim`) * I also have tried `mr` supplying it `*.vim$` in the folder full of vim files -- nothing happens Or they do not work in windows?
Ok, I had a time to check netrw code. Looks like there is either a bug for a windows or just a bug (because it also doesn't work on my WSL debian). The code in question is in function `s:NetrwMarkFiles(islocal,...)` on line `6660`: ``` fun! s:NetrwMarkFiles(islocal,...) " call Dfunc("s:NetrwMarkFiles(islocal=".a:is...
18,367
<p>I want to implement something similar to Org mode M-RET into neovim. In Org mode it creates new list item or heading depending on what line the point is on.</p> <p>I'm thinking of a mapping in neovim that copies everything from the beginning of the current line until the first alphanumeric character of the line and...
[ { "answer_id": 18373, "author": "TheMeaningfulEngineer", "author_id": 7129, "author_profile": "https://vi.stackexchange.com/users/7129", "pm_score": 0, "selected": false, "text": "<p>Adding this to <code>~/.config/init.vim</code> solved it:</p>\n\n<pre><code>\" Split into a new terminal ...
2018/12/21
[ "https://vi.stackexchange.com/questions/18367", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/20258/" ]
I want to implement something similar to Org mode M-RET into neovim. In Org mode it creates new list item or heading depending on what line the point is on. I'm thinking of a mapping in neovim that copies everything from the beginning of the current line until the first alphanumeric character of the line and puts it o...
This is a documented 'feature' of `:tnoremap` as `tnoremap` effectively only work for insert mode style actions and thus any variant using `tmap` will not work. Adding the below to `init.vim` will remap the action of Ctrl-w + s in normal mode only for the terminal buffer `autocmd BufWinEnter,WinEnter term://* nnorema...
18,387
<p>I am looking for a way to toggle between these two layouts:</p> <pre><code>------- | | | ------- ------- | | ------- | | ------- </code></pre> <p>I only have two windows and I need to switch the layout often. I need a solution that will preserve the aspect ratio of windows in both horizontal and vertica...
[ { "answer_id": 19634, "author": "Kaan", "author_id": 5526, "author_profile": "https://vi.stackexchange.com/users/5526", "pm_score": 2, "selected": false, "text": "<p>add this to your <code>~/.vimrc</code> (use whatever function-key numbers you want)</p>\n\n<pre><code>:map &lt;F3&gt; &lt;...
2018/12/25
[ "https://vi.stackexchange.com/questions/18387", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/19475/" ]
I am looking for a way to toggle between these two layouts: ``` ------- | | | ------- ------- | | ------- | | ------- ``` I only have two windows and I need to switch the layout often. I need a solution that will preserve the aspect ratio of windows in both horizontal and vertical split layouts, so I don'...
Use tabs. Tabs in Vim function more like OS-level virtual desktops than tabs in most other text editors. Combined with the Vim's ability to display the same buffer in multiple splits, and you've got a built-in solution to your needs. Set up your first layout as you normally would, then ``` :tab split ``` to open a ...
18,398
<p>I'm going nuts trying to get this mapping to work. It's so simple yet doesn't work.</p> <p>with the mapping removed moves me off of nerd tree to the main window to it's right. Great.</p> <p>When I added the following mapping, nothing happens with <code>z;</code></p> <pre><code>nnoremap ; l nnoremap l k nnorema...
[ { "answer_id": 19634, "author": "Kaan", "author_id": 5526, "author_profile": "https://vi.stackexchange.com/users/5526", "pm_score": 2, "selected": false, "text": "<p>add this to your <code>~/.vimrc</code> (use whatever function-key numbers you want)</p>\n\n<pre><code>:map &lt;F3&gt; &lt;...
2018/12/26
[ "https://vi.stackexchange.com/questions/18398", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/20308/" ]
I'm going nuts trying to get this mapping to work. It's so simple yet doesn't work. with the mapping removed moves me off of nerd tree to the main window to it's right. Great. When I added the following mapping, nothing happens with `z;` ``` nnoremap ; l nnoremap l k nnoremap k j nnoremap j h nnoremap <C-W><Up>...
Use tabs. Tabs in Vim function more like OS-level virtual desktops than tabs in most other text editors. Combined with the Vim's ability to display the same buffer in multiple splits, and you've got a built-in solution to your needs. Set up your first layout as you normally would, then ``` :tab split ``` to open a ...
18,417
<p>I have set my sign column background using <code>hi SignColumn ctermbg=236</code> in my colorscheme file. However, it seems that the background colors for where there are signs has not been changed, and is the same as my default background color. </p> <p>Is there a way of changing the background (and if possible, f...
[ { "answer_id": 18422, "author": "B Layer", "author_id": 11054, "author_profile": "https://vi.stackexchange.com/users/11054", "pm_score": 2, "selected": false, "text": "<p><em>Note: Written before OP added the relatively important detail that the signs are generated by Syntastic. Ergo, a ...
2018/12/28
[ "https://vi.stackexchange.com/questions/18417", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/4962/" ]
I have set my sign column background using `hi SignColumn ctermbg=236` in my colorscheme file. However, it seems that the background colors for where there are signs has not been changed, and is the same as my default background color. Is there a way of changing the background (and if possible, foreground) colors of ...
From the docs (`:help syntastic-error-signs`): ``` Signs are colored using the Error and Todo syntax highlight groups by default (see |group-name|). If you wish to customize the colors for the signs, you can use the following groups:     SyntasticErrorSign - For syntax errors, links to "error" by default     Syntastic...
18,426
<p>Is it possible to show all changes made to a buffer since the buffer was opened?</p> <p>This question <a href="https://stackoverflow.com/questions/749297/can-i-see-changes-before-i-save-my-file-in-vim">https://stackoverflow.com/questions/749297/can-i-see-changes-before-i-save-my-file-in-vim</a> is related, but asks...
[ { "answer_id": 18428, "author": "Eric Mintz", "author_id": 20323, "author_profile": "https://vi.stackexchange.com/users/20323", "pm_score": -1, "selected": false, "text": "<p>This will do what you're looking for:</p>\n\n<pre><code>:w !diff % -\n</code></pre>\n" }, { "answer_id": ...
2018/12/30
[ "https://vi.stackexchange.com/questions/18426", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/18613/" ]
Is it possible to show all changes made to a buffer since the buffer was opened? This question <https://stackoverflow.com/questions/749297/can-i-see-changes-before-i-save-my-file-in-vim> is related, but asks for changes since the last write, which can easily be accomplished by looking at the file on the file system. ...
I played around. Could you try the following (rarely tested): ``` autocmd BufReadPost * let b:undo_seq_load=changenr() function! DiffSinceLoad() let tmpa = tempname() let tmpb = tempname() let curchange=changenr() exe "undo " . b:undo_seq_load exec 'w '.tmpa exe "undo " . curchange exec 'w...
18,433
<p>I've got Vim installed on MacOS using Brew and it installs with <code>+python3</code> support for Python 3.7.2 by default.</p> <p>I'm writing a Vim plugin which utilises some Python 3.7 and would like this to be able to work on parity with Linux with how it works on MacOS.</p> <p>In a Docker container with Ubuntu ...
[ { "answer_id": 18509, "author": "João A. Toledo", "author_id": 11384, "author_profile": "https://vi.stackexchange.com/users/11384", "pm_score": 5, "selected": true, "text": "<p>Probably your default <code>python3</code> is <code>3.6</code>. You need, then, tell the build process to use <...
2018/12/31
[ "https://vi.stackexchange.com/questions/18433", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/7119/" ]
I've got Vim installed on MacOS using Brew and it installs with `+python3` support for Python 3.7.2 by default. I'm writing a Vim plugin which utilises some Python 3.7 and would like this to be able to work on parity with Linux with how it works on MacOS. In a Docker container with Ubuntu Bionic I've tried installing...
Probably your default `python3` is `3.6`. You need, then, tell the build process to use `python3.7`. You can do that with the parameters `--with-python3-command`: ``` ./configure --with-python3-command=python3.7 \ --with-python3-config-dir=/usr/lib/python3.7/config-3.7m-x86_64-linux-gnu \ ... (...
18,453
<p>I'm using vim 8.1 on windows. The IT department has set $HOME to a slow network drive. Every time a file gets written to $HOME vim slows down.</p> <p>I have $VIM/vimrc with the following content.</p> <pre><code>let $HOME = $USERPROFILE </code></pre> <p>This used to work, but now netrw still creates files on the n...
[ { "answer_id": 18458, "author": "Charles Gueunet", "author_id": 15134, "author_profile": "https://vi.stackexchange.com/users/15134", "pm_score": 0, "selected": false, "text": "<p>You can use the <code>-u</code> option to give an alternate <em>.vimrc</em> file of your choice when starting...
2019/01/04
[ "https://vi.stackexchange.com/questions/18453", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/-1/" ]
I'm using vim 8.1 on windows. The IT department has set $HOME to a slow network drive. Every time a file gets written to $HOME vim slows down. I have $VIM/vimrc with the following content. ``` let $HOME = $USERPROFILE ``` This used to work, but now netrw still creates files on the network drive. How do I change $H...
After you answered the question yourself, the focus shifted. It seems the Question is now "How can I prevent Vim from checking for `$HOME/_vimrc`?". Try the following: * Create the file `$USERPROFILE/vimrc` with all your configuration. * Create the environment variable `VIMINIT` with the value `source $USERPROFILE/vi...
18,467
<p>I've recently refactored <code>vim-colors-solarized</code> and I've stumbled on a code like this</p> <pre><code>let s:foo = s:bar " used in multiple places " ... many lines let s:goo = s:boo " used in multiple places </code></pre> <p>How can I inline all usages of such variables automatically easily. Of course I c...
[ { "answer_id": 25892, "author": "Amir", "author_id": 30074, "author_profile": "https://vi.stackexchange.com/users/30074", "pm_score": 0, "selected": false, "text": "<p>I normally use search and <code>cgn</code> combination for inlining and repeating with <code>.</code></p>\n<p><kbd>g</kb...
2019/01/04
[ "https://vi.stackexchange.com/questions/18467", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/6634/" ]
I've recently refactored `vim-colors-solarized` and I've stumbled on a code like this ``` let s:foo = s:bar " used in multiple places " ... many lines let s:goo = s:boo " used in multiple places ``` How can I inline all usages of such variables automatically easily. Of course I can write a function to do that. But m...
After expanding on the other [answer](https://vi.stackexchange.com/a/25892/10033), I thought I should also share my own personal solution for these renaming/refactoring type problems. ``` nnoremap * :'<,'>s/\C\<<C-r><C-w>\>//g<C-f>$F/i vnoremap * y:'<,'>s/\C\<<C-r>"\>//g<C-f>$F/i nnoremap & :%s/\C\<<C-r><C-w>\>//g<C-f...
18,477
<p>Is there a way to make vim behave like the app <a href="http://hailoverman.com/flowstate" rel="nofollow noreferrer">flowstate</a>?</p> <p>What this app does is forces the user to type continuously without pause for a certain period of time (which is very useful for brainstorming). The moment the user stops typing b...
[ { "answer_id": 18478, "author": "Hunaphu", "author_id": 20444, "author_profile": "https://vi.stackexchange.com/users/20444", "pm_score": 1, "selected": false, "text": "<p>VimRoom, inspired by writeroom gives the same appearance</p>\n\n<p><a href=\"http://mikewest.github.io/vimroom/\" rel...
2019/01/07
[ "https://vi.stackexchange.com/questions/18477", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/20443/" ]
Is there a way to make vim behave like the app [flowstate](http://hailoverman.com/flowstate)? What this app does is forces the user to type continuously without pause for a certain period of time (which is very useful for brainstorming). The moment the user stops typing before the time is up, it deletes everything on ...
You can use the [CursorHold](https://vimhelp.org/autocmd.txt.html#CursorHold) and [CursorHoldI](https://vimhelp.org/autocmd.txt.html#CursorHoldI) events of `autocmd` to implement this easily. This `autocmd` is sufficient to enable this for the current buffer: ``` :autocmd CursorHold,CursorHoldI <buffer> %d ``` This...
18,482
<p>The default <code>vim</code> filetype commands create new bindings beginning with <code>[</code> and <code>]</code>. Is there a way to prevent them from doing so or control which bindings are created?</p> <p>I like using <code>[</code> and <code>]</code> to scroll up and down by half pages, by analogy with <code>{<...
[ { "answer_id": 18483, "author": "Mass", "author_id": 13728, "author_profile": "https://vi.stackexchange.com/users/13728", "pm_score": 3, "selected": true, "text": "<p>You can unmap these within a file called <code>~/.vim/after/ftplugin/python.vim</code> or <code>$HOME/vimfiles/after/ftpl...
2019/01/07
[ "https://vi.stackexchange.com/questions/18482", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/6420/" ]
The default `vim` filetype commands create new bindings beginning with `[` and `]`. Is there a way to prevent them from doing so or control which bindings are created? I like using `[` and `]` to scroll up and down by half pages, by analogy with `{` and `}` for paragraph navigation. ``` nnoremap ] <c-d> vnoremap ] <c...
You can unmap these within a file called `~/.vim/after/ftplugin/python.vim` or `$HOME/vimfiles/after/ftplugin/python.vim` on windows, etc. containing: ``` silent! nunmap <buffer> ]] silent! nunmap <buffer> [[ silent! nunmap <buffer> ][ silent! nunmap <buffer> [] " and so on ... ``` vim executes scripts of the form `...
18,490
<p>For best experience, I want to enable some snippets to be expanded only in Tex Math environments. A wonderful person, lacygoill helped me on GitHub to achieve just this with the following setup:</p> <p>Let the context function and a snippet using the context be given by:</p> <pre><code>global !p def isMath(): ...
[ { "answer_id": 18494, "author": "Hotschke", "author_id": 1292, "author_profile": "https://vi.stackexchange.com/users/1292", "pm_score": 3, "selected": true, "text": "<p><strong>UPDATED UPDATE</strong></p>\n\n<p>I noticed that checking simply for <code>texMathZone...</code> at the beginni...
2019/01/08
[ "https://vi.stackexchange.com/questions/18490", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/20299/" ]
For best experience, I want to enable some snippets to be expanded only in Tex Math environments. A wonderful person, lacygoill helped me on GitHub to achieve just this with the following setup: Let the context function and a snippet using the context be given by: ``` global !p def isMath(): return int(vim.eval("...
**UPDATED UPDATE** I noticed that checking simply for `texMathZone...` at the beginning or end of the synstack is not sufficient. Every element has to be checked. As the OP has requested there should be a possibility to disable the autoexpansion for `\text{...}` within math zones (updated update). This is done by che...
18,499
<p>I'm working on <a href="https://metacpan.org/pod/Open::This" rel="nofollow noreferrer">Open::This</a>, which provides a command line utility that acts as a wrapper around <code>vim</code>, <code>emacs</code> and <code>nano</code>. The utility is called <code>ot</code>. It does things like translating <code>ot lib/...
[ { "answer_id": 18494, "author": "Hotschke", "author_id": 1292, "author_profile": "https://vi.stackexchange.com/users/1292", "pm_score": 3, "selected": true, "text": "<p><strong>UPDATED UPDATE</strong></p>\n\n<p>I noticed that checking simply for <code>texMathZone...</code> at the beginni...
2019/01/08
[ "https://vi.stackexchange.com/questions/18499", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/13055/" ]
I'm working on [Open::This](https://metacpan.org/pod/Open::This), which provides a command line utility that acts as a wrapper around `vim`, `emacs` and `nano`. The utility is called `ot`. It does things like translating `ot lib/Foo/Bar.pm:99` into `vim +99 lib/Foo/Bar.pm`. What I'd like to be able to do is translate ...
**UPDATED UPDATE** I noticed that checking simply for `texMathZone...` at the beginning or end of the synstack is not sufficient. Every element has to be checked. As the OP has requested there should be a possibility to disable the autoexpansion for `\text{...}` within math zones (updated update). This is done by che...
18,515
<p>I use the following setting for automatic line number toggle.</p> <pre><code>augroup numbertoggle autocmd! autocmd BufEnter,FocusGained,InsertLeave * set relativenumber autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber augroup END </code></pre> <p>But it seems that this setting does not work in...
[ { "answer_id": 18521, "author": "Ralf", "author_id": 19763, "author_profile": "https://vi.stackexchange.com/users/19763", "pm_score": 2, "selected": false, "text": "<p>As D. Ben Knoble said in his comment, \"you haven't left the buffer or entered insert mode when you switch, so it makes...
2019/01/10
[ "https://vi.stackexchange.com/questions/18515", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/15292/" ]
I use the following setting for automatic line number toggle. ``` augroup numbertoggle autocmd! autocmd BufEnter,FocusGained,InsertLeave * set relativenumber autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber augroup END ``` But it seems that this setting does not work inside tmux. If I open two t...
I opened [an issue](https://github.com/neovim/neovim/issues/9486) on Neovim repo and get the right answer. We need to turn on the `focus-events` for tmux. Edit the tmux config file `~/.tmux.conf` and add the following setting: ``` set -g focus-events on ``` Refresh the tmux session and the automatic relative line ...
18,546
<p>In the screencast below I searched <code>statusline</code> and then cycle through the results with <code>n</code>. </p> <p><strong>Is it possible to highlight the selected match with a different color than the other matches</strong>, instead of having them all highlighted in yellow and relying only on the user to n...
[ { "answer_id": 18551, "author": "B Layer", "author_id": 11054, "author_profile": "https://vi.stackexchange.com/users/11054", "pm_score": 2, "selected": false, "text": "<p><strong>TL;DR</strong> <em>For those in a hurry, not interested in the process/context, etc...jump to the last two co...
2019/01/12
[ "https://vi.stackexchange.com/questions/18546", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/18613/" ]
In the screencast below I searched `statusline` and then cycle through the results with `n`. **Is it possible to highlight the selected match with a different color than the other matches**, instead of having them all highlighted in yellow and relying only on the user to notice that the very first character of the ma...
Here is my solution, based on the answer of B Layer and those of many other stackexchange heroes. It supports incremental search highlighting as well and keeps the highlight color of the incremental search highlight after pressing Enter and after pressing `n` and `N`. [![enter image description here](https://i.stack...
18,547
<p>Example: I tried finding out about <a href="https://stackoverflow.com/questions/24711212/vim-auto-fold-when-leaving-fold"><code>foldclose</code></a> because it sounded strange to me that it isn't a binary setting but still only knows the value <code>"all"</code>. I typed <code>:h foldclose</code> and landed on a de...
[ { "answer_id": 18551, "author": "B Layer", "author_id": 11054, "author_profile": "https://vi.stackexchange.com/users/11054", "pm_score": 2, "selected": false, "text": "<p><strong>TL;DR</strong> <em>For those in a hurry, not interested in the process/context, etc...jump to the last two co...
2019/01/12
[ "https://vi.stackexchange.com/questions/18547", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/18613/" ]
Example: I tried finding out about [`foldclose`](https://stackoverflow.com/questions/24711212/vim-auto-fold-when-leaving-fold) because it sounded strange to me that it isn't a binary setting but still only knows the value `"all"`. I typed `:h foldclose` and landed on a description of the command `:foldc[lose]`. How do ...
Here is my solution, based on the answer of B Layer and those of many other stackexchange heroes. It supports incremental search highlighting as well and keeps the highlight color of the incremental search highlight after pressing Enter and after pressing `n` and `N`. [![enter image description here](https://i.stack...
18,557
<p>I opened a large file, didn't make a modification, and pressed <code>:w</code>. Then Vim was frozen for a while. Was it simply rewriting the whole file? Is it possible to make it understand that there was no change so that it could just quit? To generalize a little bit, is it possible to let it not rewrite the whole...
[ { "answer_id": 18558, "author": "Mass", "author_id": 13728, "author_profile": "https://vi.stackexchange.com/users/13728", "pm_score": 3, "selected": false, "text": "<p>Instead of <code>:write</code> you should use <code>:update</code>. According to vim's help:</p>\n\n<pre><code> ...
2019/01/13
[ "https://vi.stackexchange.com/questions/18557", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/10448/" ]
I opened a large file, didn't make a modification, and pressed `:w`. Then Vim was frozen for a while. Was it simply rewriting the whole file? Is it possible to make it understand that there was no change so that it could just quit? To generalize a little bit, is it possible to let it not rewrite the whole file if I onl...
Instead of `:write` you should use `:update`. According to vim's help: ``` *:up* *:update* :[range]up[date][!] [++opt] [>>] [file] Like ":write", but only write when the buffer has been modified. {not in Vi} ``` As stated, this will only write out the file to disk...
18,559
<p>I can use the powerful <code>:g</code> command to delete lines that contain a certain pattern like this: </p> <pre><code>:g/^\va pattern/d </code></pre> <p>I thought I should paste the deleted content to a new place but I cannot find all those lines that have been removed by checking the registers: </p> <pre><co...
[ { "answer_id": 18561, "author": "Hotschke", "author_id": 1292, "author_profile": "https://vi.stackexchange.com/users/1292", "pm_score": 3, "selected": false, "text": "<h3>Use a Dedicated Register to Which You Append</h3>\n\n<p>Note <code>delete</code> overwrites the unnamed register <cod...
2019/01/14
[ "https://vi.stackexchange.com/questions/18559", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/1788/" ]
I can use the powerful `:g` command to delete lines that contain a certain pattern like this: ``` :g/^\va pattern/d ``` I thought I should paste the deleted content to a new place but I cannot find all those lines that have been removed by checking the registers: ``` :register ``` The `"` register only remember...
### Use a Dedicated Register to Which You Append Note `delete` overwrites the unnamed register `""` for each match. Therefore, only the last line matching the pattern is still available in `""`. Also the numbered registers `"0-"9` are not helpful because there are only 10 of them. However, you can append each line to ...
18,586
<p>On a <code>.python</code> file, I see the following for <code>:ALEInfo</code></p> <pre><code>:ALEInfo Current Filetype: python Available Linters: ['flake8', 'mypy', 'prospector', 'pycodestyle', 'pydocstyle', 'pyflakes', 'pylint', 'pyls', 'pyre', 'vulture'] Enabled Linters: ['flake8', 'mypy', 'pylint'] </code></p...
[ { "answer_id": 18587, "author": "Tri Nguyen", "author_id": 7596, "author_profile": "https://vi.stackexchange.com/users/7596", "pm_score": 4, "selected": true, "text": "<p>I just found out that only <code>flake8</code>, <code>mypy</code> and <code>pylint</code> are enabled by default. I w...
2019/01/16
[ "https://vi.stackexchange.com/questions/18586", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/7596/" ]
On a `.python` file, I see the following for `:ALEInfo` ``` :ALEInfo Current Filetype: python Available Linters: ['flake8', 'mypy', 'prospector', 'pycodestyle', 'pydocstyle', 'pyflakes', 'pylint', 'pyls', 'pyre', 'vulture'] Enabled Linters: ['flake8', 'mypy', 'pylint'] ``` Why is `pycodestyle` not enabled? Is the...
I just found out that only `flake8`, `mypy` and `pylint` are enabled by default. I was trying to find out before but couldn't until someone pointed to <https://github.com/w0rp/ale/blob/master/doc/ale.txt#L1438> or `:help ale_linters` In order to enable new linters, I need to set: ``` let g:ale_linters = {'python': ...
18,590
<p>I might not have discovered everything about it, but the <code>smartindent</code> option has given me much more trouble than usefulness. For example, it indents a line beginning with <code>for</code> or <code>if</code>, and won't shift a line beginning with <code>#</code>. Probably I'm wrong having this option on wh...
[ { "answer_id": 18607, "author": "Scott Severance", "author_id": 20217, "author_profile": "https://vi.stackexchange.com/users/20217", "pm_score": 0, "selected": false, "text": "<p>According to <code>:help 'smartindent'</code>:</p>\n\n<blockquote>\n <p>Do smart autoindenting when starting...
2019/01/16
[ "https://vi.stackexchange.com/questions/18590", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/10448/" ]
I might not have discovered everything about it, but the `smartindent` option has given me much more trouble than usefulness. For example, it indents a line beginning with `for` or `if`, and won't shift a line beginning with `#`. Probably I'm wrong having this option on when editing normal text files (not programs). Bu...
Here is an example typing the following into `vim --clean`, with each option set: ``` hello { world foo; bar } ``` `smartindent` only: ``` hello { world foo; bar } ``` `cindent` only: ``` hello { world foo; bar } ``` As you can see with `cindent`, vim tries to continue lines that ar...
18,603
<p>I am trying <code>Vim</code> capabilities and stuck with this task - addition the incrementing number to the end of each line.</p> <p><strong>Testing lines:</strong></p> <pre><code>text text text text text </code></pre> <p>This command works partially:</p> <pre><code>:let n=1 | g/text/s/$/\=n/ | let n+=1 </code>...
[ { "answer_id": 18604, "author": "MiniMax", "author_id": 14024, "author_profile": "https://vi.stackexchange.com/users/14024", "pm_score": 1, "selected": false, "text": "<p><strong>Answer to the question №1:</strong></p>\n\n<pre><code>:let n=1 | g/text/s/$/\\=printf(\" %d\", n)/ | let n+=1...
2019/01/17
[ "https://vi.stackexchange.com/questions/18603", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/14024/" ]
I am trying `Vim` capabilities and stuck with this task - addition the incrementing number to the end of each line. **Testing lines:** ``` text text text text text ``` This command works partially: ``` :let n=1 | g/text/s/$/\=n/ | let n+=1 ``` **Result:** ``` text1 text2 text3 text4 text5 ``` But I want ...
For your answer specifically, you could get around this by concatenating a space with the number, i.e. ``` :let n=1 | g/text/s/$/\=" ".n/ | let n+=1 ``` --- If you want to do this to every line, there are some much shorter ways to do this. For example: ``` :%s/$/\=" ".line('.') ``` Or if you only want to number ...
18,611
<p>My ideal editing layout would look like this (in Gvim):</p> <pre><code>---------------------------------------------------------- | | | | | N | | | E | | | | R |...
[ { "answer_id": 18612, "author": "B Layer", "author_id": 11054, "author_profile": "https://vi.stackexchange.com/users/11054", "pm_score": 3, "selected": true, "text": "<p>We start with:</p>\n\n<pre><code>:bel terminal\n</code></pre>\n\n<p>When <code>:bel[owright]</code> is followed by a c...
2019/01/17
[ "https://vi.stackexchange.com/questions/18611", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/20217/" ]
My ideal editing layout would look like this (in Gvim): ``` ---------------------------------------------------------- | | | | | N | | | E | | | | R | ...
We start with: ``` :bel terminal ``` When `:bel[owright]` is followed by a command that splits a window the new window is opened below the current one. That means we first need to get to the bottom right window of the existing layout and then do `:bel`. `Ctrl-W b` is how we'd go to the bottom right in Normal mode. T...
18,621
<p>I want to achieve two effects about using the netrw plugin for vim.</p> <p><strong>EFFECT ONE:</strong></p> <p>I have a test directory.Here is its directory structure:</p> <pre><code>MINGW64 ~/test $ ll total 1 drwxr-xr-x 1 uooki2 197121 0 一月 18 18:37 dir1/ drwxr-xr-x 1 uooki2 197121 0 一月 18 18:37 dir2/ drw...
[ { "answer_id": 18627, "author": "Hotschke", "author_id": 1292, "author_profile": "https://vi.stackexchange.com/users/1292", "pm_score": 2, "selected": false, "text": "<h2>Plugins</h2>\n<p>There are plenty of plugins which provide a custom prompt for mru lists and allow you to select seve...
2019/01/18
[ "https://vi.stackexchange.com/questions/18621", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/20589/" ]
I want to achieve two effects about using the netrw plugin for vim. **EFFECT ONE:** I have a test directory.Here is its directory structure: ``` MINGW64 ~/test $ ll total 1 drwxr-xr-x 1 uooki2 197121 0 一月 18 18:37 dir1/ drwxr-xr-x 1 uooki2 197121 0 一月 18 18:37 dir2/ drwxr-xr-x 1 uooki2 197121 0 一月 18 18:37 ...
Plugins ------- There are plenty of plugins which provide a custom prompt for mru lists and allow you to select several entries: * [**Mru list by ctrlp.vim**](https://github.com/ctrlpvim/ctrlp.vim) 1. Open mru list with `<c-p><c-b>` or `:CtrlPMR[UFiles]` or set `let g:ctrlp_cmd = 'CtrlPMRU'` in your vimrc and then ...
18,636
<p>I have this texts</p> <pre><code>drwxr-xr-x enan enan Jan 15 16:10 Desktop/ drwxr-xr-x enan enan Jan 16 20:09 Documents/ drwxr-xr-x enan enan Jan 20 19:52 Downloads/ drwxr-xr-x enan enan Nov 3 20:44 Music/ drwxr-xr-x enan enan Jan 17 20:21 Pictures/ drwxr-xr-x ena...
[ { "answer_id": 18646, "author": "B Layer", "author_id": 11054, "author_profile": "https://vi.stackexchange.com/users/11054", "pm_score": 2, "selected": true, "text": "<p>Okay, so you want that <code>command</code> broken down? Here you go....</p>\n\n<pre><code> command! -range=% -nargs=0...
2019/01/20
[ "https://vi.stackexchange.com/questions/18636", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/16280/" ]
I have this texts ``` drwxr-xr-x enan enan Jan 15 16:10 Desktop/ drwxr-xr-x enan enan Jan 16 20:09 Documents/ drwxr-xr-x enan enan Jan 20 19:52 Downloads/ drwxr-xr-x enan enan Nov 3 20:44 Music/ drwxr-xr-x enan enan Jan 17 20:21 Pictures/ drwxr-xr-x enan enan J...
Okay, so you want that `command` broken down? Here you go.... ``` command! -range=% -nargs=0 Tab2Space ``` Creates a custom command named "Tab2Space" that takes no arguments and operates on a range of lines which by default will be from first line to last line. ``` \ execute '<line1>,<line2>s#^\t\+#\=repea...
18,640
<p>I have a <code>*.txt</code> file with 10,000 lines. The lines are E-Mail and password divided by a ":", so like </p> <pre><code>E-Mail:Password </code></pre> <p>I want to delete the E-Mail addresses on every single line at once, so I end up with the passwords only. How can I do that?</p> <p>Thanks in advance.</p...
[ { "answer_id": 18641, "author": "Ralf", "author_id": 19763, "author_profile": "https://vi.stackexchange.com/users/19763", "pm_score": 2, "selected": false, "text": "<p>Try:</p>\n\n<pre><code>:%s/^[^:]*://\n</code></pre>\n\n<p>Matches from the start of the line all not-<code>:</code> unti...
2019/01/20
[ "https://vi.stackexchange.com/questions/18640", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/20635/" ]
I have a `*.txt` file with 10,000 lines. The lines are E-Mail and password divided by a ":", so like ``` E-Mail:Password ``` I want to delete the E-Mail addresses on every single line at once, so I end up with the passwords only. How can I do that? Thanks in advance.
Try: ``` :%s/^[^:]*:// ``` Matches from the start of the line all not-`:` until the first `:` and replaces them with nothing.
18,650
<p>netrw has a <code>gh</code> command that toggles dotfile hiding. It is off by default. I would like it to be on by default. How do I do that?</p>
[ { "answer_id": 18651, "author": "João A. Toledo", "author_id": 11384, "author_profile": "https://vi.stackexchange.com/users/11384", "pm_score": 2, "selected": false, "text": "<p>You can try this on your <code>.vimrc</code>:</p>\n\n<pre><code>let g:netrw_list_hide = '^\\..*' \" or ...
2019/01/21
[ "https://vi.stackexchange.com/questions/18650", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/20175/" ]
netrw has a `gh` command that toggles dotfile hiding. It is off by default. I would like it to be on by default. How do I do that?
`gh` works by modifying `netrw_list_hide`, rather than by toggling a separate flag. It appends or removes the regex `\(^\|\s\s\)\zs\.\S\+`. As far as I can tell, said regex matches "a dot followed by any number of non-whitespace characters, starting either at the beginning of the string or after two spaces." I'm not su...
18,668
<p>I've upgraded vim and now it's unhappy about some UTF-8 values in my <code>.vimrc</code>.</p> <p>This lead me to the question -- when vim reads <code>.vimrc</code>, what encoding does it assume the file has? I.e. what's <code>fileencoding</code> then?</p>
[ { "answer_id": 18672, "author": "Tae", "author_id": 786, "author_profile": "https://vi.stackexchange.com/users/786", "pm_score": 4, "selected": true, "text": "<p>It is whatever you define whit <code>:scriptencoding</code>. it should be the first line in you <code>.vimrc</code> file, e.g....
2019/01/23
[ "https://vi.stackexchange.com/questions/18668", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/-1/" ]
I've upgraded vim and now it's unhappy about some UTF-8 values in my `.vimrc`. This lead me to the question -- when vim reads `.vimrc`, what encoding does it assume the file has? I.e. what's `fileencoding` then?
It is whatever you define whit `:scriptencoding`. it should be the first line in you `.vimrc` file, e.g.: ``` scriptencoding utf-8 set number set ... ``` Be aware that some options (`listchars` for example) only accept single width values. Edit: Yeah, Vim is weird. `encoding` is for the editor itself, `fileencodin...
18,693
<p>I have two different lists of words and I want to make sure that they have no mutual duplicates. In other words, none of the words in list A can be in list B and vice versa. They must be mutually exclusive word lists.</p> <p>Both lists are guaranteed to be sorted alphabetically.</p> <p>How can I do this?</p>
[ { "answer_id": 18694, "author": "Peter Rincker", "author_id": 778, "author_profile": "https://vi.stackexchange.com/users/778", "pm_score": 2, "selected": false, "text": "<p>The easiest solution in my mind is to use <code>comm</code> utility.</p>\n\n<p>List A:</p>\n\n<pre><code>comm -2 -3...
2019/01/24
[ "https://vi.stackexchange.com/questions/18693", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/6952/" ]
I have two different lists of words and I want to make sure that they have no mutual duplicates. In other words, none of the words in list A can be in list B and vice versa. They must be mutually exclusive word lists. Both lists are guaranteed to be sorted alphabetically. How can I do this?
The easiest solution in my mind is to use `comm` utility. List A: ``` comm -2 -3 a.txt b.txt > a.txt ``` List B: ``` comm -1 -3 a.txt b.txt > b.txt ``` You can do this inside of Vim with the filter command, `:!`. e.g. `:%!comm -2 -3 % b.txt` For more help see `man comm` and `:h :range!`
18,717
<p>Would like to have all content of the folded block, instead of only the first line.</p> <p>My current foldsettings are:</p> <pre><code>set foldmethod=marker set foldmarker={,} </code></pre> <p>Example how my data is structured:</p> <pre><code>{ cows pigs chickens } </code></pre> <p>Current folds look like...
[ { "answer_id": 18720, "author": "Ralf", "author_id": 19763, "author_profile": "https://vi.stackexchange.com/users/19763", "pm_score": 1, "selected": false, "text": "<p>The option <code>foldtext</code> defines a expression, that is evaluated to create the text displayed for a closed fold....
2019/01/28
[ "https://vi.stackexchange.com/questions/18717", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/20726/" ]
Would like to have all content of the folded block, instead of only the first line. My current foldsettings are: ``` set foldmethod=marker set foldmarker={,} ``` Example how my data is structured: ``` { cows pigs chickens } ``` Current folds look like: ``` +-- 5 lines: --------------------------- ``` I...
The option `foldtext` defines a expression, that is evaluated to create the text displayed for a closed fold. By default this is set to the build in function `foldtext()`. You can create a custom function, to create the text displayed on a closed fold. The documentation `:help fold-foldtext` contains an example. Note ...
18,722
<p>I have some plugins I would prefer load by default in the terminal, and cause performance issues or ux glitches in jetbrains ides running ideavim. Neovim needs to start getting adopted, but that's an aside. How can I detect intellij ides through vimscript? </p> <p>I have used this in the past to detect the name of ...
[ { "answer_id": 18723, "author": "Rohit Bhanot", "author_id": 18373, "author_profile": "https://vi.stackexchange.com/users/18373", "pm_score": 0, "selected": false, "text": "<p>Not really sure why you want to check that, since IdeaVim uses <code>.ideavimrc</code> and not <code>.vimrc</cod...
2019/01/28
[ "https://vi.stackexchange.com/questions/18722", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/20729/" ]
I have some plugins I would prefer load by default in the terminal, and cause performance issues or ux glitches in jetbrains ides running ideavim. Neovim needs to start getting adopted, but that's an aside. How can I detect intellij ides through vimscript? I have used this in the past to detect the name of the termin...
Generally speaking ideavim can handle consuming of native vimrc. That's because it doesn't actually parse it as vimscript. It just does pattern matching so anything non-compatible is skipped over. Most people get away with this just fine... ``` source ~/.vimrc ``` And that command is recommended on [ideamvim's githu...
18,732
<p>I have two syntax region defined as follows:</p> <pre><code>syntax region xBCD start="b" end="d" hi def link xBCD Todo syntax region xBlock start="\z(abcde\)\zs::" end=";" hi def link xBlock Comment </code></pre> <p>and a text file like this:</p> <pre><code>abcde::test; </code></pre> <p>I.e, I have is a syntax ...
[ { "answer_id": 18748, "author": "Maxim Kim", "author_id": 9333, "author_profile": "https://vi.stackexchange.com/users/9333", "pm_score": 0, "selected": false, "text": "<p>I don't think vim can do what you want (highlight region in a start match of another region -- in terms of vim region...
2019/01/29
[ "https://vi.stackexchange.com/questions/18732", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/20748/" ]
I have two syntax region defined as follows: ``` syntax region xBCD start="b" end="d" hi def link xBCD Todo syntax region xBlock start="\z(abcde\)\zs::" end=";" hi def link xBlock Comment ``` and a text file like this: ``` abcde::test; ``` I.e, I have is a syntax region that I'd like to define within the start m...
The fix ------- ``` syntax region xBCD start="b" end="d" syntax region xBlock start="abcde::"hs=s+5 end=";" contains=xBCD ``` Explanation ----------- The problem is not that Vim cannot highlight a subset of `start`. Instead it is your use of `\zs` that is causing issues. We can show this is true by removing the `\z...
18,754
<p>Sometime there is <strong>0xa0</strong> in my code, which causes compile error and hard to find out where it is because it's invisible.. I searched on google and found <code>set listchars=nbsp:.</code> can make the <strong>0xa0</strong> visible. </p> <p>I want to enable <code>listchars</code> permanently, but it re...
[ { "answer_id": 18755, "author": "D. Ben Knoble", "author_id": 10604, "author_profile": "https://vi.stackexchange.com/users/10604", "pm_score": 2, "selected": false, "text": "<p>One slightly hacky workaround that I’m not entirely satisfied with is to use the space character for listchars ...
2019/01/31
[ "https://vi.stackexchange.com/questions/18754", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/6971/" ]
Sometime there is **0xa0** in my code, which causes compile error and hard to find out where it is because it's invisible.. I searched on google and found `set listchars=nbsp:.` can make the **0xa0** visible. I want to enable `listchars` permanently, but it requires `set list`, which causes tabs are displayed as '^I'...
Displaying `^I` for tab is the default Vi behavior. You could set the list character for tab to a spaces: ``` set listchars=nbsp:×,tab:\ \ ,trail:\ , set list ``` Note that I have added a definition for trailing spaces (to be displayed as spaces). Without it, the nbsp is not displayed. **Alternative:** Use Syntax h...
18,771
<p>I'm trying to use indent size as variable, but it doesn't work.</p> <pre><code>let indent=4 set tabstop=&amp;indent set softtabstop=&amp;indent set shiftwidth=&amp;indent set expandtab </code></pre> <p>I tried both <code>&amp;indent</code> and <code>%(&amp;indent)</code> - just guessing, but it still broken.</p>
[ { "answer_id": 18774, "author": "Ralf", "author_id": 19763, "author_profile": "https://vi.stackexchange.com/users/19763", "pm_score": 3, "selected": true, "text": "<p>Most is already in the comments, but to summarize:</p>\n\n<pre><code>let indent=4\nlet &amp;tabstop=indent\nlet &amp;soft...
2019/02/01
[ "https://vi.stackexchange.com/questions/18771", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/20821/" ]
I'm trying to use indent size as variable, but it doesn't work. ``` let indent=4 set tabstop=&indent set softtabstop=&indent set shiftwidth=&indent set expandtab ``` I tried both `&indent` and `%(&indent)` - just guessing, but it still broken.
Most is already in the comments, but to summarize: ``` let indent=4 let &tabstop=indent let &softtabstop=indent let &shiftwidth=indent set expandtab ``` If you want to set a setting (like `tabstop`) to the value of a variable, you have to Vim script expressions instead of set-expressions. In that case, settings are ...
18,777
<p>Since Vim considers paragraphs as lines/sentences separated by blank lines the paragraph movement with <code>{</code> and <code>}</code> feels little weird to me as it takes you to the next blank line and you always have to press either <code>w</code> or <code>j</code> to go to the actual text.</p> <p>So i thought ...
[ { "answer_id": 18786, "author": "Ed Grimm", "author_id": 20713, "author_profile": "https://vi.stackexchange.com/users/20713", "pm_score": 0, "selected": false, "text": "<p>This feels kludgy to me, but it's my first vim function, and I still haven't done a custom command yet... It's not ...
2019/02/02
[ "https://vi.stackexchange.com/questions/18777", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/18373/" ]
Since Vim considers paragraphs as lines/sentences separated by blank lines the paragraph movement with `{` and `}` feels little weird to me as it takes you to the next blank line and you always have to press either `w` or `j` to go to the actual text. So i thought of remapping this behaviour, the forward movement is p...
If I understand correctly what you want, the following mapping achieves it: ``` nnoremap <expr><silent> { (col('.')==1 && len(getline(line('.')-1))==0? '2{j' : '{j') ``` This is a map expression, that means one can use expression have evaluated at the time the mapping is performed and react to certain conditions. I...
18,798
<p>Instead of wrapping lines visually, I want vim to wrap with a linebreak regardless of my the window dimensions. How can I set this automatically </p>
[ { "answer_id": 18799, "author": "Ralf", "author_id": 19763, "author_profile": "https://vi.stackexchange.com/users/19763", "pm_score": 3, "selected": true, "text": "<p>You could work with <code>wrapmargin</code>:</p>\n<pre><code>set textwidth=0\nset wrapmargin=1\nset formatoptions+=t\nset...
2019/02/05
[ "https://vi.stackexchange.com/questions/18798", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/16949/" ]
Instead of wrapping lines visually, I want vim to wrap with a linebreak regardless of my the window dimensions. How can I set this automatically
You could work with `wrapmargin`: ``` set textwidth=0 set wrapmargin=1 set formatoptions+=t set formatoptions-=l ``` The option `wrapmargin` defines the *number of characters from the right window border where wrapping starts*. This option is only used, if `textwidth` is set to zero. The `formatoptions` flag `t` en...
18,803
<p>Vim automatically strips trailing whitespace from my files on save, which is extremely annoying in various contexts. How do I disable this behaviour?</p> <p>This question is <strong>not</strong> a duplicate of <a href="https://vi.stackexchange.com/questions/8995/stop-vim-from-removing-whitespace-on-save-for-diff-fi...
[ { "answer_id": 18805, "author": "PeterVP", "author_id": 11066, "author_profile": "https://vi.stackexchange.com/users/11066", "pm_score": 2, "selected": false, "text": "<p>In my .vimrc I have the following function:</p>\n\n<pre><code>\" Trim trailing whitespace\n\" =======================...
2019/02/05
[ "https://vi.stackexchange.com/questions/18803", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/14849/" ]
Vim automatically strips trailing whitespace from my files on save, which is extremely annoying in various contexts. How do I disable this behaviour? This question is **not** a duplicate of [this one](https://vi.stackexchange.com/questions/8995/stop-vim-from-removing-whitespace-on-save-for-diff-files), because I'm not...
In my .vimrc I have the following function: ``` " Trim trailing whitespace " ======================== function! TrimWhitespace() " trailing whitespaces have meaning in markdown so don't try there if &filetype!='markdown' let l:save = winsaveview() %s/\s\+$//e call winrestview(l:save) endif endfunctio...
18,819
<p>Because the default <code>Ctrl-B/F</code> or <code>PageUp/Down</code> behaviour usually leaves the cursor somewhere other than where it started, I remapped <code>PageUp</code> and <code>PageDown</code> in my <code>.vimrc</code> to simply move up/down 25 lines. </p> <pre><code>nnoremap &lt;silent&gt; &lt;PageUp&gt; ...
[ { "answer_id": 18836, "author": "Spidey", "author_id": 10482, "author_profile": "https://vi.stackexchange.com/users/10482", "pm_score": 0, "selected": false, "text": "<p>You could use Ctrl+O to go back to the previous positions instead of relying on the standard scrolling commands. </p>\...
2019/02/06
[ "https://vi.stackexchange.com/questions/18819", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/20870/" ]
Because the default `Ctrl-B/F` or `PageUp/Down` behaviour usually leaves the cursor somewhere other than where it started, I remapped `PageUp` and `PageDown` in my `.vimrc` to simply move up/down 25 lines. ``` nnoremap <silent> <PageUp> 25<Up> nnoremap <silent> <PageDown> 25<Down> ``` But if I get to the top of th...
You can mark the current position of the cursor typing `m` followed by an alphabet in normal mode which is the register to store it. If you use `ma` to mark it, you can jump back to this position by ``a` or `'a`. For more details, run `:help mark` in vim. If you had used certain commands to navigate the documents, you...
18,832
<p><code>:scriptnames</code> outputs a (not convenient) list with more at the bottom.</p> <p>I'd like to have all the output in a buffer so i can search, edit ...</p> <p>How do i do that?</p>
[ { "answer_id": 18833, "author": "Ralf", "author_id": 19763, "author_profile": "https://vi.stackexchange.com/users/19763", "pm_score": 0, "selected": false, "text": "<p>You could redirect the output to a register like:</p>\n\n<pre><code>:redir @a | silent scriptnames | redir END\n</code><...
2019/02/08
[ "https://vi.stackexchange.com/questions/18832", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/19908/" ]
`:scriptnames` outputs a (not convenient) list with more at the bottom. I'd like to have all the output in a buffer so i can search, edit ... How do i do that?
You can also directly paste it into the current buffer using ``` :put =execute(':scriptnames') ```
18,843
<p><strong>N.B</strong> I use the word <em>blank</em> here due to lack of a better word. By <em>blank</em> I mean the remaining part of a tab that is visualized after the starting part. Please feel free to edit this question.</p> <p>I know there are questions already answered about vim's indent with tabs and align wit...
[ { "answer_id": 18848, "author": "João A. Toledo", "author_id": 11384, "author_profile": "https://vi.stackexchange.com/users/11384", "pm_score": 1, "selected": false, "text": "<p>This seems to work:</p>\n\n<pre><code>function! ReplaceMiddleTabs() abort\n let s:linenum = line('.')\n ...
2019/02/08
[ "https://vi.stackexchange.com/questions/18843", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/16280/" ]
**N.B** I use the word *blank* here due to lack of a better word. By *blank* I mean the remaining part of a tab that is visualized after the starting part. Please feel free to edit this question. I know there are questions already answered about vim's indent with tabs and align with spaces. But those questions have an...
1st Method ---------- Use this command to convert tabs to spaces except the tabs used for indentation over a `range` of lines: ``` com! -bar -range=% RemoveTabs call s:remove_tabs(<line1>,<line2>) function! s:remove_tabs(line1, line2) abort let view = winsaveview() let mods = 'sil keepj keepp' let range =...
18,889
<p>Suppose I want to use this colorscheme: <a href="https://github.com/NLKNguyen/papercolor-theme" rel="nofollow noreferrer">https://github.com/NLKNguyen/papercolor-theme</a></p> <p>I copied the <code>PaperColor.vim</code> file into <code>.vim/colors</code> and made my <code>.vimrc</code>:</p> <pre><code>syntax on co...
[ { "answer_id": 18848, "author": "João A. Toledo", "author_id": 11384, "author_profile": "https://vi.stackexchange.com/users/11384", "pm_score": 1, "selected": false, "text": "<p>This seems to work:</p>\n\n<pre><code>function! ReplaceMiddleTabs() abort\n let s:linenum = line('.')\n ...
2019/02/13
[ "https://vi.stackexchange.com/questions/18889", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/20958/" ]
Suppose I want to use this colorscheme: <https://github.com/NLKNguyen/papercolor-theme> I copied the `PaperColor.vim` file into `.vim/colors` and made my `.vimrc`: ``` syntax on colorscheme PaperColor background=light ``` Now, I want to use this syntax highlighting for haskell files: <https://github.com/raichoo/has...
1st Method ---------- Use this command to convert tabs to spaces except the tabs used for indentation over a `range` of lines: ``` com! -bar -range=% RemoveTabs call s:remove_tabs(<line1>,<line2>) function! s:remove_tabs(line1, line2) abort let view = winsaveview() let mods = 'sil keepj keepp' let range =...
18,894
<p>I really like and often use the <kbd>c</kbd><kbd>g</kbd><kbd>n</kbd> command for replacing something I was currently searching for, but it sort of lacks a (imho) rather intuitive feature: replace the word (or whatever) under the cursor. My current approach is to search for the word in question, but that feels like a...
[ { "answer_id": 18895, "author": "Maxim Kim", "author_id": 9333, "author_profile": "https://vi.stackexchange.com/users/9333", "pm_score": 4, "selected": true, "text": "<p>There is no built-in way to do it (as an option), as far as I know.</p>\n\n<p>I have the following mapping:</p>\n\n<pr...
2019/02/13
[ "https://vi.stackexchange.com/questions/18894", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/6350/" ]
I really like and often use the `c``g``n` command for replacing something I was currently searching for, but it sort of lacks a (imho) rather intuitive feature: replace the word (or whatever) under the cursor. My current approach is to search for the word in question, but that feels like a hack, plus the cursor immedia...
There is no built-in way to do it (as an option), as far as I know. I have the following mapping: ``` " change current word (like ciw) but repeatable with dot . for the same next " word nnoremap <silent> c<Tab> :let @/=expand('<cword>')<cr>cgn ``` Basically what it does is: 1. make current search term == word unde...
18,897
<p>Is there a way that a open up a window or buffer, where i can run my bash commands? I thought on something like you know it from VS Code(<a href="https://i.stack.imgur.com/SNyAc.png" rel="nofollow noreferrer">1</a>). The code windows on the top and a small command prompt on the bottom of the view, where i can run fo...
[ { "answer_id": 18898, "author": "Ralf", "author_id": 19763, "author_profile": "https://vi.stackexchange.com/users/19763", "pm_score": 3, "selected": true, "text": "<p>You need Vim 8.1, then you can use the following command:</p>\n\n<pre><code>:below terminal ++rows=10\n</code></pre>\n\n<...
2019/02/13
[ "https://vi.stackexchange.com/questions/18897", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/20971/" ]
Is there a way that a open up a window or buffer, where i can run my bash commands? I thought on something like you know it from VS Code([1](https://i.stack.imgur.com/SNyAc.png)). The code windows on the top and a small command prompt on the bottom of the view, where i can run for example my rails or node server? [![V...
You need Vim 8.1, then you can use the following command: ``` :below terminal ++rows=10 ``` Normally a terminal is opened above the current window, but with `below` it is opened at the bottom. And in this case, the terminal should have a height of 10 rows. See `:help :terminal` for additional `++`-options.
18,904
<p>accidentally just wrote</p> <pre><code>void foo(bar, baz, que) { </code></pre> <p>and forgot to specify type, I want to convert the above to</p> <pre><code>void foo(String bar, String baz, String que) { </code></pre> <p>How can I do that quickly?</p>
[ { "answer_id": 18898, "author": "Ralf", "author_id": 19763, "author_profile": "https://vi.stackexchange.com/users/19763", "pm_score": 3, "selected": true, "text": "<p>You need Vim 8.1, then you can use the following command:</p>\n\n<pre><code>:below terminal ++rows=10\n</code></pre>\n\n<...
2019/02/14
[ "https://vi.stackexchange.com/questions/18904", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/9024/" ]
accidentally just wrote ``` void foo(bar, baz, que) { ``` and forgot to specify type, I want to convert the above to ``` void foo(String bar, String baz, String que) { ``` How can I do that quickly?
You need Vim 8.1, then you can use the following command: ``` :below terminal ++rows=10 ``` Normally a terminal is opened above the current window, but with `below` it is opened at the bottom. And in this case, the terminal should have a height of 10 rows. See `:help :terminal` for additional `++`-options.
18,907
<p>I'm trying to programmatically record a macro (using <code>:let @m=</code> rather than <code>qm</code>). In vim, I executed:</p> <pre><code>:let @m = ':retab^M' </code></pre> <p>where <code>^M</code> is typed as ctrl+V, Enter. I expect the buffer to contain exactly what is written above, but it also contains a new...
[ { "answer_id": 18898, "author": "Ralf", "author_id": 19763, "author_profile": "https://vi.stackexchange.com/users/19763", "pm_score": 3, "selected": true, "text": "<p>You need Vim 8.1, then you can use the following command:</p>\n\n<pre><code>:below terminal ++rows=10\n</code></pre>\n\n<...
2019/02/14
[ "https://vi.stackexchange.com/questions/18907", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/13936/" ]
I'm trying to programmatically record a macro (using `:let @m=` rather than `qm`). In vim, I executed: ``` :let @m = ':retab^M' ``` where `^M` is typed as ctrl+V, Enter. I expect the buffer to contain exactly what is written above, but it also contains a newline at the end, and when the macro is executed, my cursor ...
You need Vim 8.1, then you can use the following command: ``` :below terminal ++rows=10 ``` Normally a terminal is opened above the current window, but with `below` it is opened at the bottom. And in this case, the terminal should have a height of 10 rows. See `:help :terminal` for additional `++`-options.
18,911
<p>I am using Vim 8.1 on Windows 10 and with a default package manager Vim doesn't see plugins in <code>C:\Program Files (x86)\Vim\vimfiles\pack</code> directory.</p> <p>Did I put in into incorrect place?</p> <p><strong>EDIT:</strong></p> <p>It is the same configuration as I use on Ubuntu and it works there.</p> <p...
[ { "answer_id": 18912, "author": "Maxim Kim", "author_id": 9333, "author_profile": "https://vi.stackexchange.com/users/9333", "pm_score": 0, "selected": false, "text": "<p>Not sure if packages are being searched in <code>$VIM/vimfiles</code> directory.</p>\n\n<p>Try </p>\n\n<ol>\n<li>if y...
2019/02/14
[ "https://vi.stackexchange.com/questions/18911", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/1860/" ]
I am using Vim 8.1 on Windows 10 and with a default package manager Vim doesn't see plugins in `C:\Program Files (x86)\Vim\vimfiles\pack` directory. Did I put in into incorrect place? **EDIT:** It is the same configuration as I use on Ubuntu and it works there. **EDIT 2:** ``` packpath=~/vimfiles,C:\Program Files ...
Well the problem initially was in the fact that due to some issues git repo files cloned in Ubuntu subsystem wasn't visible to Windows. The second thing: paths should be `HOME/vimfiles` and `HOME/.vimrc`. At least this worked for me.
18,986
<p>When I run this command in <code>ex</code> mode it works without a problem:</p> <pre><code>:call deoplete#custom#source('ultisnips', 'rank', 1000) </code></pre> <p>However, when I put it in my vimrc I get an error:</p> <pre><code>Error detected while processing /Users/me/config/nvim/plugins/deoplete.vim: line 1...
[ { "answer_id": 18987, "author": "mMontu", "author_id": 1405, "author_profile": "https://vi.stackexchange.com/users/1405", "pm_score": 2, "selected": false, "text": "<p>You could try using the <a href=\"http://vimhelp.appspot.com/autocmd.txt.html#VimEnter\" rel=\"nofollow noreferrer\"><co...
2019/02/21
[ "https://vi.stackexchange.com/questions/18986", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/21086/" ]
When I run this command in `ex` mode it works without a problem: ``` :call deoplete#custom#source('ultisnips', 'rank', 1000) ``` However, when I put it in my vimrc I get an error: ``` Error detected while processing /Users/me/config/nvim/plugins/deoplete.vim: line 14: E117: Unknown function: deoplete#custom#sourc...
According to the OP, the plugin directory is located inside the `'packpath'`, which means the plugin is not available until *after* the vimrc is processed: > > > ``` > When Vim starts up, after processing your .vimrc, it scans all directories in > 'packpath' for plugins under the "pack/*/start" directory. First all...
19,000
<p>I need to set cursor position when <em>opening</em> quickfix window. I have tried</p> <pre><code>autocmd BufEnter * call cursor(2, 2) </code></pre> <p>It doesn't set cursor for quickfix buffer immediately after I have opened it.</p> <p>UPD: I am trying to save current cursor position of quickfix window when close...
[ { "answer_id": 19001, "author": "3N4N", "author_id": 16280, "author_profile": "https://vi.stackexchange.com/users/16280", "pm_score": 0, "selected": false, "text": "<p>Put this in your vimrc</p>\n\n<pre><code>augroup quickfix\n autocmd!\n autocmd QuickFixCmdPost [^l]* nested cwindo...
2019/02/24
[ "https://vi.stackexchange.com/questions/19000", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/20634/" ]
I need to set cursor position when *opening* quickfix window. I have tried ``` autocmd BufEnter * call cursor(2, 2) ``` It doesn't set cursor for quickfix buffer immediately after I have opened it. UPD: I am trying to save current cursor position of quickfix window when close it and restore when open again. ``` le...
From the source code it looks like the position in the quickfix window is determined by the current position in the quickfix list. This is set after the window was opened, hence after your autocmd ran. First you need the autocmd event `BufLeave`, to save the cursor position (the quickfix buffer is not deleted). Then c...
19,003
<p>I want to be able to hit a single key to see the netrw buffer for the directory of the file I'm in. Rex will handily move your cursor to where it was previously, but only works if you opened the file from netrw, and breaks when you reopen a session.</p> <pre><code>fu! OpenExplorer() try silent! :Rex ...
[ { "answer_id": 19004, "author": "B Layer", "author_id": 11054, "author_profile": "https://vi.stackexchange.com/users/11054", "pm_score": 3, "selected": true, "text": "<p>Well, <code>:silent!</code> suppresses errors and neutralizes exceptions. If the <code>netrw</code> code is indeed thr...
2019/02/24
[ "https://vi.stackexchange.com/questions/19003", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/8483/" ]
I want to be able to hit a single key to see the netrw buffer for the directory of the file I'm in. Rex will handily move your cursor to where it was previously, but only works if you opened the file from netrw, and breaks when you reopen a session. ``` fu! OpenExplorer() try silent! :Rex catch ...
Well, `:silent!` suppresses errors and neutralizes exceptions. If the `netrw` code is indeed throwing exceptions (see below) then removing it, or at least dropping the `!`, should clear things up. (Note: I'm interpreting what you said about that error message you saw as if that occurred in a later/different context tha...
19,021
<p>I start up vim from mac terminal like so:</p> <pre><code>vim filename </code></pre> <p>But my colorschemes do not load properly (I tried loading <code>desert.vim</code>, <code>desert256.vim</code> and <code>solarized.vim</code>).</p> <p><code>desert256.vim</code> has a black background and white text.</p> <p><co...
[ { "answer_id": 19031, "author": "Maxim Kim", "author_id": 9333, "author_profile": "https://vi.stackexchange.com/users/9333", "pm_score": 1, "selected": false, "text": "<p>It is very common for a fancy colorscheme (such as solarized, base16-*, you name it) to require palette changes in a ...
2019/02/25
[ "https://vi.stackexchange.com/questions/19021", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/20958/" ]
I start up vim from mac terminal like so: ``` vim filename ``` But my colorschemes do not load properly (I tried loading `desert.vim`, `desert256.vim` and `solarized.vim`). `desert256.vim` has a black background and white text. `desert.vim` doesn't make a difference. `solarized.vim` has blue font and grey backgro...
It is very common for a fancy colorscheme (such as solarized, base16-\*, you name it) to require palette changes in a terminal. Without it you will face ugly colors. I generally avoid such colorschemes in terminals and use them only in GUI vim. To solve it -- goto the place you have obtained colorscheme, find descrip...
19,029
<p>I need to create a variable with a fool folder direct which need to concatenate from a environment variable and the end notes </p> <pre><code>function! MyFoo(arg) let repo=$Project + "/cfora" #Q1 let build=$project + "/build/cfora/debug" exec "!cd build" ...
[ { "answer_id": 19030, "author": "Maxim Kim", "author_id": 9333, "author_profile": "https://vi.stackexchange.com/users/9333", "pm_score": 4, "selected": true, "text": "<p>In vim dot is a concatenation operator:</p>\n\n<pre><code>let repo = $Project . '/cfora'\n</code></pre>\n\n<p>To \"ref...
2019/02/26
[ "https://vi.stackexchange.com/questions/19029", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/15958/" ]
I need to create a variable with a fool folder direct which need to concatenate from a environment variable and the end notes ``` function! MyFoo(arg) let repo=$Project + "/cfora" #Q1 let build=$project + "/build/cfora/debug" exec "!cd build" exec "!...
In vim dot is a concatenation operator: ``` let repo = $Project . '/cfora' ``` To "refer" variable in the string, well, in your case it is just a concatenation again: ``` exe '!cmake ' . repo ``` **PS** I would suggest to use built in make facilities for this. And vim `lcd` instead of `exe '!cd ...`
19,040
<p><code>Todo</code> highlight group currently highlights <code>TODO</code> and <code>FIXME</code> keywords. What do I do to add <code>NOTE</code>, and possibley more keywords, to this existing highlight group, for all file types?</p>
[ { "answer_id": 19043, "author": "Ralf", "author_id": 19763, "author_profile": "https://vi.stackexchange.com/users/19763", "pm_score": 4, "selected": false, "text": "<p>The highlight group <code>Todo</code> just defines how a \"todo\" should be highlighted. What is actually highlighted by...
2019/02/27
[ "https://vi.stackexchange.com/questions/19040", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/16280/" ]
`Todo` highlight group currently highlights `TODO` and `FIXME` keywords. What do I do to add `NOTE`, and possibley more keywords, to this existing highlight group, for all file types?
Add the following to your .vimrc: ``` fun! SetMyTodos() syn match myTodos /\%(HABA:\)\|\%(NOTE:\)/ hi link myTodos Todo endfu autocmd bufenter * :call SetMyTodos() autocmd filetype * :call SetMyTodos() ``` Restart. Then everytime you will set filetype (usually when you edit a file) or when you enter a buffer...
19,047
<p>I am a new Vim user. I can do : <code>:! &lt;some command&gt;</code> in Vim to run a bash command in Linux. After that bash command is executed, I can press <code>Enter</code> to go back to Vim. What happens if the bash command takes a long time to run (I am running some simulations), so I need to go back to code ...
[ { "answer_id": 19058, "author": "Herb", "author_id": 5298, "author_profile": "https://vi.stackexchange.com/users/5298", "pm_score": 1, "selected": false, "text": "<p>If you're sitting at a console, one option is the <code>screen</code> command.</p>\n\n<p>If you're using XWindows, there a...
2019/02/28
[ "https://vi.stackexchange.com/questions/19047", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/21038/" ]
I am a new Vim user. I can do : `:! <some command>` in Vim to run a bash command in Linux. After that bash command is executed, I can press `Enter` to go back to Vim. What happens if the bash command takes a long time to run (I am running some simulations), so I need to go back to code and read while waiting for the co...
For general purpose multi-window terminal experience, look into [tmux](https://github.com/tmux/tmux). Tmux, a terminal multiplexer, provides functionalities to split a terminal window into several vertical and horizontal splits, managing windows from one terminal emulator instance and managing different sessions. Here ...
19,051
<p>My problem on this gif:</p> <p><a href="https://i.stack.imgur.com/GQh4M.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GQh4M.gif" alt="vim incremental search, theme Gotham, macOS, term" /></a></p> <p>I am in one place, searching for <code>meta</code>, I do not want to loose my current search high...
[ { "answer_id": 19054, "author": "Ralf", "author_id": 19763, "author_profile": "https://vi.stackexchange.com/users/19763", "pm_score": 2, "selected": true, "text": "<p>I don't think that this is possible in Vim, but I'm ready to be surprised. </p>\n\n<p>The only idea I have is to create a...
2019/03/01
[ "https://vi.stackexchange.com/questions/19051", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/6038/" ]
My problem on this gif: [![vim incremental search, theme Gotham, macOS, term](https://i.stack.imgur.com/GQh4M.gif)](https://i.stack.imgur.com/GQh4M.gif) I am in one place, searching for `meta`, I do not want to loose my current search highlighting (yes I know that I can restore it later in `/` menu). I found what I n...
I don't think that this is possible in Vim, but I'm ready to be surprised. The only idea I have is to create a mapping to set the last search to the next to last search. So you hit `<Enter>` and then use the mapping to reset your search highlighting. ``` nnoremap _ps :let @/=histget('/',-2)<CR> ``` If you want to ...
19,053
<p>I am traversing through a <strong>C code in Vim using cscope</strong>. Sometimes while traversing, some key gets pressed or mouse gets right-clicked and the Vim enters in insert mode, and it creates a mess to undo the changes and all. I just want to read the code, and hence want to open <strong>Vim in read-only mode...
[ { "answer_id": 19055, "author": "Maxim Kim", "author_id": 9333, "author_profile": "https://vi.stackexchange.com/users/9333", "pm_score": 0, "selected": false, "text": "<p>You can try to reuse <code>modifiable</code> setting (<code>:h mo</code>)</p>\n\n<p>If you <code>set noma</code> (nom...
2019/03/01
[ "https://vi.stackexchange.com/questions/19053", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/21150/" ]
I am traversing through a **C code in Vim using cscope**. Sometimes while traversing, some key gets pressed or mouse gets right-clicked and the Vim enters in insert mode, and it creates a mess to undo the changes and all. I just want to read the code, and hence want to open **Vim in read-only mode.** Is it possible? Ho...
Invoke vim as `view` on the command line: ``` view myfile.c ``` This will automatically set the appropriate “readonly” flags.
19,067
<p>I find myself often aligning certain code blocks by inserting one or more spaces, like in the following situation:</p> <pre><code>case something of Just a▉-&gt; ... Nothing -&gt; ... </code></pre> <p>Here <code>▉</code> is the position of my cursor. In order to align the arrows, I enter insert mode with <c...
[ { "answer_id": 19070, "author": "Ralf", "author_id": 19763, "author_profile": "https://vi.stackexchange.com/users/19763", "pm_score": 1, "selected": false, "text": "<p>You could use <code>`[</code> to return \"to the first character of the previously changed or yanked text\" (from <code>...
2019/03/02
[ "https://vi.stackexchange.com/questions/19067", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/21196/" ]
I find myself often aligning certain code blocks by inserting one or more spaces, like in the following situation: ``` case something of Just a▉-> ... Nothing -> ... ``` Here `▉` is the position of my cursor. In order to align the arrows, I enter insert mode with `i`, hit `<Space>` and `<Esc>`. In my vim con...
You can create repeatable mappings by passing them through `g@`. ``` function! s:insspace(...) if a:0 " perform operation execute 'normal' v:count1.'i '."\<esc>".'`[' else " set up let &operatorfunc = matchstr(expand('<sfile>'), '[^. ]*$') return "g@\<space>" endif endfunction nnoremap <sile...
19,085
<p>When I run the <code>:sh</code> command I see the following characters</p> <p><a href="https://i.stack.imgur.com/D70i1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D70i1.png" alt="enter image description here"></a></p> <p>If it is relevant, my default shell is zsh and it runs oh-my-zsh also<b...
[ { "answer_id": 19086, "author": "Ralf", "author_id": 19763, "author_profile": "https://vi.stackexchange.com/users/19763", "pm_score": 2, "selected": false, "text": "<p>You are doing this in GVim and this only provides a terminal with limited capabilities. The command <code>echo $TERM</co...
2019/03/05
[ "https://vi.stackexchange.com/questions/19085", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/19397/" ]
When I run the `:sh` command I see the following characters [![enter image description here](https://i.stack.imgur.com/D70i1.png)](https://i.stack.imgur.com/D70i1.png) If it is relevant, my default shell is zsh and it runs oh-my-zsh also Thanks
You are doing this in GVim and this only provides a terminal with limited capabilities. The command `echo $TERM` returns "dumb". Might be your zsh /oh-my-zsh setup can't handle this. It works for me (with bash) as my bash setups checks for terminal capabilities before configuring a colored PS1 or configuring colored ...
19,088
<p><a href="https://i.stack.imgur.com/d3WoM.png" rel="noreferrer"><img src="https://i.stack.imgur.com/d3WoM.png" alt="why isn&#39;t the fourth SELECT highlighted like the second one?"></a></p> <p><em>I edited my original question and title to broaden its scope to any syntax - with SQL used as just an example. You can ...
[ { "answer_id": 19392, "author": "stepse", "author_id": 1634, "author_profile": "https://vi.stackexchange.com/users/1634", "pm_score": 1, "selected": false, "text": "<p>Answering my own question after some time.</p>\n\n<p>The clue to a solution came from noticing that the same issue happe...
2019/03/05
[ "https://vi.stackexchange.com/questions/19088", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/1634/" ]
[![why isn't the fourth SELECT highlighted like the second one?](https://i.stack.imgur.com/d3WoM.png)](https://i.stack.imgur.com/d3WoM.png) *I edited my original question and title to broaden its scope to any syntax - with SQL used as just an example. You can adapt the examples and the answer to other languages.* By ...
I would recommend the following approach: Create the file `$HOME/.vim/after/syntax/sh.vim` (`$HOME/vimfiles/after/syntax/sh.vim` on Windows) with the following content: ``` " safe b:current_syntax to restore it afterwards " Value could be 'sh', 'posix', 'ksh' or 'bash' let s:cs_safe = b:current_syntax " unlet b:curr...
19,090
<p>I have an XML document with many (dozens) of the following tags:</p> <pre><code>&lt;item prop1="val1" prop2="val2" /&gt; </code></pre> <p>I would like to change this to:</p> <pre><code>&lt;item prop1="val1" prop2="val2"&gt; &lt;sometihng&gt;text&lt;/something&gt; &lt;/item&gt; </code></pre> <p>However, I cann...
[ { "answer_id": 19092, "author": "D. Ben Knoble", "author_id": 10604, "author_profile": "https://vi.stackexchange.com/users/10604", "pm_score": 0, "selected": false, "text": "<p>I would do something like (untested)</p>\n\n<pre><code>qq0f&lt;lyiwf&gt;F/i&gt;&lt;Enter&gt;&lt;&lt;Esc&gt;pq\n...
2019/03/05
[ "https://vi.stackexchange.com/questions/19090", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/21221/" ]
I have an XML document with many (dozens) of the following tags: ``` <item prop1="val1" prop2="val2" /> ``` I would like to change this to: ``` <item prop1="val1" prop2="val2"> <sometihng>text</something> </item> ``` However, I cannot even figure out how to change the self-cosing "item" tag into an open + clos...
You could use the following substitution command: ``` :%s%<item[^>]\{-}\zs */>\ze%></item>%g ``` In this case I use `%` as separator instead of `/`. That way I need less escaping. To explain the regex: * `<item[^>]\{-}` matches `<item` followed by any number of characters, that are not `>`. The `\{-}` matches 0 o...
19,099
<p>What I need to do is yank a word (yw) and then move my cursor to a diffent location and "paste" the word <em>over</em> whatever follows the cursor without disturbing the other characters in the line</p> <p>"yw" ...move cursor "p"</p> <p>inserts the word. I need the put (p) to act as if it was coming from "R" mode<...
[ { "answer_id": 19100, "author": "3dSpatialUser", "author_id": 21223, "author_profile": "https://vi.stackexchange.com/users/21223", "pm_score": 0, "selected": false, "text": "<p>I am also very new to vim, but I have a work-around for you (I think). </p>\n\n<p>What worked on my machine is ...
2019/03/05
[ "https://vi.stackexchange.com/questions/19099", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/21225/" ]
What I need to do is yank a word (yw) and then move my cursor to a diffent location and "paste" the word *over* whatever follows the cursor without disturbing the other characters in the line "yw" ...move cursor "p" inserts the word. I need the put (p) to act as if it was coming from "R" mode
### Replacing Several Occurrences with the Same Text in Visual Mode I want to point out following: when you yanked and replaced the first occurrence with ``` yiw viwp ``` and now want to repeat the replacement for another occurrence with ``` viwp ``` the inserted text is the one from the first replacement and no...
19,111
<p>I used to have some simple <code>map</code> macros that implemented a "pager mode" for vi.</p> <p>When I was reading through a very long file, I would activate pager mode. This would make two key maps:</p> <ul> <li><code>&lt;Space&gt;</code> would be mapped to: <code>^F^G</code></li> <li><code>&lt;Backspace&gt;</...
[ { "answer_id": 19100, "author": "3dSpatialUser", "author_id": 21223, "author_profile": "https://vi.stackexchange.com/users/21223", "pm_score": 0, "selected": false, "text": "<p>I am also very new to vim, but I have a work-around for you (I think). </p>\n\n<p>What worked on my machine is ...
2019/03/06
[ "https://vi.stackexchange.com/questions/19111", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/21250/" ]
I used to have some simple `map` macros that implemented a "pager mode" for vi. When I was reading through a very long file, I would activate pager mode. This would make two key maps: * `<Space>` would be mapped to: `^F^G` * `<Backspace>` would be mapped to: `^B^G` Not that weird. Space would go to the next whole sc...
### Replacing Several Occurrences with the Same Text in Visual Mode I want to point out following: when you yanked and replaced the first occurrence with ``` yiw viwp ``` and now want to repeat the replacement for another occurrence with ``` viwp ``` the inserted text is the one from the first replacement and no...
19,119
<p>In the fzf plugin you can define mappings for the fzf window to open the selected file in a vertical split, etc. How can I make fzf mapping to insert the path of the selected file as a string into the current buffer? I want to use this mapping inside the fzf-window opend by <code>:FZF</code> and similar commands.</p...
[ { "answer_id": 19129, "author": "D. Ben Knoble", "author_id": 10604, "author_profile": "https://vi.stackexchange.com/users/10604", "pm_score": 0, "selected": false, "text": "<p>You could always yank it and put it. I dont know how to create fzf mappings but the right hand side would basic...
2019/03/07
[ "https://vi.stackexchange.com/questions/19119", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/3316/" ]
In the fzf plugin you can define mappings for the fzf window to open the selected file in a vertical split, etc. How can I make fzf mapping to insert the path of the selected file as a string into the current buffer? I want to use this mapping inside the fzf-window opend by `:FZF` and similar commands.
Add FZF setup: ``` func! s:insert_file_name(lines) let @@ = fnamemodify(a:lines[0], ":p") normal! p endfunc let g:fzf_action = { 'ctrl-r': function('s:insert_file_name')} ``` Then open `:Files` select a file and press `<c-r>`. See `:h fzf-examples`.
19,138
<p>I'm trying to make a search and replace to format the following type of strings.</p> <p>INPUT</p> <pre><code>someName0 : in std_logic; someName1 : in integer; someName2 : out unsigned; someName3 : out std_logic_vector(3 downto 0); </code></pre> <p>OUTPUT</p> <pre><code>someName0 : in std_logic; someName1 : in...
[ { "answer_id": 19139, "author": "DJMcMayhem", "author_id": 2920, "author_profile": "https://vi.stackexchange.com/users/2920", "pm_score": 2, "selected": true, "text": "<p>It's actually simpler than doing a search and replace based on the following character. Use word boundaries</p>\n\n<p...
2019/03/08
[ "https://vi.stackexchange.com/questions/19138", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/21279/" ]
I'm trying to make a search and replace to format the following type of strings. INPUT ``` someName0 : in std_logic; someName1 : in integer; someName2 : out unsigned; someName3 : out std_logic_vector(3 downto 0); ``` OUTPUT ``` someName0 : in std_logic; someName1 : in integer; someName2 : out unsigned; som...
It's actually simpler than doing a search and replace based on the following character. Use word boundaries From `:h \<`: ``` */\<* \< Matches the beginning of a word: The next char is the first char of a word. The 'iskeyword' option specifies what is a word character. |/zero-wid...
19,142
<p>In Vimscript, if you use a function as an R-value (right hand side value) of an assignment statement, then the function simply evaluates. For example:</p> <pre><code>let count_pattern += str2nr( strpart( execute( command ), 1 ) ) </code></pre> <p>However, if a function is used not as an R-value of an assignment stat...
[ { "answer_id": 19143, "author": "3N4N", "author_id": 16280, "author_profile": "https://vi.stackexchange.com/users/16280", "pm_score": 3, "selected": false, "text": "<p><strong>Hypothesis</strong>:\nWhen you're using a function as an R-value, or right hand side value, of an assignment sta...
2019/03/08
[ "https://vi.stackexchange.com/questions/19142", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/6952/" ]
In Vimscript, if you use a function as an R-value (right hand side value) of an assignment statement, then the function simply evaluates. For example: ``` let count_pattern += str2nr( strpart( execute( command ), 1 ) ) ``` However, if a function is used not as an R-value of an assignment statement, then a "call" key...
IMO, we have to consider that `vi` and `ed` had ex-commands, and that `vim` introduces functions. When `vim` interprets a line, it needs a way to distinguish `:substitute` from `substitute()`, or `:MyUserThing` (which is a command) from `MyUserThing()` (which is a function). That's why `:call` is required. As `:let`,...
19,156
<p>On my Ubuntu OS, I see this in <code>/etc/vim/vimrc.tiny</code>:</p> <pre><code>$ cat /etc/vim/vimrc.tiny " Vim configuration file, in effect when invoked as "vi". </code></pre> <p>Here's the partial output from <code>:version</code>:<br> <code>system vimrc file: "$VIM/vimrc"</code> </p> <p>It looks like the VIM ...
[ { "answer_id": 19143, "author": "3N4N", "author_id": 16280, "author_profile": "https://vi.stackexchange.com/users/16280", "pm_score": 3, "selected": false, "text": "<p><strong>Hypothesis</strong>:\nWhen you're using a function as an R-value, or right hand side value, of an assignment sta...
2019/03/11
[ "https://vi.stackexchange.com/questions/19156", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/21314/" ]
On my Ubuntu OS, I see this in `/etc/vim/vimrc.tiny`: ``` $ cat /etc/vim/vimrc.tiny " Vim configuration file, in effect when invoked as "vi". ``` Here's the partial output from `:version`: `system vimrc file: "$VIM/vimrc"` It looks like the VIM environment variable is not defined - `echo $VIM` doesn't show anyt...
IMO, we have to consider that `vi` and `ed` had ex-commands, and that `vim` introduces functions. When `vim` interprets a line, it needs a way to distinguish `:substitute` from `substitute()`, or `:MyUserThing` (which is a command) from `MyUserThing()` (which is a function). That's why `:call` is required. As `:let`,...
19,168
<p>I was reading <a href="http://vimdoc.sourceforge.net/htmldoc/starting.html#initialization" rel="nofollow noreferrer">http://vimdoc.sourceforge.net/htmldoc/starting.html#initialization</a>, but couldn't immediately find the answer. Is the <code>$VIM</code> environment variable hardcoded in its binary (not read from a...
[ { "answer_id": 19169, "author": "Ralf", "author_id": 19763, "author_profile": "https://vi.stackexchange.com/users/19763", "pm_score": 2, "selected": false, "text": "<p>Linux view, for more details see Doktor OSwaldo answer.</p>\n\n<p>The installation directory is defined during build (to...
2019/03/12
[ "https://vi.stackexchange.com/questions/19168", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/21314/" ]
I was reading <http://vimdoc.sourceforge.net/htmldoc/starting.html#initialization>, but couldn't immediately find the answer. Is the `$VIM` environment variable hardcoded in its binary (not read from a config file)? The binary is built differently depending on the OS, so I'm guessing that's how the `$VIM` differs per O...
The whole process can be read under `:h $VIM`: > > To avoid the need for every user to set the $VIM environment variable, > Vim will try to get the value for $VIM in this order: > > > 1. The value defined by the $VIM environment variable. You can use this to make Vim look in a specific directory for its support > f...
19,171
<p>I'm trying to make autocommands that will run only when the buffer is a man page (<code>:Man</code>), but I can't get the right pattern as I'm not too familiar with regex and globs. Here's what I've tried so far:</p> <pre><code>autocmd! BufEnter *man://* call Myfunc() autocmd! BufEnter [^man://]* call Myfunc() </co...
[ { "answer_id": 19172, "author": "statox", "author_id": 1841, "author_profile": "https://vi.stackexchange.com/users/1841", "pm_score": 1, "selected": false, "text": "<p>From what I have tested this works:</p>\n\n<pre><code>function! Test()\n echom \"entering man buffer \" . expand('%')...
2019/03/12
[ "https://vi.stackexchange.com/questions/19171", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/18514/" ]
I'm trying to make autocommands that will run only when the buffer is a man page (`:Man`), but I can't get the right pattern as I'm not too familiar with regex and globs. Here's what I've tried so far: ``` autocmd! BufEnter *man://* call Myfunc() autocmd! BufEnter [^man://]* call Myfunc() ``` but nothing seems to wo...
It's probably better to use a `FileType` buffer. The problem with `BufEnter` is that the buffer may not yet be fully set up when it's run; I also don't think it's run for new buffers. I'm also not entirely sure if I follow where you go the `man://` pattern from? I don't see that in the source? And using `bufname('')` ...
19,176
<p>In order to have my vim text always bold, I found this config in stackoverflow:</p> <pre><code> :hi MyGroup cterm=bold :match MyGroup /./ </code></pre> <p>But somehow, it has messed up search highlighting. It is no longer highlighted, but it shouldn't have any effect on that, since it is only changing the cterm p...
[ { "answer_id": 19185, "author": "Tumbler41", "author_id": 6489, "author_profile": "https://vi.stackexchange.com/users/6489", "pm_score": 1, "selected": false, "text": "<p>Despite this seeming like a fairly simple task, I can't think of straight forward way to do this. The best way I know...
2019/03/12
[ "https://vi.stackexchange.com/questions/19176", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/21343/" ]
In order to have my vim text always bold, I found this config in stackoverflow: ``` :hi MyGroup cterm=bold :match MyGroup /./ ``` But somehow, it has messed up search highlighting. It is no longer highlighted, but it shouldn't have any effect on that, since it is only changing the cterm property, and not ctermfg/c...
Despite this seeming like a fairly simple task, I can't think of straight forward way to do this. The best way I know how is to create your own color file and change all the `cterm`s to bold. If you're using one of the default color schemes you can find it at `.../Vim/vim##/colors` where `##` is the version you're run...
19,190
<p>I happen to come across the = register. I checked <code>:h @=</code> and <code>:h recording</code> where it is mentioned. I am not able to understand how to use it. It could be helpful to know a valid usecase for the same.</p>
[ { "answer_id": 19191, "author": "Ralf", "author_id": 19763, "author_profile": "https://vi.stackexchange.com/users/19763", "pm_score": 2, "selected": false, "text": "<p>Assume you often need to insert a timestamp in your documents. Then you could define a mapping for that:</p>\n\n<pre><co...
2019/03/14
[ "https://vi.stackexchange.com/questions/19190", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/16789/" ]
I happen to come across the = register. I checked `:h @=` and `:h recording` where it is mentioned. I am not able to understand how to use it. It could be helpful to know a valid usecase for the same.
So let's begin by quoting the doc [`:h @=`](http://vimhelp.appspot.com/change.txt.html#%40%3d) ``` When typing the '=' after " or CTRL-R the cursor moves to the command-line, where you can enter any expression (see |expression|). All normal command-line editing commands are available, including a special history for ...
19,209
<p>Other editors and IDEs, such as <a href="https://code.visualstudio.com/" rel="noreferrer">VSCode</a> and <a href="https://www.rstudio.com/" rel="noreferrer">RStudio</a>, have an integrated console/terminal/REPL with the following characteristics:</p> <ul> <li>They open in a split window. The file we’re working on i...
[ { "answer_id": 19210, "author": "D. Ben Knoble", "author_id": 10604, "author_profile": "https://vi.stackexchange.com/users/10604", "pm_score": 3, "selected": false, "text": "<p><em>Disclaimer</em>: this answer is more vim-centric than it is neovim-centric because I use the one and not th...
2019/03/16
[ "https://vi.stackexchange.com/questions/19209", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/21397/" ]
Other editors and IDEs, such as [VSCode](https://code.visualstudio.com/) and [RStudio](https://www.rstudio.com/), have an integrated console/terminal/REPL with the following characteristics: * They open in a split window. The file we’re working on is visible at the same time as the console. * If we press a certain sho...
After further searching and testing, it looks like [`kassio/neoterm`](https://github.com/kassio/neoterm) can tick all the boxes, with the following configuration: ``` let g:neoterm_default_mod='belowright' " open terminal in bottom split let g:neoterm_size=16 " terminal split size let g:neoterm_autoscroll=1 " scroll t...
19,218
<p>I would like an object method call to be syntax highlighted in Vim. For instance, in an expression that contains <code>person.getName()</code>, I would like to match <code>getName</code> and give it some syntax highlighting.</p> <p>I have tried quite a number of patterns and at the moment, this is what I have in my...
[ { "answer_id": 19210, "author": "D. Ben Knoble", "author_id": 10604, "author_profile": "https://vi.stackexchange.com/users/10604", "pm_score": 3, "selected": false, "text": "<p><em>Disclaimer</em>: this answer is more vim-centric than it is neovim-centric because I use the one and not th...
2019/03/17
[ "https://vi.stackexchange.com/questions/19218", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/21080/" ]
I would like an object method call to be syntax highlighted in Vim. For instance, in an expression that contains `person.getName()`, I would like to match `getName` and give it some syntax highlighting. I have tried quite a number of patterns and at the moment, this is what I have in my experimental syntax file; ``` ...
After further searching and testing, it looks like [`kassio/neoterm`](https://github.com/kassio/neoterm) can tick all the boxes, with the following configuration: ``` let g:neoterm_default_mod='belowright' " open terminal in bottom split let g:neoterm_size=16 " terminal split size let g:neoterm_autoscroll=1 " scroll t...
19,235
<p>I know that with this command:</p> <pre><code>:yyp!!bash </code></pre> <p>I can execute current line and print the output in the next line (actually it copies the current line to the next line, executes it, and replaces it with the output), to get from this:</p> <pre><code>echo "Hello" </code></pre> <p>to this (...
[ { "answer_id": 19246, "author": "Doktor OSwaldo", "author_id": 11316, "author_profile": "https://vi.stackexchange.com/users/11316", "pm_score": 2, "selected": false, "text": "<p>When you have the lines selected you could just use the following:</p>\n\n<pre><code>yPgv:!bash\n</code></pre>...
2019/03/18
[ "https://vi.stackexchange.com/questions/19235", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/21415/" ]
I know that with this command: ``` :yyp!!bash ``` I can execute current line and print the output in the next line (actually it copies the current line to the next line, executes it, and replaces it with the output), to get from this: ``` echo "Hello" ``` to this (after the command above): ``` echo "Hello" Hello...
When you have the lines selected you could just use the following: ``` yPgv:!bash ``` If you want to have that as a mapping you can do like that: ``` :xnoremap x yPgv:!bash<CR> ``` To be clear, do NOT use `x` here but insert your desired mapping. `x` would be a horrible idea, the cut function is pretty useful. *...
19,236
<p>see the following session in dash:</p> <pre><code>$ printf "foo\nbar\n" &gt; testfile $ cat testfile foo bar $ vim -E testfile &lt;&lt;-EOS &gt; 1 &gt; s/foo/baz/ &gt; x &gt; EOS $ echo $? 1 $ cat testfile baz bar $ vim -E testfile +'1' +'s/baz/foo/' +'x' $ echo $? 0 $ </code></pre> <p>I use ex-mode of vi for exch...
[ { "answer_id": 19237, "author": "John1024", "author_id": 16880, "author_profile": "https://vi.stackexchange.com/users/16880", "pm_score": 0, "selected": false, "text": "<p>Let's consider this test file:</p>\n\n<pre><code>$ cat file\nbaz is here\n</code></pre>\n\n<p>Now, let's run two var...
2019/03/18
[ "https://vi.stackexchange.com/questions/19236", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/21417/" ]
see the following session in dash: ``` $ printf "foo\nbar\n" > testfile $ cat testfile foo bar $ vim -E testfile <<-EOS > 1 > s/foo/baz/ > x > EOS $ echo $? 1 $ cat testfile baz bar $ vim -E testfile +'1' +'s/baz/foo/' +'x' $ echo $? 0 $ ``` I use ex-mode of vi for exchaning the string `foo` with the string `baz` by...
This is a interesting question and I'm not sure I fully understand what is going on. So here are *my* findings based on *my* Vim setup. --- My setup contains some plugins (mainly self written) installed in `~/.vim/pack/.../start`. These plugins all require Vim to run in `nocompatible` mode (see `:help 'compatible'`)...
19,243
<p>(EDIT: In the original question, I had accidentally used <code>\w</code> instead of <code>\&lt;</code>. Comments and answers with <code>\w</code> should be interpreted as using <code>\&lt;</code> as well.)</p> <p>In my LaTeX source files, section headings have an initial uppercase on each first word, but all lower...
[ { "answer_id": 19244, "author": "D. Ben Knoble", "author_id": 10604, "author_profile": "https://vi.stackexchange.com/users/10604", "pm_score": 2, "selected": false, "text": "<p>Limit the match using <code>\\zs</code> and <code>\\ze</code> as Klaus suggested and adjusting per Mars:</p>\n\...
2019/03/19
[ "https://vi.stackexchange.com/questions/19243", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/4643/" ]
(EDIT: In the original question, I had accidentally used `\w` instead of `\<`. Comments and answers with `\w` should be interpreted as using `\<` as well.) In my LaTeX source files, section headings have an initial uppercase on each first word, but all lowercase on subsequent words. I want to convert all words in each...
Limit the match using `\zs` and `\ze` as Klaus suggested and adjusting per Mars: ``` :g/section{/s/[^{\\]\zs\<\(.\)/\u&/gc ``` The `g/section/` is needed because we want to do this only on the `section{` lines, but `section{` should not be involved in the replacement match. Then `[^{\\]\zs` means that we don't try ...
19,250
<p>So, to begin, this is similar to <a href="https://vi.stackexchange.com/questions/2824/pipe-shell-command-into-buffer-in-real-time">Pipe shell command into buffer in real-time</a>.</p> <p>The difference is that the top answer there pipes the output to a new buffer. How do I pipe the output <strong>to the editor itse...
[ { "answer_id": 19265, "author": "Rich", "author_id": 343, "author_profile": "https://vi.stackexchange.com/users/343", "pm_score": 1, "selected": false, "text": "<p>You've clarified in the comments that your need would be satisfied if you could edit the output buffer and current command p...
2019/03/20
[ "https://vi.stackexchange.com/questions/19250", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/21415/" ]
So, to begin, this is similar to [Pipe shell command into buffer in real-time](https://vi.stackexchange.com/questions/2824/pipe-shell-command-into-buffer-in-real-time). The difference is that the top answer there pipes the output to a new buffer. How do I pipe the output **to the editor itself in real time**? For exa...
You've clarified in the comments that your need would be satisfied if you could edit the output buffer and current command prompt when in a `:terminal` buffer. You can achieve the latter by using your shell's "edit in an editor" function. In bash, this is called `edit-and-execute-command` and is usually bound to `Ctrl...
19,257
<p>I need to find ONLY the lines that start with the string <code>G1 Z</code>, and then replace any occurrence on that same line of <code>F1800</code> with a new value of <code>F500</code>. For example:</p> <pre><code>G1 Z9.800 F1800.000 ; move to next layer (48) G1 X103.711 Y99.145 F1800.000 ; move to first perimeter...
[ { "answer_id": 19258, "author": "Ralf", "author_id": 19763, "author_profile": "https://vi.stackexchange.com/users/19763", "pm_score": 4, "selected": true, "text": "<p>Try:</p>\n\n<pre><code>:g/^G1 Z/s/F1800/F500/g\n</code></pre>\n\n<p>The <code>:g</code> is the \"global\" command. It sel...
2019/03/20
[ "https://vi.stackexchange.com/questions/19257", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/11454/" ]
I need to find ONLY the lines that start with the string `G1 Z`, and then replace any occurrence on that same line of `F1800` with a new value of `F500`. For example: ``` G1 Z9.800 F1800.000 ; move to next layer (48) G1 X103.711 Y99.145 F1800.000 ; move to first perimeter point G1 X96.289 Y96.289 E320.13685 ; perimete...
Try: ``` :g/^G1 Z/s/F1800/F500/g ``` The `:g` is the "global" command. It selects lines with a regular expression and then executes a command on it. Here it selects lines that start with `G1 Z` and then substitutes all "F1800" with "F500" in this line. BTW: * The default command for `:g` is `print`. So by just e...
19,269
<p>I'm trying to make it easier to refactor stuff by running a single command that "performs the last rename interactively".</p> <p>I have a binding for doing this that sort of works, but I'm curious whether there's a way to prevent it from ever getting "out of sync" by replacing an old substitution with a recent edit...
[ { "answer_id": 19270, "author": "Peter Rincker", "author_id": 778, "author_profile": "https://vi.stackexchange.com/users/778", "pm_score": 3, "selected": true, "text": "<p>You can use <code>InsertLeave</code> to capture <code>@@</code> and <code>@.</code> then use those values in your su...
2019/03/21
[ "https://vi.stackexchange.com/questions/19269", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/6420/" ]
I'm trying to make it easier to refactor stuff by running a single command that "performs the last rename interactively". I have a binding for doing this that sort of works, but I'm curious whether there's a way to prevent it from ever getting "out of sync" by replacing an old substitution with a recent edit. --- so...
You can use `InsertLeave` to capture `@@` and `@.` then use those values in your substitution mapping. ``` nnoremap <expr> ciw <SID>replacer() nnoremap gs :<c-u>%s/<c-r>=get(g:, 'replacer_pat')<cr>/<c-r>=get(g:, 'replacer_str')<cr>/gc function s:replacer() augroup replacer autocmd! autocmd InsertLeave * exe...
19,277
<p>I'd like to make a command that works like this: <code>:KeepCursor {cmd}</code> will the given execute ex command string, then restore the cursor's position. A primary example is:</p> <pre><code>:KeepCursor normal! * </code></pre> <p>which would perform a keyword search without jumping to the next match. This ca...
[ { "answer_id": 19278, "author": "Peter Rincker", "author_id": 778, "author_profile": "https://vi.stackexchange.com/users/778", "pm_score": 4, "selected": true, "text": "<blockquote>\n <p>Can it be written?</p>\n</blockquote>\n\n<p>Yup.</p>\n\n<pre><code>command! -nargs=* -complete=comma...
2019/03/22
[ "https://vi.stackexchange.com/questions/19277", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/13728/" ]
I'd like to make a command that works like this: `:KeepCursor {cmd}` will the given execute ex command string, then restore the cursor's position. A primary example is: ``` :KeepCursor normal! * ``` which would perform a keyword search without jumping to the next match. This can of course be accomplished in other wa...
> > Can it be written? > > > Yup. ``` command! -nargs=* -complete=command KeepCursor \ let [s:view, s:win] = [winsaveview(), win_getid()] | \ try | \ execute <q-args> | \ finally | \ if win_id2win(s:win) | \ call win_gotoid(s:win) | \ endif | \ keepjumps...
19,285
<p>Preface: Newish to vim so please excuse any rookie mistakes.</p> <p>I normally use vim-latex/latex-suite to edit .tex files, and it works great. I've also started to use vim to edit scripts, and I use the autoclose plugin to help with that. Unfortunately, autoclose interferes with some of the imaps in latex-suite, ...
[ { "answer_id": 19278, "author": "Peter Rincker", "author_id": 778, "author_profile": "https://vi.stackexchange.com/users/778", "pm_score": 4, "selected": true, "text": "<blockquote>\n <p>Can it be written?</p>\n</blockquote>\n\n<p>Yup.</p>\n\n<pre><code>command! -nargs=* -complete=comma...
2019/03/23
[ "https://vi.stackexchange.com/questions/19285", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/21479/" ]
Preface: Newish to vim so please excuse any rookie mistakes. I normally use vim-latex/latex-suite to edit .tex files, and it works great. I've also started to use vim to edit scripts, and I use the autoclose plugin to help with that. Unfortunately, autoclose interferes with some of the imaps in latex-suite, so I'd lik...
> > Can it be written? > > > Yup. ``` command! -nargs=* -complete=command KeepCursor \ let [s:view, s:win] = [winsaveview(), win_getid()] | \ try | \ execute <q-args> | \ finally | \ if win_id2win(s:win) | \ call win_gotoid(s:win) | \ endif | \ keepjumps...
19,288
<p>I want to make toggleable window with terminal buffer similar to every IDE terminal feature.</p> <hr> <p>Currently i have mapped:</p> <pre><code>noremap &lt;F4&gt; :botright 8split term://bash&lt;CR&gt; tnoremap &lt;F4&gt; &lt;C-\&gt;&lt;C-n&gt;:q&lt;CR&gt; autocmd BufEnter term://* startinsert | set wfh </code><...
[ { "answer_id": 37347, "author": "Fsmv", "author_id": 1348, "author_profile": "https://vi.stackexchange.com/users/1348", "pm_score": 2, "selected": false, "text": "<p>Now vim has <code>:term</code> built in, not just in neo vim. So you can use that and then to hide it use <code>CTRL-W :hi...
2019/03/23
[ "https://vi.stackexchange.com/questions/19288", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/8444/" ]
I want to make toggleable window with terminal buffer similar to every IDE terminal feature. --- Currently i have mapped: ``` noremap <F4> :botright 8split term://bash<CR> tnoremap <F4> <C-\><C-n>:q<CR> autocmd BufEnter term://* startinsert | set wfh ``` but buffer is lost whenever is not active on any window (ex....
Now vim has `:term` built in, not just in neo vim. So you can use that and then to hide it use `CTRL-W :hide` I got this from `:help terminal` (as suggested in the comments above): ``` You can use CTRL-W :hide to close the terminal window and make the buffer hidden, the job keeps running. The :buffer command can ...
19,319
<p>can anyone give me an example of how <code>!!</code> works? The documentation says:</p> <pre><code>!!{filter} Filter [count] lines through the external program {filter}. </code></pre>
[ { "answer_id": 19320, "author": "D. Ben Knoble", "author_id": 10604, "author_profile": "https://vi.stackexchange.com/users/10604", "pm_score": 4, "selected": true, "text": "<p><code>!!</code> (and more generally the <code>!</code> operator) provides vim builtin support for all the unix f...
2019/03/25
[ "https://vi.stackexchange.com/questions/19319", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/21157/" ]
can anyone give me an example of how `!!` works? The documentation says: ``` !!{filter} Filter [count] lines through the external program {filter}. ```
`!!` (and more generally the `!` operator) provides vim builtin support for all the unix filters that have evolved over the ages: this includes `cut`, `paste`, `sort`, `uniq`, `awk`, `sed`, even `bash`. Basically a filter is anything that can transform stdin to stdout (possibly doing something meaningful—the identity f...
19,326
<p>VIM doesn't conceal text, for example tex. Here's my vimrc: </p> <pre><code>"commands for vim-plug "PlugInstall - installs plugs "PlugUpdate - updates plugs "PlugClean - remove unused directories "PlugUpgrade - upgrades vim-plug itself "PlugStatus - status of plugs "vim-plug installer if empty(glob('~/.vim/a...
[ { "answer_id": 19327, "author": "w0nsh", "author_id": 21518, "author_profile": "https://vi.stackexchange.com/users/21518", "pm_score": 1, "selected": true, "text": "<p>You should remove augroup remember_folds commands</p>\n" }, { "answer_id": 19333, "author": "Michał Syposz",...
2019/03/26
[ "https://vi.stackexchange.com/questions/19326", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/21516/" ]
VIM doesn't conceal text, for example tex. Here's my vimrc: ``` "commands for vim-plug "PlugInstall - installs plugs "PlugUpdate - updates plugs "PlugClean - remove unused directories "PlugUpgrade - upgrades vim-plug itself "PlugStatus - status of plugs "vim-plug installer if empty(glob('~/.vim/autoload/plug.v...
You should remove augroup remember\_folds commands
19,358
<p>I am using macvim 8.1, the map command is</p> <pre><code>:inoremap &lt;C-$&gt; &lt;End&gt; </code></pre> <p>I also tried <code>&lt;C-4&gt;</code>, no working.</p> <p>tried other number, can't work too (however CTRL-6 could work).</p> <p>Also tried <code>nnoremap</code>, same result.</p> <p>the <code>:map &lt;C-...
[ { "answer_id": 19359, "author": "Ralf", "author_id": 19763, "author_profile": "https://vi.stackexchange.com/users/19763", "pm_score": 3, "selected": false, "text": "<p>Normally Ctrl-Number produce a different key code. You can check like this:</p>\n\n<p>Open Vim and change to insert mode...
2019/03/29
[ "https://vi.stackexchange.com/questions/19358", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/21218/" ]
I am using macvim 8.1, the map command is ``` :inoremap <C-$> <End> ``` I also tried `<C-4>`, no working. tried other number, can't work too (however CTRL-6 could work). Also tried `nnoremap`, same result. the `:map <C-$>` command shows ``` i <C-$> * <End> ```
Normally Ctrl-Number produce a different key code. You can check like this: Open Vim and change to insert mode. Then hit `Ctrl-V` followed by `Ctrl-4` (or whatever you plan to map). On Linux this produces the output `^\`. Note that this is one character, usually displayed in light-blue. So `Ctrl-4` is identical to `...
19,362
<p>I am trying to find (in Vim script) if the 2 files open using vimdiff are same or different? Is there a way to do that? (a variable like &amp;diff perhaps?)</p>
[ { "answer_id": 19363, "author": "D. Ben Knoble", "author_id": 10604, "author_profile": "https://vi.stackexchange.com/users/10604", "pm_score": 2, "selected": true, "text": "<p>The easiest option is not to make vim do any work at all: <code>diff -q</code> reports if files are different, a...
2019/03/29
[ "https://vi.stackexchange.com/questions/19362", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/16636/" ]
I am trying to find (in Vim script) if the 2 files open using vimdiff are same or different? Is there a way to do that? (a variable like &diff perhaps?)
The easiest option is not to make vim do any work at all: `diff -q` reports if files are different, and `diff -s` if they are the same. According to [this answer](https://stackoverflow.com/a/5439382) if you don’t need output, `cmp -s` works. So in vimscript you might do ``` let l:files = [ get_file_names() ] " left ...
19,372
<p>Is there a way to turn the "region bounded by two specific marks" into a text object similar to <code>aw</code> or <code>ap</code>?</p> <p>I've been messing around with <code>vi</code> and found it convenient to use <code>a</code> and <code>b</code>. and define a region and to define commands that act on the region...
[ { "answer_id": 19373, "author": "3N4N", "author_id": 16280, "author_profile": "https://vi.stackexchange.com/users/16280", "pm_score": 1, "selected": false, "text": "<p>I would use something like the following. <strong>There might be a lot of corner cases</strong>, but it's a start:</p>\n...
2019/03/30
[ "https://vi.stackexchange.com/questions/19372", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/6420/" ]
Is there a way to turn the "region bounded by two specific marks" into a text object similar to `aw` or `ap`? I've been messing around with `vi` and found it convenient to use `a` and `b`. and define a region and to define commands that act on the region bounded by `a` and `b`. It would be nice to be able to expose a...
Here is an example for a custom text object working with the marks `a` and `b`. ``` " char-wise onoremap am :<c-u>execute 'normal `av`b'<cr> xnoremap am :<c-u>execute 'normal `av`b'<cr> " line-wise onoremap aM :<c-u>execute 'normal `aV`b'<cr> xnoremap aM :<c-u>execute 'normal `aV`b'<cr> ``` To copy the characters b...
19,394
<p>I have been using nvim terminal mode to learn python and I want to have Ctrl-C break the python script from the terminal window even when I am not in insert mode. However, I also want Ctrl-C in my python script to result in entering an escape command directly to the terminal.</p> <p>I have </p> <pre><code>if exist...
[ { "answer_id": 19395, "author": "nmb", "author_id": 21593, "author_profile": "https://vi.stackexchange.com/users/21593", "pm_score": 0, "selected": false, "text": "<p>Adding this to my .vimrc seems to have fixed it for my purposes without slowing down vim load or python launch</p>\n\n<pr...
2019/04/01
[ "https://vi.stackexchange.com/questions/19394", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/21593/" ]
I have been using nvim terminal mode to learn python and I want to have Ctrl-C break the python script from the terminal window even when I am not in insert mode. However, I also want Ctrl-C in my python script to result in entering an escape command directly to the terminal. I have ``` if exists(':tnoremap') nn...
### Using autocmds Neovim provides `TermOpen`, while vim provides `TerminalOpen`: ``` augroup MyTermMappings autocmd! if has('nvim') autocmd TermOpen * nnoremap <buffer> <C-c> i<C-c> else if exists('##TerminalOpen') audocmd TerminalOpen * nnoremap <buffer> <C-c> i<C-c> endif augroup END ``` I've pro...
19,407
<p>If I have a text containing markdown matching markings e.g.</p> <p>"Strikethrough uses two tildes. ~~Scratch this.~~"</p> <p>What would be a good way to delete all those occurrences such as - in this example - "~~Scratch this.~~"?</p>
[ { "answer_id": 19395, "author": "nmb", "author_id": 21593, "author_profile": "https://vi.stackexchange.com/users/21593", "pm_score": 0, "selected": false, "text": "<p>Adding this to my .vimrc seems to have fixed it for my purposes without slowing down vim load or python launch</p>\n\n<pr...
2019/04/02
[ "https://vi.stackexchange.com/questions/19407", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/19878/" ]
If I have a text containing markdown matching markings e.g. "Strikethrough uses two tildes. ~~Scratch this.~~" What would be a good way to delete all those occurrences such as - in this example - "~~Scratch this.~~"?
### Using autocmds Neovim provides `TermOpen`, while vim provides `TerminalOpen`: ``` augroup MyTermMappings autocmd! if has('nvim') autocmd TermOpen * nnoremap <buffer> <C-c> i<C-c> else if exists('##TerminalOpen') audocmd TerminalOpen * nnoremap <buffer> <C-c> i<C-c> endif augroup END ``` I've pro...