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 |
|---|---|---|---|---|---|---|
2,630 | <p>I am developing main in Rails using SASS, Slim and Coffeescript. I have Exuberant Ctags installed and using <a href="http://tbaggery.com/2011/08/08/effortless-ctags-with-git.html" rel="noreferrer">tpope's setup</a></p>
<p>It kind of works so at least I can move around my ruby code.</p>
<p>But I would like to be ab... | [
{
"answer_id": 2631,
"author": "Ingo Karkat",
"author_id": 970,
"author_profile": "https://vi.stackexchange.com/users/970",
"pm_score": 2,
"selected": false,
"text": "<p>Vim is a powerful text editor. The <em>tags</em> feature is based on a simple foundation: Vim can read one or several ... | 2015/03/19 | [
"https://vi.stackexchange.com/questions/2630",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/237/"
] | I am developing main in Rails using SASS, Slim and Coffeescript. I have Exuberant Ctags installed and using [tpope's setup](http://tbaggery.com/2011/08/08/effortless-ctags-with-git.html)
It kind of works so at least I can move around my ruby code.
But I would like to be able to:
```
SASS
color: $whatever <- go to... | Vim is a powerful text editor. The *tags* feature is based on a simple foundation: Vim can read one or several *tags databases*, which contain line-based records consisting of a tag (basically a string), a corresponding file and address (search pattern) to locate it, and optional additional information.
That's what yo... |
2,645 | <p>I've been messing about with file type specific commands this evening (which is going to be very useful) and I'm trying to write a markdown comment command at the moment. I'm not sure how to go about this though. </p>
<p>So If I have the following text : </p>
<pre><code>This is a bit
of text that
I'm going
to c... | [
{
"answer_id": 2647,
"author": "jjaderberg",
"author_id": 1306,
"author_profile": "https://vi.stackexchange.com/users/1306",
"pm_score": 4,
"selected": true,
"text": "<p>Vim creates marks for the beginning and the end of the last visual selection in the current buffer. You can use <code>... | 2015/03/20 | [
"https://vi.stackexchange.com/questions/2645",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1443/"
] | I've been messing about with file type specific commands this evening (which is going to be very useful) and I'm trying to write a markdown comment command at the moment. I'm not sure how to go about this though.
So If I have the following text :
```
This is a bit
of text that
I'm going
to comment
```
I can r... | Vim creates marks for the beginning and the end of the last visual selection in the current buffer. You can use `'<` to move to the beginning and `'>` to move to end. In this way you can conveniently add any text you want before and after the visual selection. For example, I have a map for inserting a LaTeX underline c... |
2,665 | <p>I quite often start typing the <em>s</em> before fully releasing the shift key, and having to correct the command afterwards is a bit annoying.</p>
<p>Is there any way to make <code>:Set ...</code> an alias for <code>:set ...</code>?</p>
| [
{
"answer_id": 2667,
"author": "Ingo Karkat",
"author_id": 970,
"author_profile": "https://vi.stackexchange.com/users/970",
"pm_score": 5,
"selected": true,
"text": "<p>While you cannot define custom commands starting with lowercase characters (like the built-in ones), nothing prevents y... | 2015/03/21 | [
"https://vi.stackexchange.com/questions/2665",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1461/"
] | I quite often start typing the *s* before fully releasing the shift key, and having to correct the command afterwards is a bit annoying.
Is there any way to make `:Set ...` an alias for `:set ...`? | While you cannot define custom commands starting with lowercase characters (like the built-in ones), nothing prevents you from doing the opposite, defining user commands that mirror the built-in ones.
```
:command! -nargs=* -complete=option Set set <args>
```
If you do this for additional commands, just ensure the n... |
2,670 | <p>I'm using Processing. I've created a Python script that enables me to compile a sketch from the directory that the processing file is in. </p>
<p>I'm currently running as follows</p>
<pre><code>:!./make.py
</code></pre>
<p>This works, but when It's running the Vim window (that I was in) is taken over by the outp... | [
{
"answer_id": 2671,
"author": "kenorb",
"author_id": 467,
"author_profile": "https://vi.stackexchange.com/users/467",
"pm_score": 2,
"selected": false,
"text": "<p>The best idea it would be to define your own <code>:make</code> by setting <code>makeprg</code> option and then you can run... | 2015/03/21 | [
"https://vi.stackexchange.com/questions/2670",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1443/"
] | I'm using Processing. I've created a Python script that enables me to compile a sketch from the directory that the processing file is in.
I'm currently running as follows
```
:!./make.py
```
This works, but when It's running the Vim window (that I was in) is taken over by the output of the programme. I think that... | One way, which I don't like all that much, could be to use [`system()`](http://vimhelp.appspot.com/eval.txt.html#system%28%29). `system()` saves the output and returns it, so unless you capture it in a variable or echo it, the output won't show up:
```
:call system('./make.py')
```
`system` doesn't seem to have any ... |
2,680 | <p>Imagine you want to quote the word below. If <code>|</code> is the cursor position you can easily quote the word with <code>cw""<Esc>P</code> from Normal mode.</p>
<pre><code>|below
</code></pre>
<p>I want to achieve the same behaviour in Command-line mode. My question is how can I say to the Command-line mo... | [
{
"answer_id": 2681,
"author": "EvergreenTree",
"author_id": 865,
"author_profile": "https://vi.stackexchange.com/users/865",
"pm_score": 4,
"selected": false,
"text": "<p>This is because special keys like <code><Esc></code> are not translated in <code>normal</code> commands, and a... | 2015/03/22 | [
"https://vi.stackexchange.com/questions/2680",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/356/"
] | Imagine you want to quote the word below. If `|` is the cursor position you can easily quote the word with `cw""<Esc>P` from Normal mode.
```
|below
```
I want to achieve the same behaviour in Command-line mode. My question is how can I say to the Command-line mode that I want to type an `<Esc>`. I tried `:norm cw""... | `<C-v>` is what you are looking for. It allows you to enter literal characters (e.g., a literal `Esc` instead of the string "Esc") without requiring you to escape anything.
```
:norm cw""<C-v><Esc>P
```
displays as:
```
:norm cw""^[P
```
and will do what you want (i.e., quote the word). You can also use this with... |
2,702 | <p>I'm using VIm for all kinds of things (or gVim in this case), including monitoring output written to a file; I use <code>autoread</code> to make Vim reread the file, which it does whenever I switch the keyboard focus to it.</p>
<p>Is there any way to make Vim update the buffer even if I don't switch the keyboard fo... | [
{
"answer_id": 2731,
"author": "Martin Tournoij",
"author_id": 51,
"author_profile": "https://vi.stackexchange.com/users/51",
"pm_score": 6,
"selected": true,
"text": "<p><a href=\"http://vimhelp.appspot.com/options.txt.html#%27autoread%27\" rel=\"nofollow noreferrer\"><code>:help 'autor... | 2015/03/23 | [
"https://vi.stackexchange.com/questions/2702",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1489/"
] | I'm using VIm for all kinds of things (or gVim in this case), including monitoring output written to a file; I use `autoread` to make Vim reread the file, which it does whenever I switch the keyboard focus to it.
Is there any way to make Vim update the buffer even if I don't switch the keyboard focus? I've tried setti... | [`:help 'autoread'`](http://vimhelp.appspot.com/options.txt.html#%27autoread%27) doesn't have a lot of information on how it works, but Vim checks if an open file is modified in certain events (it always does this), and will reload it automatically if `autoread` is abled.
Specifically, it checks when:
* `:checktime` ... |
2,703 | <p>Let say I've register which has string stored in it, but I'd like to use <em>substitute</em> command to change it.</p>
<p>For example I've 5x5 html table:</p>
<pre><code>let @t='<table>'.repeat('<tr>'.repeat('<td>_</td>',5).'</tr>',5).'</table>'
</code></pre>
<p>and I'd like to... | [
{
"answer_id": 2704,
"author": "PhilippFrank",
"author_id": 1296,
"author_profile": "https://vi.stackexchange.com/users/1296",
"pm_score": 3,
"selected": false,
"text": "<p>Apart from using the let-statement and dealing with vim-script, you need to paste it into a buffer and then yank it... | 2015/03/23 | [
"https://vi.stackexchange.com/questions/2703",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/467/"
] | Let say I've register which has string stored in it, but I'd like to use *substitute* command to change it.
For example I've 5x5 html table:
```
let @t='<table>'.repeat('<tr>'.repeat('<td>_</td>',5).'</tr>',5).'</table>'
```
and I'd like to replace placeholder (`_`) with some other data ideally by modifying existin... | Ex commands work on the buffer contents; for register (or variable) contents, you need to use a corresponding Vimscript function (if it exists).
For `:substitute`, the equivalent is `substitute()` (that was easy, right?) So:
```
:let @t = substitute(@t, '_', 'test', 'g')
``` |
2,705 | <p>In my vimrc I have <code><C-H></code>, <code><C-J></code>, <code><C-K></code> and <code><C-L></code> mapped to navigate between split windows in normal mode. When I use diff mode I only ever have windows in vertical splits, so I'd like to re-purpose <code><C-J></code> and <code><C-K... | [
{
"answer_id": 2706,
"author": "tommcdo",
"author_id": 64,
"author_profile": "https://vi.stackexchange.com/users/64",
"pm_score": 5,
"selected": true,
"text": "<p>You can create an expression mapping that checks <code>&diff</code>. This is done using the <code><expr></code> key... | 2015/03/23 | [
"https://vi.stackexchange.com/questions/2705",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1115/"
] | In my vimrc I have `<C-H>`, `<C-J>`, `<C-K>` and `<C-L>` mapped to navigate between split windows in normal mode. When I use diff mode I only ever have windows in vertical splits, so I'd like to re-purpose `<C-J>` and `<C-K>` to jump to the previous/next diff.
`:help diff` mentions `&diff` when using vimdiff to determ... | You can create an expression mapping that checks `&diff`. This is done using the `<expr>` keyword.
### Example
```
nnoremap <expr> <C-J> &diff ? ']c' : '<C-W>j'
```
With this, each time you type `<C-J>`, the expression `&diff ? ']c' : '<C-W>h'` is evaluated, and the result (a string) is used for your map. So, in di... |
2,713 | <p>I have the following piece of HTML:</p>
<pre><code><div>
<section>
</section>
</div>
</code></pre>
<p>I would like to wrap the 2 section tags in a single article like so:</p>
<pre><code><div>
<article>
<section>
</section>
</article>
</div&g... | [
{
"answer_id": 2714,
"author": "Martin Tournoij",
"author_id": 51,
"author_profile": "https://vi.stackexchange.com/users/51",
"pm_score": 2,
"selected": false,
"text": "<p><kbd>vitVS<article></kbd> seems to do what you want.</p>\n\n<ul>\n<li><kbd>v</kbd> to start select mode</li>\n<li... | 2015/03/24 | [
"https://vi.stackexchange.com/questions/2713",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1503/"
] | I have the following piece of HTML:
```
<div>
<section>
</section>
</div>
```
I would like to wrap the 2 section tags in a single article like so:
```
<div>
<article>
<section>
</section>
</article>
</div>
```
I have [vim-surround](https://github.com/tpope/vim-surround) installed.
If I `v``i``t``... | `vitVS<article>` seems to do what you want.
* `v` to start select mode
* `it` to select "inner tag"
* `V` to start line-wise visual mode
* `S<article>` to surround
It would be better to start with line-wise visual mode, and go from there, but `it` changes it back to 'normal' (non-line wise) visual mode. |
2,717 | <p>I currently use <a href="http://www.vim.org/scripts/script.php?script_id=896" rel="nofollow">Ricardo Signes's plugin</a> to allow me to use a single command to both check my Perl syntax and save my code only if it is syntactically correct. However, isn't there a simpler way to do this without a plugin and/or a lot ... | [
{
"answer_id": 2718,
"author": "Ingo Karkat",
"author_id": 970,
"author_profile": "https://vi.stackexchange.com/users/970",
"pm_score": 4,
"selected": true,
"text": "<p>The mentioned plugin either uses a custom <code>:Write</code> command, or employs autocmds to hook into the saving. Tho... | 2015/03/24 | [
"https://vi.stackexchange.com/questions/2717",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1111/"
] | I currently use [Ricardo Signes's plugin](http://www.vim.org/scripts/script.php?script_id=896) to allow me to use a single command to both check my Perl syntax and save my code only if it is syntactically correct. However, isn't there a simpler way to do this without a plugin and/or a lot of code?
I can save and then ... | The mentioned plugin either uses a custom `:Write` command, or employs autocmds to hook into the saving. Those are the two possible integrations into Vim.
In the end, any custom solution will probably re-implement large parts of the plugin. The most lightweight approach I can think of is executing the external check c... |
2,725 | <p>I have</p>
<ol>
<li><kbd>q</kbd> <a href="https://github.com/jalanb/dotjab/blob/master/vim/vimrc#L53" rel="nofollow">mapped to <kbd>:</kbd><kbd>q</kbd><kbd>enter</kbd></a></li>
<li><kbd>Q</kbd> <a href="https://github.com/jalanb/dotjab/commit/2b7996373b5b2ef933c633a34837f1343fe75e98" rel="nofollow">mapped to <kbd>&... | [
{
"answer_id": 2726,
"author": "Matt Boehm",
"author_id": 680,
"author_profile": "https://vi.stackexchange.com/users/680",
"pm_score": 4,
"selected": true,
"text": "<p>I would start vim with a command that tells it the current file is a scratch buffer (which vim will not prompt you to sa... | 2015/03/25 | [
"https://vi.stackexchange.com/questions/2725",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/182/"
] | I have
1. `q` [mapped to `:``q``enter`](https://github.com/jalanb/dotjab/blob/master/vim/vimrc#L53)
2. `Q` [mapped to `<esc>``:``q``a``!``enter`](https://github.com/jalanb/dotjab/commit/2b7996373b5b2ef933c633a34837f1343fe75e98)
which means
1. quit, unless something needs to be saved
2. just quit
My meanings for the... | I would start vim with a command that tells it the current file is a scratch buffer (which vim will not prompt you to save):
```
git log | vim -c "setlocal buftype=nofile bufhidden=hide noswapfile" -
```
Because I do this a lot, I save the scratch buffer settings to a command in my .vimrc
```
":ScratchBuffer makes ... |
2,737 | <p>I found a command in NERDCommenter like this:</p>
<pre><code>[count]<leader>cc |NERDComComment|
</code></pre>
<p>I have installed the plugin. But, I don't know how to make it work. So what's the meaning of that command? How can I make it work?</p>
| [
{
"answer_id": 2738,
"author": "Martin Tournoij",
"author_id": 51,
"author_profile": "https://vi.stackexchange.com/users/51",
"pm_score": 4,
"selected": false,
"text": "<ul>\n<li><code>[count]</code> is optional. If given, the mapping works for <em>count</em> lines (ie. comments out <em>... | 2015/03/26 | [
"https://vi.stackexchange.com/questions/2737",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1526/"
] | I found a command in NERDCommenter like this:
```
[count]<leader>cc |NERDComComment|
```
I have installed the plugin. But, I don't know how to make it work. So what's the meaning of that command? How can I make it work? | * `[count]` is optional. If given, the mapping works for *count* lines (ie. comments out *count* lines).
* `<Leader>` is usually the backslash key (`\`), although this can be remapped (also see [What is <Leader>?](https://vi.stackexchange.com/q/836/51) and [How can I find out what <Leader> is set to? And is it possible... |
2,740 | <p>I'm aware of the following comparison:</p>
<pre><code>if @% == "/tmp/crontab.zi5NeVPGRc"
set nobackup
set nowritebackup
set noundofile
set noswapfile
endif
</code></pre>
<p>But how can I use regular expression? For example if the filename contains "crontab", then do this and that?</p>
| [
{
"answer_id": 2741,
"author": "toro2k",
"author_id": 13,
"author_profile": "https://vi.stackexchange.com/users/13",
"pm_score": 5,
"selected": true,
"text": "<p>You just have to use one of <a href=\"http://vimhelp.appspot.com/eval.txt.html#expr-%3D%7E\" rel=\"noreferrer\">the regular ex... | 2015/03/26 | [
"https://vi.stackexchange.com/questions/2740",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/467/"
] | I'm aware of the following comparison:
```
if @% == "/tmp/crontab.zi5NeVPGRc"
set nobackup
set nowritebackup
set noundofile
set noswapfile
endif
```
But how can I use regular expression? For example if the filename contains "crontab", then do this and that? | You just have to use one of [the regular expression match operators](http://vimhelp.appspot.com/eval.txt.html#expr-%3D%7E). For example, using `=~#` to perform a case sensitive match:
```
if @% =~# 'crontab'
# the file name contains 'crontab',
# do this and that
endif
``` |
2,753 | <p>How would one vertically rotate a visual block of text?</p>
<p>For example given this:</p>
<pre><code>h
e
l
l
o
</code></pre>
<p>Select those characters in visual block and rotate them once:</p>
<pre><code>o
h
e
l
l
</code></pre>
<p>As you see, every character is moved down one line, and the last character (<co... | [
{
"answer_id": 2755,
"author": "Gonçalo Ribeiro",
"author_id": 356,
"author_profile": "https://vi.stackexchange.com/users/356",
"pm_score": 3,
"selected": false,
"text": "<p>You can do it like this:</p>\n<ul>\n<li>select the lines you want to rotate (with <code>V</code> or <code><C-v&... | 2015/03/27 | [
"https://vi.stackexchange.com/questions/2753",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/-1/"
] | How would one vertically rotate a visual block of text?
For example given this:
```
h
e
l
l
o
```
Select those characters in visual block and rotate them once:
```
o
h
e
l
l
```
As you see, every character is moved down one line, and the last character (`o`) is wrapped around and put on top
Is this possible? | You can do it like this:
* select the lines you want to rotate (with `V` or `<C-v>`)
* type `:`
* type `<C-w>` to get rid of the `'<,'>` that appeared after the `:`
* type `'> move '<-1`, or the short version `'>m'<-`
* press `<Enter>`
**Explanation**
The `move` command accepts a range to move and an address to wher... |
2,758 | <p>Not easy to find a nice title for my problem.</p>
<p>I'm aware of inserting in front of a text-block:</p>
<p><kbd>Ctrl</kbd>-<kbd>v</kbd> <em>select lines</em> <kbd>I</kbd> <em>type text</em> <kbd>ESC</kbd></p>
<p>Now I would like to do this but also with replacing a part in my block selection. Currently I'm doin... | [
{
"answer_id": 2759,
"author": "Dumitru",
"author_id": 1545,
"author_profile": "https://vi.stackexchange.com/users/1545",
"pm_score": 6,
"selected": true,
"text": "<p>Typing <kbd>c</kbd> after selecting your block instead of <kbd>x</kbd> will remove the text in the selection block and wi... | 2015/03/27 | [
"https://vi.stackexchange.com/questions/2758",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1542/"
] | Not easy to find a nice title for my problem.
I'm aware of inserting in front of a text-block:
`Ctrl`-`v` *select lines* `I` *type text* `ESC`
Now I would like to do this but also with replacing a part in my block selection. Currently I'm doing two operations
`Ctrl`-`v` *select block* `x` *go back to start*
Follow... | Typing `c` after selecting your block instead of `x` will remove the text in the selection block and will enter insert mode. Once you type something and exit insert mode you should have the same change on every line.
Try
`Ctrl`-`v` -- select block -- `c` -- insert whatever -- `Esc` |
2,761 | <p>With the current colourscheme I have been using, it is hard to find where the cursor is positioned when navigating through search results. The highlighting colour and the cursor colour are blending in making it hard to find the cursor.</p>
<p>How do I set the cursor colour different when it is on a highlighted word... | [
{
"answer_id": 2762,
"author": "adelarsq",
"author_id": 177,
"author_profile": "https://vi.stackexchange.com/users/177",
"pm_score": 2,
"selected": false,
"text": "<p>You can choose a better color. Just put this on your vimrc:</p>\n\n<pre><code>hi Cursor guifg=#121212 guibg=#afd700\n</co... | 2015/03/27 | [
"https://vi.stackexchange.com/questions/2761",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1479/"
] | With the current colourscheme I have been using, it is hard to find where the cursor is positioned when navigating through search results. The highlighting colour and the cursor colour are blending in making it hard to find the cursor.
How do I set the cursor colour different when it is on a highlighted word?
 (at 4m 59s). It causes the entire highlight to blink briefly when you leap between search results.
```
" Damian Conway's Die Blinkënmatchen: highlight matches
nnoremap <silent> n n:call HLNext(0.1... |
2,764 | <p>Recently there was an add-on to NeoVim which allows opening terminal in a vim buffer. This has appealing possibilities to send text from one vim window to another replicating, for example, a REPL like behavior.</p>
<p>In the past I was using tmux for this kind of configuration. However now I would like to try it ou... | [
{
"answer_id": 2765,
"author": "Matt Boehm",
"author_id": 680,
"author_profile": "https://vi.stackexchange.com/users/680",
"pm_score": 5,
"selected": true,
"text": "<p>Basically when you have text selected, you want to remap a key sequence to copy, switch to terminal, paste, and then pos... | 2015/03/27 | [
"https://vi.stackexchange.com/questions/2764",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/307/"
] | Recently there was an add-on to NeoVim which allows opening terminal in a vim buffer. This has appealing possibilities to send text from one vim window to another replicating, for example, a REPL like behavior.
In the past I was using tmux for this kind of configuration. However now I would like to try it out using on... | Basically when you have text selected, you want to remap a key sequence to copy, switch to terminal, paste, and then possibly switch windows back and reselect the text. If you have two splits open, this would look something like:
```
vnoremap <F5> y<c-w>wp<c-w>pgv
"explanation:
xnoremap <F5> Remap F5... |
2,776 | <p>One of the open questions I have about Vim is if there is a way to perform a search/replace in the current project (bear with me if I use this notion inherited from other editors).</p>
<p>For instance, let's assume I want to search my project files for a method name, and rename all the instances of that method call... | [
{
"answer_id": 2777,
"author": "akshay",
"author_id": 246,
"author_profile": "https://vi.stackexchange.com/users/246",
"pm_score": 7,
"selected": true,
"text": "<p>There are several ways to do this.</p>\n\n<h3>Inside Current Directory</h3>\n\n<p>If you want to perform the search/replace ... | 2015/03/29 | [
"https://vi.stackexchange.com/questions/2776",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1558/"
] | One of the open questions I have about Vim is if there is a way to perform a search/replace in the current project (bear with me if I use this notion inherited from other editors).
For instance, let's assume I want to search my project files for a method name, and rename all the instances of that method call.
This is... | There are several ways to do this.
### Inside Current Directory
If you want to perform the search/replace in a project tree, you can use Vim's [argument list](http://vimhelp.appspot.com/editing.txt.html#argument-list).
Simply open Vim and then use the `:args` command to populate the argument list. You can pass in mu... |
2,782 | <p>What files do I need to create? What should be inside these files? Is there a default colorscheme file somewhere that I can use and change color values accordingly?</p>
| [
{
"answer_id": 2783,
"author": "akshay",
"author_id": 246,
"author_profile": "https://vi.stackexchange.com/users/246",
"pm_score": 5,
"selected": true,
"text": "<h3>Colorscheme locations</h3>\n\n<p>First, Vim looks in its runtime folders for a <code>colors</code> directory. Here is where... | 2015/03/30 | [
"https://vi.stackexchange.com/questions/2782",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/428/"
] | What files do I need to create? What should be inside these files? Is there a default colorscheme file somewhere that I can use and change color values accordingly? | ### Colorscheme locations
First, Vim looks in its runtime folders for a `colors` directory. Here is where all the colorschemes should be stored ([`:help 'runtimepath'`](http://vimhelp.appspot.com/options.txt.html#%27runtimepath%27))
This means you will need one file that lives in the `~/.vim/colors` folder. Default c... |
2,784 | <p>I have a <code>README.txt</code> file as follows:</p>
<pre><code>This document is a list of
a) Known issues in the services or test environment, i.e. things expected to fail
b) Things to be improved in the test suite
c) Possible bugs to be followed up
</code></pre>
<p>If I add anything to line 2, gVim automagicall... | [
{
"answer_id": 2786,
"author": "Rich",
"author_id": 343,
"author_profile": "https://vi.stackexchange.com/users/343",
"pm_score": 4,
"selected": true,
"text": "<p>Try turning off automatic formatting:</p>\n\n<pre><code>set formatoptions=\n</code></pre>\n\n<p>If this works, you're going to... | 2015/03/30 | [
"https://vi.stackexchange.com/questions/2784",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/398/"
] | I have a `README.txt` file as follows:
```
This document is a list of
a) Known issues in the services or test environment, i.e. things expected to fail
b) Things to be improved in the test suite
c) Possible bugs to be followed up
```
If I add anything to line 2, gVim automagically wraps it as follows
```
a) Known i... | Try turning off automatic formatting:
```
set formatoptions=
```
If this works, you're going to want to try to track down how it's having an effect. There are two possibilities. Either you have `'wrapmargin'` set (which causes Vim to insert newlines when you get within a certain distance of the edge of the window), ... |
2,791 | <p>I'm working on a plugin that allows users to create custom operators. The operators would apply a VimL expression to the motion or text object that the operator moves over.</p>
<h2>Keeping a clean user interface</h2>
<p>I think the cleanest interface for defining the custom operators would be to use a command. I'v... | [
{
"answer_id": 2794,
"author": "Luc Hermitte",
"author_id": 626,
"author_profile": "https://vi.stackexchange.com/users/626",
"pm_score": 3,
"selected": false,
"text": "<p>It seems to me you are looking for <code>:runtime</code>. You can perfectly run commands defined in plugins from your... | 2015/03/31 | [
"https://vi.stackexchange.com/questions/2791",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/64/"
] | I'm working on a plugin that allows users to create custom operators. The operators would apply a VimL expression to the motion or text object that the operator moves over.
Keeping a clean user interface
------------------------------
I think the cleanest interface for defining the custom operators would be to use a ... | It seems to me you are looking for `:runtime`. You can perfectly run commands defined in plugins from your .vimrc, but you have to know the plugin name (that defines it) before that.
```
" 1- Prepare the plugin-suite if it's managed through VAM/Vundle/NeoBundle/...
ActivateAddons FooBar
" 2- Be sure the plugin is loa... |
2,792 | <p>Can I share Vim command history across instances in real time?</p>
<p>By that I mean what people do in bash this way:</p>
<pre><code>export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
</code></pre>
<p>That is, when I run a command <code>echo test1</code> in one shell, and then press <kbd>... | [
{
"answer_id": 2793,
"author": "Ingo Karkat",
"author_id": 970,
"author_profile": "https://vi.stackexchange.com/users/970",
"pm_score": 5,
"selected": true,
"text": "<p>The command history is stored in the <em>viminfo</em> file (<code>:help viminfo</code>). Usually that is read on startu... | 2015/03/27 | [
"https://vi.stackexchange.com/questions/2792",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1553/"
] | Can I share Vim command history across instances in real time?
By that I mean what people do in bash this way:
```
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
```
That is, when I run a command `echo test1` in one shell, and then press `Up` in another one, I see `echo test1`. (To be p... | The command history is stored in the *viminfo* file (`:help viminfo`). Usually that is read on startup and written on exit, but you could explicitly persist and sync between Vim instances with a combination of `:wviminfo` and `:rviminfo`. Note that this will sync the entire information; i.e. also register contents, mar... |
2,796 | <p>assume I have following texts:</p>
<p>aaa-dd-e: "aaa",<br>
bb-x: "bb",<br>
c-9: "c"</p>
<p>I want to do selection like below:</p>
<p><code>aaa-dd-e:</code> "aaa",<br>
<code>bb-x:</code> "bb",<br>
<code>c-9:</code> "c"</p>
<p>I tried using c-v to create a visual block, but after I create selection on the first co... | [
{
"answer_id": 2798,
"author": "Ingo Karkat",
"author_id": 970,
"author_profile": "https://vi.stackexchange.com/users/970",
"pm_score": 4,
"selected": false,
"text": "<p>Vim only supports rectangular blockwise selections, with the exception of the jagged right border when you press <code... | 2015/03/31 | [
"https://vi.stackexchange.com/questions/2796",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1276/"
] | assume I have following texts:
aaa-dd-e: "aaa",
bb-x: "bb",
c-9: "c"
I want to do selection like below:
`aaa-dd-e:` "aaa",
`bb-x:` "bb",
`c-9:` "c"
I tried using c-v to create a visual block, but after I create selection on the first column and I press "f:"( I meant to expand the selection to colon mark... | Selection is generally a mean to an end, more so in Vim where selection is often not necessary in the first place.
Assuming you still want to put quotes around property names in your non-JSON file to turn it into proper JSON:
1. select the lines to modify, character-wise or line-wise, it doesn't matter,
2. `:'<,'>nor... |
2,801 | <p>By default, if a buffer in vim contains a URL such as <code>http://www.google.com</code>, <kbd>g</kbd><kbd>x</kbd> in normal mode will open a browser with that URL. That's very handy. However, if the URL has URL parameters (e.g. <code>http://www.google.com/search?q=stuff</code>), then the URL parameters are missed o... | [
{
"answer_id": 2980,
"author": "user569825",
"author_id": 1631,
"author_profile": "https://vi.stackexchange.com/users/1631",
"pm_score": 5,
"selected": true,
"text": "<p>As @Carpetsmoker points out in his comment, <code>g:netrw_gx</code> determines what will be considered part of a URI.<... | 2015/03/31 | [
"https://vi.stackexchange.com/questions/2801",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/91/"
] | By default, if a buffer in vim contains a URL such as `http://www.google.com`, `g``x` in normal mode will open a browser with that URL. That's very handy. However, if the URL has URL parameters (e.g. `http://www.google.com/search?q=stuff`), then the URL parameters are missed out (i.e. just `http://www.google.com/search... | As @Carpetsmoker points out in his comment, `g:netrw_gx` determines what will be considered part of a URI.
By default it is set to `"<cfile>"`. From the docs (`:help <cfile>`):
`<cfile> is replaced with the path name under the cursor`
It escapes me, **why** parameter parts (i.e. `?`) of a URL are being disregarded a... |
2,806 | <p>I want to enable html snippets for php files. The Ultisnips manual said what I need to do is put <code>extends html</code> command at the beginning of the <code>php.snippets</code> file. But it doesn't work. HTML snippets still aren't showing up. How do I extend it properly?</p>
| [
{
"answer_id": 3433,
"author": "Martin Tournoij",
"author_id": 51,
"author_profile": "https://vi.stackexchange.com/users/51",
"pm_score": 2,
"selected": false,
"text": "<p>It's difficult to point out where your problem is, since you didn't really\ndescribe what <em>exactly</em> you did; ... | 2015/04/01 | [
"https://vi.stackexchange.com/questions/2806",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1526/"
] | I want to enable html snippets for php files. The Ultisnips manual said what I need to do is put `extends html` command at the beginning of the `php.snippets` file. But it doesn't work. HTML snippets still aren't showing up. How do I extend it properly? | It's difficult to point out where your problem is, since you didn't really
describe what *exactly* you did; but this is how I added a custom PHP snippet
file:
* I installed <http://github.com/SirVer/ultisnips> and <http://github.com/honza/vim-snippets>
* I created `~/.vim/UltiSnips/php.snippets` with the contents:
``... |
2,809 | <p>When I used <code>:silent</code> to run a terminal command in the background, my vim screen goes blank, until I navigate through my code, at which point each line I move to reappears. </p>
<p>What gives?</p>
| [
{
"answer_id": 2810,
"author": "Ingo Karkat",
"author_id": 970,
"author_profile": "https://vi.stackexchange.com/users/970",
"pm_score": 4,
"selected": true,
"text": "<p>This works as designed, and is documented under <code>:help :silent</code>:</p>\n\n<blockquote>\n<pre><code> \":si... | 2015/04/01 | [
"https://vi.stackexchange.com/questions/2809",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1596/"
] | When I used `:silent` to run a terminal command in the background, my vim screen goes blank, until I navigate through my code, at which point each line I move to reappears.
What gives? | This works as designed, and is documented under `:help :silent`:
>
>
> ```
> ":silent" will also avoid the hit-enter prompt. When
> using this for an external command, this may cause the
> screen to be messed up. Use |CTRL-L| to clean it up
> then.
>
> ```
>
>
You can also use the `:red... |
2,811 | <p>I often want a new empty vertical pane (vim window / viewport ...) in my current Vim tab.</p>
<p>I know I can get a new empty horizontal pane by doing <code>control+w n</code>.</p>
<p>I know I can split the current pane into two identical vertical copies with <code>control+w v</code>, but then I always resort to t... | [
{
"answer_id": 2812,
"author": "akshay",
"author_id": 246,
"author_profile": "https://vi.stackexchange.com/users/246",
"pm_score": 5,
"selected": true,
"text": "<p>From <a href=\"http://vimhelp.appspot.com/windows.txt.html#%3Avnew\" rel=\"nofollow noreferrer\"><code>:help vnew</code></a>... | 2015/04/02 | [
"https://vi.stackexchange.com/questions/2811",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/878/"
] | I often want a new empty vertical pane (vim window / viewport ...) in my current Vim tab.
I know I can get a new empty horizontal pane by doing `control+w n`.
I know I can split the current pane into two identical vertical copies with `control+w v`, but then I always resort to the awkward workaround of opening a new ... | From [`:help vnew`](http://vimhelp.appspot.com/windows.txt.html#%3Avnew):
```
Like |:new|, but split vertically. If 'equalalways' is set
and 'eadirection' isn't "ver" the windows will be spread out
horizontally, unless a width was specified.
```
However, it seems like Vim does not provide a mapping for ... |
2,816 | <p>When I open a new split Vim is scrolling both buffers up despite having enough space.</p>
<p>Here is an <a href="https://asciinema.org/a/18333" rel="nofollow noreferrer">asciicast</a></p>
<p>This behaviour comes out-of-the box in <code>vim -u NONE</code>.</p>
<p>It is really annoying. My guess it tries to keep the c... | [
{
"answer_id": 2913,
"author": "jecxjo",
"author_id": 895,
"author_profile": "https://vi.stackexchange.com/users/895",
"pm_score": 0,
"selected": false,
"text": "<p>If I understand your question correctly you are wishing that the split would\nautomatically move the cursor location to the... | 2015/04/03 | [
"https://vi.stackexchange.com/questions/2816",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/237/"
] | When I open a new split Vim is scrolling both buffers up despite having enough space.
Here is an [asciicast](https://asciinema.org/a/18333)
This behaviour comes out-of-the box in `vim -u NONE`.
It is really annoying. My guess it tries to keep the cursor in the middle of the screen or something. But even if the both ... | I found a [solution](https://stackoverflow.com/q/12897276/151007) which came from Vim's own help docs. It's not perfect but it is an improvement.
```
nnoremap <C-W>s Hmx`` \|:split<CR>`xzt``
``` |
2,817 | <p>I like formating code this way:</p>
<pre><code>class A
{
}
</code></pre>
<p>unlike another common way:</p>
<pre><code>class B {
}
</code></pre>
<p>The thing is, when using the <code>%</code> command to go to the enclosing bracket, which is very useful for copying/deleting loops/functions, it doesn't work so wel... | [
{
"answer_id": 2823,
"author": "Gonçalo Ribeiro",
"author_id": 356,
"author_profile": "https://vi.stackexchange.com/users/356",
"pm_score": 3,
"selected": false,
"text": "<p>I tried to figure if Vim had some option for this and I believe it doesn't. So I wrote a Vim script to do the job.... | 2015/04/03 | [
"https://vi.stackexchange.com/questions/2817",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/342/"
] | I like formating code this way:
```
class A
{
}
```
unlike another common way:
```
class B {
}
```
The thing is, when using the `%` command to go to the enclosing bracket, which is very useful for copying/deleting loops/functions, it doesn't work so well on the first case - it just doesn't work if my cursor is o... | I tried to figure if Vim had some option for this and I believe it doesn't. So I wrote a Vim script to do the job. Just add it to your `.vimrc`.
```
function Percent_nextline()
let line = getline('.')
if line =~ "{"
normal! %
else
let line = getline(line('.')+1)
if line =~ "{"
... |
2,824 | <p>I wrote this little function to update my plugins from within vim:</p>
<pre><code>function! UpdatePlugins()
call system('for f in ~/.vim/bundle/*; do cd $f; git pull; done')
endfunction
command! UpdatePlugins call UpdatePlugins()
</code></pre>
<p>How can I get the output of this to be piped into a new buffer in ... | [
{
"answer_id": 2825,
"author": "romainl",
"author_id": 54,
"author_profile": "https://vi.stackexchange.com/users/54",
"pm_score": 2,
"selected": false,
"text": "<p>You could simply do:</p>\n\n<pre><code>command! UpdatePlugins :!for f in ~/.vim/bundle/*; do cd $f; git pull; done<CR>... | 2015/04/03 | [
"https://vi.stackexchange.com/questions/2824",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/-1/"
] | I wrote this little function to update my plugins from within vim:
```
function! UpdatePlugins()
call system('for f in ~/.vim/bundle/*; do cd $f; git pull; done')
endfunction
command! UpdatePlugins call UpdatePlugins()
```
How can I get the output of this to be piped into a new buffer in real time? By real time, I... | You could simply do:
```
command! UpdatePlugins :!for f in ~/.vim/bundle/*; do cd $f; git pull; done<CR>
```
and see the output scroll in your shell. |
2,834 | <p>From time to time I see something like in the status bar when I open a file:</p>
<pre><code>"Gemfile" 112L, 2941C
"Gemfile" 112 lines --62%--
Press ENTER or type command to continue
</code></pre>
<p>Where is it coming from? How to disable it forever?</p>
<p>This is seriously getting out of hand, ... | [
{
"answer_id": 3047,
"author": "firedev",
"author_id": 237,
"author_profile": "https://vi.stackexchange.com/users/237",
"pm_score": 1,
"selected": false,
"text": "<p>So I kind of alleviated it by using</p>\n\n<pre><code>:set cmdheight=2\n</code></pre>\n\n<p>But that is weak sause and I d... | 2015/04/06 | [
"https://vi.stackexchange.com/questions/2834",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/237/"
] | From time to time I see something like in the status bar when I open a file:
```
"Gemfile" 112L, 2941C
"Gemfile" 112 lines --62%--
Press ENTER or type command to continue
```
Where is it coming from? How to disable it forever?
This is seriously getting out of hand, I am editing wrong lines in files because when I s... | This is controlled with the `shortmess` option. In particular, you probably want to set the `O` (upper-case o) flag with `set shortmess+=O`.
```
O message for reading a file overwrites any previous message.
Also for quickfix message (e.g., ":cn").
```
Note that this is included in the Vim default, which is... |
2,835 | <p>This could be a rare issue related to individual environment. But it's so annoying that can't help me asking for help. Please have a look at following captured photos which is fine before scrolling and wrong afterwards.</p>
<p>Although I use keyboard in most of time, which makes me blind on this issue. But when I u... | [
{
"answer_id": 2870,
"author": "Pak",
"author_id": 1115,
"author_profile": "https://vi.stackexchange.com/users/1115",
"pm_score": 2,
"selected": false,
"text": "<p>I have a feeling this is bug in Vim 7.4 since my Windows version does the same thing from time to time. The only solution I... | 2015/04/06 | [
"https://vi.stackexchange.com/questions/2835",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1632/"
] | This could be a rare issue related to individual environment. But it's so annoying that can't help me asking for help. Please have a look at following captured photos which is fine before scrolling and wrong afterwards.
Although I use keyboard in most of time, which makes me blind on this issue. But when I use a mouse... | I have a feeling this is bug in Vim 7.4 since my Windows version does the same thing from time to time. The only solution I've found so far is to scroll past the corruption so that it fixes itself or call `:redraw!` to force it to redraw the screen.
P.S. I was going to add this as a comment, but I don't have the requi... |
2,836 | <p>I'm asking about some sort of specialized diff highlighting mode. I need to diff, line by line, files A and B, which look similar to this in vimdiff:</p>
<pre><code>A B
repo/manipulate_1.0.1.out | package ../manipulate-1.0.1-x86_64-1.txz created.
repo/evaluate_0.5.5.out | package .... | [
{
"answer_id": 2870,
"author": "Pak",
"author_id": 1115,
"author_profile": "https://vi.stackexchange.com/users/1115",
"pm_score": 2,
"selected": false,
"text": "<p>I have a feeling this is bug in Vim 7.4 since my Windows version does the same thing from time to time. The only solution I... | 2015/04/06 | [
"https://vi.stackexchange.com/questions/2836",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1634/"
] | I'm asking about some sort of specialized diff highlighting mode. I need to diff, line by line, files A and B, which look similar to this in vimdiff:
```
A B
repo/manipulate_1.0.1.out | package ../manipulate-1.0.1-x86_64-1.txz created.
repo/evaluate_0.5.5.out | package ../evaluate-0.5... | I have a feeling this is bug in Vim 7.4 since my Windows version does the same thing from time to time. The only solution I've found so far is to scroll past the corruption so that it fixes itself or call `:redraw!` to force it to redraw the screen.
P.S. I was going to add this as a comment, but I don't have the requi... |
2,846 | <p>I'm currently writing a lot of plain text (and LaTeX with minimal formatting in paragraphs), and it would be nice if I could set up vim to keep each sentence (for simplicity, text terminated by a '. ', '! ', or '? '; that is a terminating punctuation followed by a space so as to avoid breaking on decimal numbers) o... | [
{
"answer_id": 2847,
"author": "Sukima",
"author_id": 544,
"author_profile": "https://vi.stackexchange.com/users/544",
"pm_score": 1,
"selected": false,
"text": "<p>Well you can setup up some maps and autocommands:</p>\n\n<pre><code>function! AddSentenceMaps()\n imap .<Space> .<... | 2015/04/08 | [
"https://vi.stackexchange.com/questions/2846",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1402/"
] | I'm currently writing a lot of plain text (and LaTeX with minimal formatting in paragraphs), and it would be nice if I could set up vim to keep each sentence (for simplicity, text terminated by a '. ', '! ', or '? '; that is a terminating punctuation followed by a space so as to avoid breaking on decimal numbers) on it... | The `'formatexpr'` option
-------------------------
You can achieve this using the [`'formatexpr'`](http://vimhelp.appspot.com/options.txt.html#%27formatexpr%27) option. From the help:
>
> Expression which is evaluated to format a range of lines for the gq operator or automatic formatting (see 'formatoptions'). When... |
2,849 | <p>I have gVim 7.4.608 installed on Windows 7 at work.</p>
<p>I've looked in <code>C:\</code> , <code>C:\Users\<username>\AppData</code> , <code>C:\Program Files\vim</code> , <code>C:\Temp</code> but there's no sign of it. It must exist somewhere, command history is working OK. I just want to read the file, I do... | [
{
"answer_id": 2851,
"author": "Tony LIU",
"author_id": 1653,
"author_profile": "https://vi.stackexchange.com/users/1653",
"pm_score": 4,
"selected": true,
"text": "<p>For Windows, the home directory is set in <code>%USERPROFILE%</code>. I believe vim will use this as <code>$HOME</code>.... | 2015/04/08 | [
"https://vi.stackexchange.com/questions/2849",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/398/"
] | I have gVim 7.4.608 installed on Windows 7 at work.
I've looked in `C:\` , `C:\Users\<username>\AppData` , `C:\Program Files\vim` , `C:\Temp` but there's no sign of it. It must exist somewhere, command history is working OK. I just want to read the file, I don't care where it actually is.
From `:help viminfo`
```
Th... | For Windows, the home directory is set in `%USERPROFILE%`. I believe vim will use this as `$HOME`.
In my case, the `_viminfo` is located in the `C:\Users\<username>`, which is the home directory, while the `%HOME%` is not set as well. |
2,850 | <p>I have a log file with lots of web service XML data (example follows). Ideally I would like to just go to a line and type <code>,x</code> to create pretty formatted XML for readability.</p>
<pre><code> Response XML: <ZZZZZ_EXBListLocalEftposRS xmlns="http://types.wise.zzzzz.com/2005/06"><PayLoad><Tim... | [
{
"answer_id": 2854,
"author": "Ingo Karkat",
"author_id": 970,
"author_profile": "https://vi.stackexchange.com/users/970",
"pm_score": 3,
"selected": true,
"text": "<p>You already have most of the pieces:</p>\n\n<pre><code>:199 :!C:\\apps\\xmllint.exe % --format\n</code></pre>\n\n<p>You... | 2015/04/08 | [
"https://vi.stackexchange.com/questions/2850",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/398/"
] | I have a log file with lots of web service XML data (example follows). Ideally I would like to just go to a line and type `,x` to create pretty formatted XML for readability.
```
Response XML: <ZZZZZ_EXBListLocalEftposRS xmlns="http://types.wise.zzzzz.com/2005/06"><PayLoad><TimeStamp>2015-04-07T10:25:18.797+12:00</Ti... | You already have most of the pieces:
```
:199 :!C:\apps\xmllint.exe % --format
```
You can use `:.` for the current line:
```
:.!C:\apps\xmllint.exe % --format
```
To get rid of the preamble before the XML, you can use `0dt<`. Inside a command-line, that's done with `:normal!`:
```
:execute 'normal! 0dt<' | .!C:... |
2,856 | <p>I have an XML file that must conform to a particular <a href="http://www.w3.org/XML/Schema" rel="nofollow">XML Schema</a>:</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<myroot
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="/home/nico/schemas/myroot.xsd">... | [
{
"answer_id": 2866,
"author": "jecxjo",
"author_id": 895,
"author_profile": "https://vi.stackexchange.com/users/895",
"pm_score": 2,
"selected": false,
"text": "<p>The <a href=\"https://github.com/scrooloose/syntastic\" rel=\"nofollow\">Syntastic</a> plugin currently contains support fo... | 2015/04/08 | [
"https://vi.stackexchange.com/questions/2856",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1083/"
] | I have an XML file that must conform to a particular [XML Schema](http://www.w3.org/XML/Schema):
```
<?xml version="1.0" encoding="UTF-8"?>
<myroot
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="/home/nico/schemas/myroot.xsd">
<blabla />
</myroot>
```
When I edit this XM... | The [Syntastic](https://github.com/scrooloose/syntastic) plugin currently contains support for xmllint from [xmlsoft](http://www.xmlsoft.org). If you know of another xml lint checker that verifies schema or dtd then it will be your easiest bet to create a Syntastic plugin for it. |
2,857 | <p>I need to configure Vim in such a way that it has a normal scrolloff of 3 or 5. But in such a way that it keeps the last line at the bottom of the screen. I don't want that as I scroll, the last lines of the buffer to come up to the top of the screen under any circumstance.
To make this more precise I want this:</p>... | [
{
"answer_id": 2865,
"author": "jecxjo",
"author_id": 895,
"author_profile": "https://vi.stackexchange.com/users/895",
"pm_score": 3,
"selected": true,
"text": "<p>If you try scrolling when you are at the bottom vim assumes you want to move the text up.</p>\n<p>You can replace commands l... | 2015/04/08 | [
"https://vi.stackexchange.com/questions/2857",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/155/"
] | I need to configure Vim in such a way that it has a normal scrolloff of 3 or 5. But in such a way that it keeps the last line at the bottom of the screen. I don't want that as I scroll, the last lines of the buffer to come up to the top of the screen under any circumstance.
To make this more precise I want this:
![ent... | If you try scrolling when you are at the bottom vim assumes you want to move the text up.
You can replace commands like `ctrl-f` with an additional "move cursor to bottom of screen" using `zb`. This modification would need to be added to any other commands you wish this to not occur.
`:nnoremap <c-f> <c-f>zb`
Now wh... |
2,858 | <p>I am trying to gather a toolbox of Vim commands/queries, in command or search mode, for navigating a code-base <em>without</em> using Ctags or other external tools. Ctags are great but support can vary depending on the development environment you are stuck on. I would like to just rely on Vim knowledge.</p>
| [
{
"answer_id": 2860,
"author": "Alexander Myshov",
"author_id": 500,
"author_profile": "https://vi.stackexchange.com/users/500",
"pm_score": 3,
"selected": false,
"text": "<p>There are a lot of ways for navigating through code (included in Vim and external), I still discover them. What I... | 2015/04/08 | [
"https://vi.stackexchange.com/questions/2858",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1661/"
] | I am trying to gather a toolbox of Vim commands/queries, in command or search mode, for navigating a code-base *without* using Ctags or other external tools. Ctags are great but support can vary depending on the development environment you are stuck on. I would like to just rely on Vim knowledge. | "Include search" is one such tool:
```
[I and ]I " search current buffer and included files for
" the word under the cursor, skipping comments
:ilist foo " same as above but for 'foo'
:ilist /foo " same as above but for a word containing 'foo'
```
Related to "include search", "definition s... |
2,863 | <p>I'm sure this will have been asked before, but I can't seem to find a solution.</p>
<p>I tend to open Vim from the root of my project, let's say:</p>
<p><code>~/dev/project/</code></p>
<p>Which looks something like:</p>
<pre><code>project/
| - app/
| | - scripts/
| | | - ...
| | - styles/
| | | - ...
| - i... | [
{
"answer_id": 2871,
"author": "jecxjo",
"author_id": 895,
"author_profile": "https://vi.stackexchange.com/users/895",
"pm_score": 0,
"selected": false,
"text": "<p>I would check your <code>:pwd</code>. I think you are probably not in the directory you think you are. CtrlP default search... | 2015/04/09 | [
"https://vi.stackexchange.com/questions/2863",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/124/"
] | I'm sure this will have been asked before, but I can't seem to find a solution.
I tend to open Vim from the root of my project, let's say:
`~/dev/project/`
Which looks something like:
```
project/
| - app/
| | - scripts/
| | | - ...
| | - styles/
| | | - ...
| - index.html
| - Gruntfile.js
| - README.md
```
... | If I'm not mistaken, you want to change g:ctrlp\_working\_path\_mode: <https://github.com/kien/ctrlp.vim/blob/master/doc/ctrlp.txt#L178>
```
let g:ctrlp_working_path_mode = '0'
``` |
2,867 | <p>Suppose you run the following piece of vimscript:</p>
<pre><code>let @z = system("date")
</code></pre>
<p>This will put a string version of the current date into the z register, but the string will end with a newline that I don’t want. Is there a built-in way (similar to Perl’s <a href="http://perldoc.perl.org/fun... | [
{
"answer_id": 2868,
"author": "Ingo Karkat",
"author_id": 970,
"author_profile": "https://vi.stackexchange.com/users/970",
"pm_score": 6,
"selected": true,
"text": "<p>You can use <code>substitute()</code>, or define a function:</p>\n\n<pre><code>function! Chomp(string)\n return subs... | 2015/04/09 | [
"https://vi.stackexchange.com/questions/2867",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/671/"
] | Suppose you run the following piece of vimscript:
```
let @z = system("date")
```
This will put a string version of the current date into the z register, but the string will end with a newline that I don’t want. Is there a built-in way (similar to Perl’s [`chomp`](http://perldoc.perl.org/functions/chomp.html)) to ge... | You can use `substitute()`, or define a function:
```
function! Chomp(string)
return substitute(a:string, '\n\+$', '', '')
endfunction
```
This variant will call `system` for you and then chomp the result:
```
function! ChompedSystem( ... )
return substitute(call('system', a:000), '\n\+$', '', '')
endfuncti... |
2,877 | <p>I'm just doing some testing with JavaScript language feature with no DOM manipulation. So I'm editing a js file and I'm wondering how to simply run it and show the console output? I installed the <a href="https://github.com/moll/vim-node" rel="noreferrer">moll/vim-node</a> plugin, but no idea how to run js code.</p>... | [
{
"answer_id": 2879,
"author": "jecxjo",
"author_id": 895,
"author_profile": "https://vi.stackexchange.com/users/895",
"pm_score": 4,
"selected": true,
"text": "<p>Per this <a href=\"http://vim.wikia.com/wiki/Display_output_of_shell_commands_in_new_window\" rel=\"noreferrer\">vim wikia</... | 2015/04/10 | [
"https://vi.stackexchange.com/questions/2877",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1276/"
] | I'm just doing some testing with JavaScript language feature with no DOM manipulation. So I'm editing a js file and I'm wondering how to simply run it and show the console output? I installed the [moll/vim-node](https://github.com/moll/vim-node) plugin, but no idea how to run js code. | Per this [vim wikia](http://vim.wikia.com/wiki/Display_output_of_shell_commands_in_new_window) entry you could create a shell execution to new buffer script and then extend it to run your code using node.
```
command! -complete=shellcmd -nargs=+ Shell call s:RunShellCommand(<q-args>)
function! s:RunShellCommand(cmdlin... |
2,878 | <p>Assuming the following situation</p>
<pre><code>$someVar = "Some String with \"escaped\" inner delimiters";
</code></pre>
<p>with the cursor somewhere in the double-quote delimited string.</p>
<p>What is the quickest way to jump to the final (actually delimiting) double quote? I can only think of <code>3f"</code>... | [
{
"answer_id": 2881,
"author": "Kent",
"author_id": 1569,
"author_profile": "https://vi.stackexchange.com/users/1569",
"pm_score": 1,
"selected": false,
"text": "<pre><code>$F\"\n</code></pre>\n\n<p>This goes to the end of the line, and searches backwards for <code>\"</code>.</p>\n"
},... | 2015/04/10 | [
"https://vi.stackexchange.com/questions/2878",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/79/"
] | Assuming the following situation
```
$someVar = "Some String with \"escaped\" inner delimiters";
```
with the cursor somewhere in the double-quote delimited string.
What is the quickest way to jump to the final (actually delimiting) double quote? I can only think of `3f"`/`f"` depending on where the cursor is, or e... | @Kent's solution assumes a single string in the line. Another approach is (mis-)using the *a / inner quoted string* text object (`a"` / `i"`), through visual mode:
* `va"<Esc>` for `:set selection=inclusive` (default)
* `vi"<Esc>` for `:set selection=exclusive`
@Kent's solution also doesn't work as a single, atomic `... |
2,883 | <p>I have some concealed characters in the buffer and horizontal scrolling kills the alignment big time.</p>
<p>Is there any way how to disable it? I could not find any relevant options.</p>
<p><img src="https://i.stack.imgur.com/KRQBA.gif" alt="bad horizontal scrolling demo"></p>
<p>Edit: Demo added. You can see vi... | [
{
"answer_id": 19552,
"author": "padawin",
"author_id": 21621,
"author_profile": "https://vi.stackexchange.com/users/21621",
"pm_score": 0,
"selected": false,
"text": "<p>If you have a way to edit the file, you might want to wrap the colors setup with <code>\\[</code> and <code>\\]</code... | 2015/04/10 | [
"https://vi.stackexchange.com/questions/2883",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1687/"
] | I have some concealed characters in the buffer and horizontal scrolling kills the alignment big time.
Is there any way how to disable it? I could not find any relevant options.

Edit: Demo added. You can see vim bases the scrolling offset on the un... | How to disable horizontal scrolling
-----------------------------------
I've written a solution that disables horizontal scrolling, (by riffing off of [@ЯрославРахматуллин's suggestion](https://vi.stackexchange.com/questions/2883/how-to-disable-horizontal-scrolling#comment23488_2883)), but I don't think you're going t... |
2,904 | <p>One thing I often do (but rely on the command line to do) is searching/grepping in multiple files.</p>
<p><strong>Is there a way to display search results for all the open buffers?</strong></p>
<p>Ideally, I'd like to have a new split buffer containing result location and snippet much like <code>grep</code> does. ... | [
{
"answer_id": 2905,
"author": "jecxjo",
"author_id": 895,
"author_profile": "https://vi.stackexchange.com/users/895",
"pm_score": 6,
"selected": true,
"text": "<p>You can use <code>:vimgrep /pattern/ {files}</code> to populate the quickfix list with matching patterns. The problem is tha... | 2015/04/13 | [
"https://vi.stackexchange.com/questions/2904",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/475/"
] | One thing I often do (but rely on the command line to do) is searching/grepping in multiple files.
**Is there a way to display search results for all the open buffers?**
Ideally, I'd like to have a new split buffer containing result location and snippet much like `grep` does. For example (`/statistics`):
```
models/... | You can use `:vimgrep /pattern/ {files}` to populate the quickfix list with matching patterns. The problem is that `:vimgrep` files option doesn't directly allow for buffers. You can use:
```
% Is replaced with the current file name. *:_%* *c_%*
# Is replaced with the alternate file name. *:_#* *c_#*
#n ... |
2,906 | <p>Vim has some fancy pants indentation stuff. When it works right it's a pleasure to have, but sometimes it just drives me nuts. One that I've never been able to solve has to do with LaTeX syntax.</p>
<p>Lets say you have this file:</p>
<pre><code>This is a test paragraph. Most of it is innocuous, but the \textit{in... | [
{
"answer_id": 2911,
"author": "Drew",
"author_id": 1688,
"author_profile": "https://vi.stackexchange.com/users/1688",
"pm_score": 2,
"selected": false,
"text": "<p>The indentation rules for LaTeX are defined in <code>$VIMRUNTIME/indent/tex.vim</code>. There are a few configurable varia... | 2015/04/13 | [
"https://vi.stackexchange.com/questions/2906",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/267/"
] | Vim has some fancy pants indentation stuff. When it works right it's a pleasure to have, but sometimes it just drives me nuts. One that I've never been able to solve has to do with LaTeX syntax.
Lets say you have this file:
```
This is a test paragraph. Most of it is innocuous, but the \textit{inline markup code happ... | The documentation for the indentation plugin for LaTeX is unfortunately not available in the help files, but it is written in the source code in `$VIMRUNTIME/indent/tex.vim`. The following variables are available for customization:
`g:tex_indent_brace`: Toggle smartindent-like style for `{}` and `[]`.
`g:tex_indent_i... |
2,912 | <p>Is there a way to increase/decrease first digit after/under cursor, not the whole number.</p>
<p>I know it's not how vim works, but is there a plugin that does that? I was unable to find it.</p>
<p>It is very useful when editing css and in other cases too.</p>
<p>Given:</p>
<pre><code>▐margin: 10px
</code></pre>... | [
{
"answer_id": 2914,
"author": "jecxjo",
"author_id": 895,
"author_profile": "https://vi.stackexchange.com/users/895",
"pm_score": 3,
"selected": false,
"text": "<h2>Basic increment</h2>\n\n<p>Here is a simple macro to perform the action:</p>\n\n<pre><code>:nnoremap <leader>a m`lv$... | 2015/04/14 | [
"https://vi.stackexchange.com/questions/2912",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/237/"
] | Is there a way to increase/decrease first digit after/under cursor, not the whole number.
I know it's not how vim works, but is there a plugin that does that? I was unable to find it.
It is very useful when editing css and in other cases too.
Given:
```
▐margin: 10px
```
When I press `CTRL-A` I want to see:
```
... | This seems to work quite well, and does fairly sane things when using `<C-a>` on
a 9 (95 becomes 105), or using `<C-x>` on a 0 (105 becomes 95):
```
nnoremap g<C-a> :call search('\d', 'c')<CR>a <Esc>h<C-a>lxh
nnoremap g<C-x> :call search('\d', 'c')<CR>a <Esc>h<C-x>lxh
```
* First, we search for any digit, `search()`... |
2,920 | <p>I have already put the following setting in my <code>.vimrc</code> file: </p>
<pre><code>set history=1000
</code></pre>
<p>It's been there for a while, I work in vim on a daily basis, so there have been many commands executed by now. I know from vim help, that duplicates and mapped command-lines are not stored, an... | [
{
"answer_id": 2921,
"author": "Ingo Karkat",
"author_id": 970,
"author_profile": "https://vi.stackexchange.com/users/970",
"pm_score": 5,
"selected": true,
"text": "<p>A <code>:</code> value in your <code>'viminfo'</code> option may limit the number of persisted commands. See <a href=\"... | 2015/04/14 | [
"https://vi.stackexchange.com/questions/2920",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1055/"
] | I have already put the following setting in my `.vimrc` file:
```
set history=1000
```
It's been there for a while, I work in vim on a daily basis, so there have been many commands executed by now. I know from vim help, that duplicates and mapped command-lines are not stored, and it also says:
```
Use the 'history... | A `:` value in your `'viminfo'` option may limit the number of persisted commands. See [`:help viminfo-:`](https://vimhelp.appspot.com/options.txt.html#viminfo-%3A):
>
>
> ```
> : Maximum number of items in the command-line history to be
> saved. When not included, the value of 'history' is used.
>
> ```
>
> |
2,923 | <p>Is there a way to select a text block (e.g. a first word "TODO:") programmatically (with some commands or functions from a script)? Not simply highlight, like with a search, but visually select like with mouse? </p>
| [
{
"answer_id": 2924,
"author": "Matt Boehm",
"author_id": 680,
"author_profile": "https://vi.stackexchange.com/users/680",
"pm_score": 1,
"selected": false,
"text": "<p>Any sequence of key presses can be represented in vimscript with the <code>:normal</code> command. For instance, to vis... | 2015/04/14 | [
"https://vi.stackexchange.com/questions/2923",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1378/"
] | Is there a way to select a text block (e.g. a first word "TODO:") programmatically (with some commands or functions from a script)? Not simply highlight, like with a search, but visually select like with mouse? | If you are looking to visually select a search pattern you can do it using two commands. For example searching for "TODO...." lines:
```
/^TODO.*$/s
v//e
```
This will search your your pattern and then visually select to the end of it.
If you want to move this to a function and then be able to call it in a single a... |
2,926 | <p>Occasionally I absentmindedly type <code>:w</code> when I'm reading something. This causes the modification time of the file to change and sometimes causes my build system to unnecessarily rebuild a substantial chunk of a project.</p>
<p>Is there a way to set vim to simply not do anything if I try to write a file a... | [
{
"answer_id": 2927,
"author": "lcd047",
"author_id": 1577,
"author_profile": "https://vi.stackexchange.com/users/1577",
"pm_score": 4,
"selected": false,
"text": "<p>Not directly (that is, the behaviour of <code>:w</code> can't be changed), but you can learn to use <code>:up</code> inst... | 2015/04/14 | [
"https://vi.stackexchange.com/questions/2926",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/268/"
] | Occasionally I absentmindedly type `:w` when I'm reading something. This causes the modification time of the file to change and sometimes causes my build system to unnecessarily rebuild a substantial chunk of a project.
Is there a way to set vim to simply not do anything if I try to write a file and it hasn't been cha... | Extending @lcd047's answer you can use `cabbrev` to modify `w`
```
:cabbrev w <c-r>=(getcmdtype()==':' && getcmdpos()==1 ? 'up' : 'w')<CR>
```
When you type `:w` you will notice that it will be replaced with `:up` when you press return. |
2,928 | <p>I was playing around with the MiniBufExplorer plugin, and I thought it would be nice if the MBE window could stick to the bottom of my ViM screen, even if I specifically open a new window with e.g. <code>:bot split xyz</code>. If I can get that working, then as a bonus I can set laststatus=0 when the MBE window is ... | [
{
"answer_id": 2935,
"author": "Ingo Karkat",
"author_id": 970,
"author_profile": "https://vi.stackexchange.com/users/970",
"pm_score": 3,
"selected": true,
"text": "<p>Vim has no means to execute command in a non-active window, and the internal implementation also mostly depends on bein... | 2015/04/14 | [
"https://vi.stackexchange.com/questions/2928",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1688/"
] | I was playing around with the MiniBufExplorer plugin, and I thought it would be nice if the MBE window could stick to the bottom of my ViM screen, even if I specifically open a new window with e.g. `:bot split xyz`. If I can get that working, then as a bonus I can set laststatus=0 when the MBE window is active, because... | Vim has no means to execute command in a non-active window, and the internal implementation also mostly depends on being in the active one, so it would be hard to implement such. You actually have to briefly move to that window, and then back:
```
let currentWinNr = winnr()
execute targetWinNr . 'wincmd w'
try
exe... |
2,938 | <p>I use a tiling window manager (awesome) + a terminal multiplexer (tmux) + splits inside of vim. I have no window decorations at all, so there is no visual split between them at all if the content of the program doesn't give it away. I'm quite comfortable with this paradigm as I use multiple monitors and group tasks ... | [
{
"answer_id": 2940,
"author": "Ingo Karkat",
"author_id": 970,
"author_profile": "https://vi.stackexchange.com/users/970",
"pm_score": 3,
"selected": false,
"text": "<p>No, this cannot be done in Vim, and would probably be very hard to implement in GVIM.</p>\n\n<p>Vim sticks to the cell... | 2015/04/15 | [
"https://vi.stackexchange.com/questions/2938",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/267/"
] | I use a tiling window manager (awesome) + a terminal multiplexer (tmux) + splits inside of vim. I have no window decorations at all, so there is no visual split between them at all if the content of the program doesn't give it away. I'm quite comfortable with this paradigm as I use multiple monitors and group tasks by ... | You are wrong about tmux. Like every terminal-based program — including Vim — it only draws stuff *inside* cells. This means that Vim and tmux both use the same method to draw vertical borders: they just use a pipe-like character.
Tmux uses `│` (`U+2502`) by default while Vim uses `|` (`U+007C`).
If you want the same... |
2,950 | <p>In Vim, when I run this command <code>:!bash -c "ll"</code>, I get this error message <code>bash: ll: command not found</code>. <code>ll</code> is an alias in my ~/.bashrc file. If I just enter <code>ll</code> from bash it works. I created a ~/.bash_profile file and added the following to it: </p>
<pre><code>if [ -... | [
{
"answer_id": 2951,
"author": "jecxjo",
"author_id": 895,
"author_profile": "https://vi.stackexchange.com/users/895",
"pm_score": 4,
"selected": false,
"text": "<p>Your issue is with bash and not with vim. The problem is that when you run <code>!<cmd></code> in vim or <code>/bin/b... | 2015/04/15 | [
"https://vi.stackexchange.com/questions/2950",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1410/"
] | In Vim, when I run this command `:!bash -c "ll"`, I get this error message `bash: ll: command not found`. `ll` is an alias in my ~/.bashrc file. If I just enter `ll` from bash it works. I created a ~/.bash\_profile file and added the following to it:
```
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
```
I looked... | Your issue is with bash and not with vim. The problem is that when you run `!<cmd>` in vim or `/bin/bash -c <cmd>` from another shell you are launching an instance of bash in non-interactive mode. In non-interactive mode alias are not expanded and you get this error. I don't know if you'd be able to enable the shell op... |
2,961 | <p>The Mac latex editor 'TeXShop' has a great feature -- I can right-click anywhere in my tex and it shows me the corresponding character of the generated PDF. Similarly I can click on PDF and jump to that character in the tex source code.</p>
<p>Is it possible to do the same thing in vim, and some PDF viewer? (I'm in... | [
{
"answer_id": 2962,
"author": "jecxjo",
"author_id": 895,
"author_profile": "https://vi.stackexchange.com/users/895",
"pm_score": 2,
"selected": false,
"text": "<p>For the first situation (tex selection to PDF) if you have a tex compiler that allows for input from stdin you could echo y... | 2015/04/16 | [
"https://vi.stackexchange.com/questions/2961",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/92/"
] | The Mac latex editor 'TeXShop' has a great feature -- I can right-click anywhere in my tex and it shows me the corresponding character of the generated PDF. Similarly I can click on PDF and jump to that character in the tex source code.
Is it possible to do the same thing in vim, and some PDF viewer? (I'm interested o... | For the first situation (tex selection to PDF) if you have a tex compiler that allows for input from stdin you could echo your visual selection.
```
function! EchoPipeCmd(cmd) range
echo system('echo ' . shellescape(join(getline(a:firstline, a:lastline), "\n")) . ' | ' . a:cmd)
endfunction
command! -range=% -nargs=... |
2,969 | <p>Given:</p>
<pre><code>$ cd ~/Sites/project
project $ vim
:NERDTreeFind
</code></pre>
<p>I would like to see NERDTree opening with <code>~/Sites/project</code> as a root folder. </p>
<p>Instead I see <code>~/Sites</code> with <code>project</code> folder selected. So I have to <code>cd</code> to the work folder eac... | [
{
"answer_id": 2987,
"author": "Peter Rincker",
"author_id": 778,
"author_profile": "https://vi.stackexchange.com/users/778",
"pm_score": 2,
"selected": false,
"text": "<p>From the documention it would seem that it should be using your <code>~/Sites/project</code> directory. (See <code>:... | 2015/04/17 | [
"https://vi.stackexchange.com/questions/2969",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/237/"
] | Given:
```
$ cd ~/Sites/project
project $ vim
:NERDTreeFind
```
I would like to see NERDTree opening with `~/Sites/project` as a root folder.
Instead I see `~/Sites` with `project` folder selected. So I have to `cd` to the work folder each time.
I am sure there should be a setting for that but I can't find it. He... | From the documention it would seem that it should be using your `~/Sites/project` directory. (See `:h :NERDTree`)
```
:NERDTree [<start-directory> | <bookmark>] *:NERDTree*
Opens a fresh NERD tree. The root of the tree depends on the argument
given. There are 3 cases: If no argument is ... |
2,975 | <p>I've opened the files I want to diff using the following command:</p>
<pre><code>C:\temp\robocopyTasks>vim -c "edit ++enc=ucs-2le" -d C:\temp\robocopyTasks\acl\tasks_temp.txt C:\temp\robocopyTasks\acl\tasks_win.txt
</code></pre>
<p>But the file encoding is only set on the first file that is opened, and not on t... | [
{
"answer_id": 2976,
"author": "Ingo Karkat",
"author_id": 970,
"author_profile": "https://vi.stackexchange.com/users/970",
"pm_score": 3,
"selected": true,
"text": "<p>The <code>edit ++enc=ucs-2le [filename]</code> only applies to the current file; when multiple are passed on the comman... | 2015/04/17 | [
"https://vi.stackexchange.com/questions/2975",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1065/"
] | I've opened the files I want to diff using the following command:
```
C:\temp\robocopyTasks>vim -c "edit ++enc=ucs-2le" -d C:\temp\robocopyTasks\acl\tasks_temp.txt C:\temp\robocopyTasks\acl\tasks_win.txt
```
But the file encoding is only set on the first file that is opened, and not on the second one; is there any w... | The `edit ++enc=ucs-2le [filename]` only applies to the current file; when multiple are passed on the command-line, that's the last opened one. You could open the other with `:diffsplit ++enc=ucs-2le file2`, but in this case, it's shorter to augment the `'fileencodings'` option:
```
vim --cmd "set fileencodings^=ucs-2... |
2,981 | <p>I can find an answer to a similar problem <a href="https://stackoverflow.com/a/3338480/3130747">here</a>, however although I can get that example to function I can't get what I want to do to work.</p>
<p>Here is the example text to be edited, a partial section of this site <a href="http://latexcolor.com/" rel="nofol... | [
{
"answer_id": 2982,
"author": "jecxjo",
"author_id": 895,
"author_profile": "https://vi.stackexchange.com/users/895",
"pm_score": 3,
"selected": false,
"text": "<p>To run a macro on every line you use <code>:{range}normal! <macro></code></p>\n\n<p>So for instance if you recorded a... | 2015/04/17 | [
"https://vi.stackexchange.com/questions/2981",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1443/"
] | I can find an answer to a similar problem [here](https://stackoverflow.com/a/3338480/3130747), however although I can get that example to function I can't get what I want to do to work.
Here is the example text to be edited, a partial section of this site <http://latexcolor.com/>:
```
Anti-flash white #F2F3F4 \def... | To run a macro on every line you use `:{range}normal! <macro>`
So for instance if you recorded a macro into `q` and visually selected the additional lines to apply the macro to, you'd type
```
:'<,'>normal! @q
```
This issue you are seeing is because running a macro in parallel assumes that all lines will stay in p... |
2,983 | <p>Let's say I have a line like this:</p>
<pre><code>a = x(y(z));
</code></pre>
<p>And I want to change it to:</p>
<pre><code>a = y(z);
</code></pre>
<p>What's the most efficient way to do this?</p>
| [
{
"answer_id": 2985,
"author": "jecxjo",
"author_id": 895,
"author_profile": "https://vi.stackexchange.com/users/895",
"pm_score": 3,
"selected": true,
"text": "<p>If you start with your cursor on the <code>x</code> type</p>\n\n<p><code>%x``2x</code></p>\n\n<ul>\n<li><code>%</code> move ... | 2015/04/17 | [
"https://vi.stackexchange.com/questions/2983",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/40/"
] | Let's say I have a line like this:
```
a = x(y(z));
```
And I want to change it to:
```
a = y(z);
```
What's the most efficient way to do this? | If you start with your cursor on the `x` type
`%x``2x`
* `%` move to the corresponding parenthesis to the one closest to you, i.e. `)`
* `x` delete it
* ```` jump back to your previous jump, the starting `x`
* `2x` delete the next two characters, `x(`
If you want this to be more robust you can do a find next and del... |
2,988 | <p>The command <code>:%s/foo/bar/gc</code> is to replace all "foo" by "bar" in the global field with confirmation. There are many "foo"s in my file within first 50 lines not to be changed. How can make this command effective only for lines 51 to last line?</p>
<p>Thanks!</p>
| [
{
"answer_id": 2989,
"author": "jecxjo",
"author_id": 895,
"author_profile": "https://vi.stackexchange.com/users/895",
"pm_score": 4,
"selected": true,
"text": "<p>The find and replace command has a range option. In this case you are performing this action against the entire document <co... | 2015/04/17 | [
"https://vi.stackexchange.com/questions/2988",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1080/"
] | The command `:%s/foo/bar/gc` is to replace all "foo" by "bar" in the global field with confirmation. There are many "foo"s in my file within first 50 lines not to be changed. How can make this command effective only for lines 51 to last line?
Thanks! | The find and replace command has a range option. In this case you are performing this action against the entire document `%`. You can also select a more specific range. So lets say you want to swap lines 51 through 57
```
:51,57s/foo/bar/gc
```
If you want to go to end of the document use `$`
```
:51,$s/foo/bar/gc
... |
3,001 | <p>When entering or doing any command mode modifications to a read only file for the first time you will get the warning</p>
<pre><code>W10: Warning: Changing a readonly file
</code></pre>
<p>That's fine, but this also introduces a second or two delay before the action actually <em>happens</em>.</p>
<p>Is there a wa... | [
{
"answer_id": 3080,
"author": "Martin Tournoij",
"author_id": 51,
"author_profile": "https://vi.stackexchange.com/users/51",
"pm_score": 3,
"selected": true,
"text": "<p>Short version: there is no way to disable this, or to shorten the 1 second timeout :-( The good news is that you can... | 2015/04/19 | [
"https://vi.stackexchange.com/questions/3001",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1787/"
] | When entering or doing any command mode modifications to a read only file for the first time you will get the warning
```
W10: Warning: Changing a readonly file
```
That's fine, but this also introduces a second or two delay before the action actually *happens*.
Is there a way to disable this delay? | Short version: there is no way to disable this, or to shorten the 1 second timeout :-( The good news is that you can just start typing while this message is being displayed, the characters are still inserted.
---
Longer version: from `misc1.c`:
```
if (msg_silent == 0 && !silent_mode)
{
out_flush();
... |
3,006 | <p>How can I move the cursor to the <i>n</i><sup>th</sup> byte in the buffer?</p>
<p>How can I display the current cursor position in the ruler in terms of the byte offset, rather than lines and columns? (Follow-up question: can it be displayed in both decimal and hexadecimal?)</p>
| [
{
"answer_id": 3007,
"author": "romainl",
"author_id": 54,
"author_profile": "https://vi.stackexchange.com/users/54",
"pm_score": 6,
"selected": true,
"text": "<pre><code>:goto 2356\n</code></pre>\n\n<p>jumps to the 2356th byte in the buffer.</p>\n\n<p>Use the <code>%o</code> field in <c... | 2015/04/19 | [
"https://vi.stackexchange.com/questions/3006",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/24/"
] | How can I move the cursor to the *n*th byte in the buffer?
How can I display the current cursor position in the ruler in terms of the byte offset, rather than lines and columns? (Follow-up question: can it be displayed in both decimal and hexadecimal?) | ```
:goto 2356
```
jumps to the 2356th byte in the buffer.
Use the `%o` field in `'statusline'` or `'rulerformat'` to display the byte number of the character under your cursor.
Use `%O` to display the value in hexadecimal format.
Reference:
```
:help :goto
:help 'statusline'
:help 'rulerformat'
``` |
3,013 | <p>Let say I have</p>
<pre><code>let l:letter = 'A'
</code></pre>
<p>is there a function that takes <code>l:letter</code> ascii code and transforms it to <code>'B'</code>? I mean something like</p>
<pre><code>let l:next_letter = l:letter + 1
</code></pre>
<p>I know there's <code><Ctrl-A></code> with <code>set... | [
{
"answer_id": 3014,
"author": "Luc Hermitte",
"author_id": 626,
"author_profile": "https://vi.stackexchange.com/users/626",
"pm_score": 5,
"selected": true,
"text": "<p>It's easy to do with <a href=\"http://vimhelp.appspot.com/eval.txt.html#nr2char%28%29\"><code>:help nr2char()</code></... | 2015/04/19 | [
"https://vi.stackexchange.com/questions/3013",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1690/"
] | Let say I have
```
let l:letter = 'A'
```
is there a function that takes `l:letter` ascii code and transforms it to `'B'`? I mean something like
```
let l:next_letter = l:letter + 1
```
I know there's `<Ctrl-A>` with `set nf=alpha`, but that requires to have the cursor over the character in the document and I was... | It's easy to do with [`:help nr2char()`](http://vimhelp.appspot.com/eval.txt.html#nr2char%28%29) and [`:help char2nr()`](http://vimhelp.appspot.com/eval.txt.html#char2nr%28%29).
Example usage:
`:let b_char = nr2char(char2nr('A') + 1)`
Then, `:echo b_char` will return 'B' |
3,016 | <p>Using <code>:buffers</code> results</p>
<pre><code>:buffers
1 %a "my-jspage.md" line 11
</code></pre>
<p>Are there any options so <code>:buffers</code> will list full path and filename? E.g.:</p>
<pre><code>:buffers
1 %a "d:\projects\self-org\my-jspage.md" line 11
</code></... | [
{
"answer_id": 3017,
"author": "lcd047",
"author_id": 1577,
"author_profile": "https://vi.stackexchange.com/users/1577",
"pm_score": 3,
"selected": false,
"text": "<blockquote>\n <p>Are there any options so <code>:buffers</code> will list full path and filename?</p>\n</blockquote>\n\n<p... | 2015/04/20 | [
"https://vi.stackexchange.com/questions/3016",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1373/"
] | Using `:buffers` results
```
:buffers
1 %a "my-jspage.md" line 11
```
Are there any options so `:buffers` will list full path and filename? E.g.:
```
:buffers
1 %a "d:\projects\self-org\my-jspage.md" line 11
```
I'm on windows Vim 7.4-656. I'm aware of `:ls` :) | Vim reduces the filespec of the open buffers to a shorter, relative representation. (That's a feature, not a bug.) You can work around that behavior by switching the current working directory (temporarily) to the file system root / (on Windows:) to a drive not currently used:
```
:cd C:/ | buffers | cd -
``` |
3,025 | <p>How do I search in multiple files for 1st line of file matching a pattern?</p>
<p>e.g. I want to search for files starting with <code>++</code></p>
<pre><code>++ Heading 1
</code></pre>
<p>and not</p>
<pre><code>+ Heading 1
++ Heading 2
</code></pre>
<p>Any pointers appreciated.</p>
| [
{
"answer_id": 3026,
"author": "PhilippFrank",
"author_id": 1296,
"author_profile": "https://vi.stackexchange.com/users/1296",
"pm_score": 0,
"selected": false,
"text": "<p>For doing something to multiple files, <code>:argdo</code> is your friend. You might need to edit the argument list... | 2015/04/22 | [
"https://vi.stackexchange.com/questions/3025",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1820/"
] | How do I search in multiple files for 1st line of file matching a pattern?
e.g. I want to search for files starting with `++`
```
++ Heading 1
```
and not
```
+ Heading 1
++ Heading 2
```
Any pointers appreciated. | Use `:vimgrep` as below:
```
:vimgrep /\%(\%<2l\)foo/ *.*
```
This will search for `foo` in all files in the current folders (`*.*`) only in the 1st line (`<2l`).
Alternatively may search either in the current file (`%`), certain files (`*.c`) or recursively (`**/*.*`, see: `:help starstar-wildcard`). See: `:help :... |
3,031 | <p>I have vim save my undo history in files named something like <code>.filename.js.un~</code>, but I don't want this cluttering up my list of file in vim (in Netrw).</p>
<p>Is there a way to exclude all files with a certain file extension in Netrw?</p>
| [
{
"answer_id": 3026,
"author": "PhilippFrank",
"author_id": 1296,
"author_profile": "https://vi.stackexchange.com/users/1296",
"pm_score": 0,
"selected": false,
"text": "<p>For doing something to multiple files, <code>:argdo</code> is your friend. You might need to edit the argument list... | 2015/04/22 | [
"https://vi.stackexchange.com/questions/3031",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/226/"
] | I have vim save my undo history in files named something like `.filename.js.un~`, but I don't want this cluttering up my list of file in vim (in Netrw).
Is there a way to exclude all files with a certain file extension in Netrw? | Use `:vimgrep` as below:
```
:vimgrep /\%(\%<2l\)foo/ *.*
```
This will search for `foo` in all files in the current folders (`*.*`) only in the 1st line (`<2l`).
Alternatively may search either in the current file (`%`), certain files (`*.c`) or recursively (`**/*.*`, see: `:help starstar-wildcard`). See: `:help :... |
3,033 | <p>Occasionally, when writing shell scripts and such, I have entries of the form:</p>
<pre><code>foo=/bar/baz
</code></pre>
<p>To get filename completion (<code><C-x> <C-f></code>) to work, I have to put a space after the <code>=</code>, and then remove it after completion. I don't have any filenames whic... | [
{
"answer_id": 3034,
"author": "muru",
"author_id": 205,
"author_profile": "https://vi.stackexchange.com/users/205",
"pm_score": 5,
"selected": true,
"text": "<p>The list of valid filename characters is given by the <code>isfname</code> variable. From <a href=\"http://vimhelp.appspot.com... | 2015/04/22 | [
"https://vi.stackexchange.com/questions/3033",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/205/"
] | Occasionally, when writing shell scripts and such, I have entries of the form:
```
foo=/bar/baz
```
To get filename completion (`<C-x> <C-f>`) to work, I have to put a space after the `=`, and then remove it after completion. I don't have any filenames which contain `=`, so I don't care about it being part of the co... | The list of valid filename characters is given by the `isfname` variable. From [`:he 'isfname'`](http://vimhelp.appspot.com/options.txt.html#%27isfname%27):
```
'isfname' 'isf' string (default for MS-DOS, Win32 and OS/2:
"@,48-57,/,\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,="
... |
3,036 | <p>I have encountered many situations in vim where it would be useful to have lookaround statements. I have tried using the standard lookaround syntax <em>(<code>(?=)</code>, <code>(?!)</code> etc ..)</em>, but it appears vim does not support this. Does vim have an equivalent syntax for these kinds of statements?</p>... | [
{
"answer_id": 3037,
"author": "jecxjo",
"author_id": 895,
"author_profile": "https://vi.stackexchange.com/users/895",
"pm_score": 4,
"selected": false,
"text": "<p>It looks as if this is possible. There is a simple table to go from perl to vim. <code>:h perl-patterns</code></p>\n\n<pre>... | 2015/04/22 | [
"https://vi.stackexchange.com/questions/3036",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/865/"
] | I have encountered many situations in vim where it would be useful to have lookaround statements. I have tried using the standard lookaround syntax *(`(?=)`, `(?!)` etc ..)*, but it appears vim does not support this. Does vim have an equivalent syntax for these kinds of statements? | "Zoom" anchors
==============
In addition to @jecxjo's answer, there are many situations where you can use the zero-width anchors `\zs` and `\ze` instead of positive lookaround. These anchors define the start (`\zs`) and the end (`\ze`) of the match within the full pattern.
Examples
--------
* `foo\zsbar` will match... |
3,055 | <p>A lot of times I'm in a situation similar to this:</p>
<pre><code>1. <Line 1>
2. <Line 2>
3. <Line 3>
4. <Cursor is here>
5. <I want to copy line 1 here>
</code></pre>
<p>An easy solution is <code>mm:1<CR>yy`mp</code> - that is, make a mark at line 4, go to line 1, copy it, go b... | [
{
"answer_id": 3056,
"author": "jecxjo",
"author_id": 895,
"author_profile": "https://vi.stackexchange.com/users/895",
"pm_score": 4,
"selected": false,
"text": "<p>You could shorten it by not using marks and yank the line directly.</p>\n\n<pre><code>:1y<CR>p\n</code></pre>\n\n<p>C... | 2015/04/24 | [
"https://vi.stackexchange.com/questions/3055",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/40/"
] | A lot of times I'm in a situation similar to this:
```
1. <Line 1>
2. <Line 2>
3. <Line 3>
4. <Cursor is here>
5. <I want to copy line 1 here>
```
An easy solution is `mm:1<CR>yy`mp` - that is, make a mark at line 4, go to line 1, copy it, go back to the mark, and paste.
Is there a shorter/more fluid solution to t... | Looks like a case for ex copy (`:help :co` or `:help :t`):
```
:1t4
```
or, using your cursor's position:
```
:1t.
```
This does not copy the line to the yank register, which might or might not be what you want. |
3,060 | <p>I have an autocommand defined in my vimrc:</p>
<pre><code>au BufWritePost * !./make.sh
</code></pre>
<p>The script <code>make.sh</code> compiles a <code>.tex</code> file 3 times and I don't want the output to be displayed.</p>
<p>Is there a way to suppress the output? </p>
<p>I tried to add <code>silent</code> o... | [
{
"answer_id": 3062,
"author": "EvergreenTree",
"author_id": 865,
"author_profile": "https://vi.stackexchange.com/users/865",
"pm_score": 6,
"selected": true,
"text": "<p>Silent should go before <code>!./make.sh</code>, not before <code>au</code>. Putting <code>silent</code> before <cod... | 2015/04/24 | [
"https://vi.stackexchange.com/questions/3060",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1837/"
] | I have an autocommand defined in my vimrc:
```
au BufWritePost * !./make.sh
```
The script `make.sh` compiles a `.tex` file 3 times and I don't want the output to be displayed.
Is there a way to suppress the output?
I tried to add `silent` one line before the `au` command, but it didn't work. I also tried [this w... | Silent should go before `!./make.sh`, not before `au`. Putting `silent` before `au` just means it will register the autocommand silently. It should look like this instead:
```
au BufWritePost * silent! !./make.sh
```
One issue with running an external command like this with the `:silent` command is that the screen d... |
3,068 | <p>I want to keep my Vim spelling synchronised across machines. For that reason I put my spelling file
into Dropbox by adding <code>set spellfile=$HOME/Dropbox/vim/spell/en.utf-8.add</code> to my <em>.vimrc</em>. It
worked just fine for a single language.</p>
<p>When I've added another spelling file for Ukrainian by c... | [
{
"answer_id": 3075,
"author": "Ingo Karkat",
"author_id": 970,
"author_profile": "https://vi.stackexchange.com/users/970",
"pm_score": 2,
"selected": false,
"text": "<p>If you have multiple entries in <code>'spellfile'</code>, you have to supply a <code>[count]</code> to commands like <... | 2015/04/25 | [
"https://vi.stackexchange.com/questions/3068",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/418/"
] | I want to keep my Vim spelling synchronised across machines. For that reason I put my spelling file
into Dropbox by adding `set spellfile=$HOME/Dropbox/vim/spell/en.utf-8.add` to my *.vimrc*. It
worked just fine for a single language.
When I've added another spelling file for Ukrainian by changing `'spellfile'` value ... | You can [symlink](http://en.wikipedia.org/wiki/Symlink) `~/.vim/spell` to `~/Dropbox/vim/spell`:
```
$ rmdir ~/.vim/spell
$ ln -s ~/Dropbox/vim/spell ~/.vim/spell
```
This will work on UNIX-like systems (Linux, BSD, OSX), for Windows, you can use:
```
$ mklink /D "$HOME\Dropbox\vim\spell" "$HOME\_vim\spell"
``` |
3,072 | <p>I dislike to have to reach up to the <code>Escape</code> key all the time. For a while I used the program <code>xcape</code> under Linux to map <code>Caps lock</code> to be both <code>Control</code> and <code>Escape</code>. However, I am currently working more and more on a Mac so I can’t have the same keybinding wi... | [
{
"answer_id": 3073,
"author": "Dhruva Sagar",
"author_id": 74,
"author_profile": "https://vi.stackexchange.com/users/74",
"pm_score": 3,
"selected": false,
"text": "<pre><code>nnoremap <C-Space> i\ninoremap <C-Space> <Esc>\n</code></pre>\n"
},
{
"answer_id": 30... | 2015/04/25 | [
"https://vi.stackexchange.com/questions/3072",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1869/"
] | I dislike to have to reach up to the `Escape` key all the time. For a while I used the program `xcape` under Linux to map `Caps lock` to be both `Control` and `Escape`. However, I am currently working more and more on a Mac so I can’t have the same keybinding without much increased effort.
I thought that the key comb... | I found this map works for `Ctrl`-`Space` :
```
:nnoremap <C-@> i
:inoremap <C-@> <Esc>
``` |
3,086 | <p>I have encountered some situations where I need to check if a value matches a regex in a list of regexes. For instance, say I have a list of regexes which match filetypes:</p>
<pre><code>['gundo', 'nerdtree', 'git*']
</code></pre>
<p>I need to find out if the filetype of the current file matches any of these rege... | [
{
"answer_id": 3073,
"author": "Dhruva Sagar",
"author_id": 74,
"author_profile": "https://vi.stackexchange.com/users/74",
"pm_score": 3,
"selected": false,
"text": "<pre><code>nnoremap <C-Space> i\ninoremap <C-Space> <Esc>\n</code></pre>\n"
},
{
"answer_id": 30... | 2015/04/26 | [
"https://vi.stackexchange.com/questions/3086",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/865/"
] | I have encountered some situations where I need to check if a value matches a regex in a list of regexes. For instance, say I have a list of regexes which match filetypes:
```
['gundo', 'nerdtree', 'git*']
```
I need to find out if the filetype of the current file matches any of these regexes. The way I would do it ... | I found this map works for `Ctrl`-`Space` :
```
:nnoremap <C-@> i
:inoremap <C-@> <Esc>
``` |
3,089 | <p>I'm using (roughly) the same config for my mac and my ubuntu machine. I use</p>
<pre><code>set clipboard=unnamed,unnamedplus
</code></pre>
<p>To conveniently share vim's clipboard with the system clipboard. However, lately the clipboard sharing broke under Mac OS X.</p>
<p>I have no idea what I did to break it, i... | [
{
"answer_id": 3130,
"author": "tommcdo",
"author_id": 64,
"author_profile": "https://vi.stackexchange.com/users/64",
"pm_score": 3,
"selected": true,
"text": "<h2>MacVim</h2>\n\n<p>Under OS X, it's best to use <a href=\"https://macvim-dev.github.io/macvim/\" rel=\"nofollow noreferrer\">... | 2015/04/27 | [
"https://vi.stackexchange.com/questions/3089",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1842/"
] | I'm using (roughly) the same config for my mac and my ubuntu machine. I use
```
set clipboard=unnamed,unnamedplus
```
To conveniently share vim's clipboard with the system clipboard. However, lately the clipboard sharing broke under Mac OS X.
I have no idea what I did to break it, it still works fine under ubuntu. ... | MacVim
------
Under OS X, it's best to use [MacVim](https://macvim-dev.github.io/macvim/). OS X behaves differently to other operating systems when it comes to things like clipboard management. MacVim is specifically designed to address the areas where Vim falls short on the Mac.
### Coming to a terminal near you
Al... |
3,099 | <p>I have found some color schemes that I like, but some of them have the feature that the lines below the content of the file on the display - the <code>~</code> area - have a different background color as shown.. I want it to be the same background color as normal text. When editing the color scheme, what keyword am ... | [
{
"answer_id": 3100,
"author": "muru",
"author_id": 205,
"author_profile": "https://vi.stackexchange.com/users/205",
"pm_score": 2,
"selected": false,
"text": "<p>In terms of highlight groups, I believe it is called <code>NonText</code>. From <a href=\"http://vimhelp.appspot.com/syntax.t... | 2015/04/28 | [
"https://vi.stackexchange.com/questions/3099",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1882/"
] | I have found some color schemes that I like, but some of them have the feature that the lines below the content of the file on the display - the `~` area - have a different background color as shown.. I want it to be the same background color as normal text. When editing the color scheme, what keyword am I looking for ... | Since Vim 8 there is the `EndOfBuffer` highlight group for this; from [`:help hl-EndOfBuffer`](http://vimhelp.appspot.com/syntax.txt.html#hl%2dEndOfBuffer):
```
EndOfBuffer filler lines (~) after the last line in the buffer.
By default, this is highlighted like hl-NonText.
```
---
For earlier Vim versions i... |
3,109 | <p>I have a problem I can think of two general approaches for solving, but I don't know specifics for either approach.</p>
<pre><code>...
Level 1: cũng also
Level 1: và and
Level 1: như like; such as
Level 2: các plural marker
Level 2: của belonging to
...
</code></pre>
<p>For each ... | [
{
"answer_id": 3110,
"author": "jecxjo",
"author_id": 895,
"author_profile": "https://vi.stackexchange.com/users/895",
"pm_score": 2,
"selected": false,
"text": "<p>You could approach it by recording a macro. Starting with your original file, prepend the first instance with the number.</... | 2015/04/29 | [
"https://vi.stackexchange.com/questions/3109",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/878/"
] | I have a problem I can think of two general approaches for solving, but I don't know specifics for either approach.
```
...
Level 1: cũng also
Level 1: và and
Level 1: như like; such as
Level 2: các plural marker
Level 2: của belonging to
...
```
For each line starting "Level n" I ... | Similar to the answer at <https://vi.stackexchange.com/a/818/227>, you can use the global command.
With it you can instruct vim to search for lines matching a pattern, and then perform commands on it.
In your case, you wish to prepend text to lines starting with "Level N:", so our global command could be
```
:g/^Lev... |
3,115 | <p>I have a file with a bunch of user defaults in. I want to change some of the text, but I'm struggling coming up with a matcher and replacer. Using the following example:</p>
<pre><code>###############################################################################
# Trackpad, mouse, keyboard, Bluetooth accessories,... | [
{
"answer_id": 3116,
"author": "muru",
"author_id": 205,
"author_profile": "https://vi.stackexchange.com/users/205",
"pm_score": 3,
"selected": false,
"text": "<p>You can:</p>\n\n<ul>\n<li>search for lines that don't end in <code>#</code>: <code>:/[^#]$/</code></li>\n<li>replace <code>#\... | 2015/04/29 | [
"https://vi.stackexchange.com/questions/3115",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/131/"
] | I have a file with a bunch of user defaults in. I want to change some of the text, but I'm struggling coming up with a matcher and replacer. Using the following example:
```
###############################################################################
# Trackpad, mouse, keyboard, Bluetooth accessories, and input ... | Just to be clear… I believe you asked for this to be the result of the substitution?
```
###############################################################################
# Trackpad, mouse, keyboard, Bluetooth accessories, and input #
######################################################################... |
3,128 | <p>I've noticed that vim's fold method affects the efficiency of autocomplete, e.g. <code>C-N</code> is slow, and <code>C-X L</code> is hideously slow in medium sized files with relatively expensive <code>foldexpr</code>s.</p>
<p>I can't see the value in having foldexpr consulted while running through auto completes, ... | [
{
"answer_id": 3144,
"author": "jjaderberg",
"author_id": 1306,
"author_profile": "https://vi.stackexchange.com/users/1306",
"pm_score": 4,
"selected": true,
"text": "<p>I had a problem a while back with syntax folding PHP where typing <code>{</code> would interfere with subsequent folds... | 2015/04/30 | [
"https://vi.stackexchange.com/questions/3128",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1406/"
] | I've noticed that vim's fold method affects the efficiency of autocomplete, e.g. `C-N` is slow, and `C-X L` is hideously slow in medium sized files with relatively expensive `foldexpr`s.
I can't see the value in having foldexpr consulted while running through auto completes, so would like to disable this somehow so I ... | I had a problem a while back with syntax folding PHP where typing `{` would interfere with subsequent folds until I typed the corresponding closing `}`. I found a suggestion somewhere (I think it was on the Vim Wiki) to temporarily set the foldmethod to manual while in insert mode. I don't know if this is *à propos* en... |
3,134 | <p>I am trying to create a mapping that has 2 functions: </p>
<p>On 1st use: redefine itself to be used</p>
<p>After: execute the newly saved mapping</p>
<p>The workflow could be : </p>
<p><code><leader>r</code> -> <code>map <leader>r dd</code></p>
<p><code><leader>r</code> -> <code>dd</code></p>... | [
{
"answer_id": 3135,
"author": "Martin Tournoij",
"author_id": 51,
"author_profile": "https://vi.stackexchange.com/users/51",
"pm_score": 2,
"selected": false,
"text": "<p>From reading the Vim source, it would seem that all occurrences of <code><Leader></code> in a mapping are repl... | 2015/04/30 | [
"https://vi.stackexchange.com/questions/3134",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1821/"
] | I am trying to create a mapping that has 2 functions:
On 1st use: redefine itself to be used
After: execute the newly saved mapping
The workflow could be :
`<leader>r` -> `map <leader>r dd`
`<leader>r` -> `dd`
`<leader>r` -> `dd`
...
So I came up with this mapping :
`map <Leader>r :nnoremap <Leader>r`
And ... | Inside a mapping, escape `<` with `<lt>` (and `|` with `<Bar>`). The following example shows a working demo of your idea:
```
:nnoremap <Leader>r :nnoremap <lt>Leader>r :echo "hi"<lt>CR><CR>
```
PS: [You should use `:noremap`](http://learnvimscriptthehardway.stevelosh.com/chapters/05.html) for the initial mapping, t... |
3,148 | <p>I noticed that when I use <code>:nohlsearch</code> that it does not actually do the same thing as <code>:set nohlsearch</code>. </p>
<p>In particular, the <code>hlsearch</code> setting is not actually switched off (which is what <code>:set hlsearch</code>) accomplishes. </p>
<p>To demonstrate what I mean: </p>
<p... | [
{
"answer_id": 3149,
"author": "FDinoff",
"author_id": 46,
"author_profile": "https://vi.stackexchange.com/users/46",
"pm_score": 5,
"selected": true,
"text": "<p>From <code>:h :nohlsearch</code></p>\n\n<pre>\n :noh :nohlsearch\n:noh... | 2015/05/02 | [
"https://vi.stackexchange.com/questions/3148",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/390/"
] | I noticed that when I use `:nohlsearch` that it does not actually do the same thing as `:set nohlsearch`.
In particular, the `hlsearch` setting is not actually switched off (which is what `:set hlsearch`) accomplishes.
To demonstrate what I mean:
```
:set hlsearch
:nohlsearch
:echo &hlsearch
```
This prints `1`... | From `:h :nohlsearch`
```
:noh :nohlsearch
:noh[lsearch] Stop the highlighting for the 'hlsearch' option. It
is automatically turned back on when using a search
command, or setting the 'hlsearch' option.... |
3,153 | <p>I'm using plugin <a href="https://github.com/Chiel92/vim-autoformat" rel="noreferrer">Chiel92/vim-autoformat</a> auto formatting xml files. So the default format program used for xml file is <code>tidy</code>. The way it formats xml file is like below:</p>
<pre><code><List id='list' items='{/sss}' mode='{device&... | [
{
"answer_id": 3161,
"author": "Martin Tournoij",
"author_id": 51,
"author_profile": "https://vi.stackexchange.com/users/51",
"pm_score": 4,
"selected": true,
"text": "<p>This should <em>almost</em> work, it aligns the attributes slightly different than your example, but it's probably \"... | 2015/05/03 | [
"https://vi.stackexchange.com/questions/3153",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1276/"
] | I'm using plugin [Chiel92/vim-autoformat](https://github.com/Chiel92/vim-autoformat) auto formatting xml files. So the default format program used for xml file is `tidy`. The way it formats xml file is like below:
```
<List id='list' items='{/sss}' mode='{device>/listMode}' noDataText='{i18n>masterListNoDataText... | This should *almost* work, it aligns the attributes slightly different than your example, but it's probably "close enough":
```
autocmd FileType xml let g:formatprg_args_expr_xml .= '." --indent-attributes 1"'
```
Which will format it like as:
```
<List id='list'
items='{/sss}'
mode='{device>/listMod... |
3,164 | <p>At first I am going try to explain you "order of opening". For example, if I'll open files in this order:</p>
<pre><code>1_file.c
2_file.c
3_file.c
4_file.c
</code></pre>
<p><code>:ls</code> command will give me:</p>
<pre><code>:ls
1 "1_file.c" line 1
2 "2_file.c" ... | [
{
"answer_id": 3167,
"author": "Ingo Karkat",
"author_id": 970,
"author_profile": "https://vi.stackexchange.com/users/970",
"pm_score": 2,
"selected": false,
"text": "<p>My <a href=\"http://www.vim.org/scripts/script.php?script_id=2695\" rel=\"nofollow\">EnhancedJumps plugin</a> provides... | 2015/05/04 | [
"https://vi.stackexchange.com/questions/3164",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/500/"
] | At first I am going try to explain you "order of opening". For example, if I'll open files in this order:
```
1_file.c
2_file.c
3_file.c
4_file.c
```
`:ls` command will give me:
```
:ls
1 "1_file.c" line 1
2 "2_file.c" line 1
3 # "3_file.c" ... | My [EnhancedJumps plugin](http://www.vim.org/scripts/script.php?script_id=2695) provides (among other variants) `<Leader><C-O>` and `<Leader><C-I>` commands that work like built-in `<C-O>` / `<C-I>`, but skip over jumps inside the same buffer.
I personally use the old [MruMenu plugin](http://www.vim.org/scripts/script... |
3,165 | <p>is it possible to edit more than one word simultaneously, which are on the same line?</p>
<p>For example, let's say I have this:</p>
<pre><code>Spam and Eggs is all you need for a healthy breakfast
</code></pre>
<p>and I would like to change the line to:</p>
<pre><code>organic_Spam and organic_Eggs is all you ne... | [
{
"answer_id": 3166,
"author": "Alexander Myshov",
"author_id": 500,
"author_profile": "https://vi.stackexchange.com/users/500",
"pm_score": 4,
"selected": false,
"text": "<p>In Vim there are no multi-cursors like in Sublime Text (but there are some plugins as I remember). But it seeems ... | 2015/05/04 | [
"https://vi.stackexchange.com/questions/3165",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1968/"
] | is it possible to edit more than one word simultaneously, which are on the same line?
For example, let's say I have this:
```
Spam and Eggs is all you need for a healthy breakfast
```
and I would like to change the line to:
```
organic_Spam and organic_Eggs is all you need for a healthy breakfast
```
I would lik... | I agree with Alexander here. In day to day editing I would probably use the `.` command as well, but if you want to execute just one command I would use the substitute command:
```
:s/S\|E/organic_&/g
```
whereas the `&` is the matched pattern from `/S\|E/`. |
3,174 | <p>When I move lines with <code>m</code> (e.g. <code>:m+1</code>) all my folds are closed. I can then open the folding with <code>zv</code> again and the cursor will be at the position I moved to.
I use folding with <code>{{{ }}}</code> marks and have <code>set foldmethod=marker</code> in my .vimrc.</p>
<p>How can I p... | [
{
"answer_id": 6967,
"author": "Dan Bradbury",
"author_id": 2189,
"author_profile": "https://vi.stackexchange.com/users/2189",
"pm_score": 1,
"selected": false,
"text": "<p>Folding is a pretty complicated mechanism (see <a href=\"https://stackoverflow.com/questions/34563239/folding-of-sc... | 2015/05/05 | [
"https://vi.stackexchange.com/questions/3174",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1982/"
] | When I move lines with `m` (e.g. `:m+1`) all my folds are closed. I can then open the folding with `zv` again and the cursor will be at the position I moved to.
I use folding with `{{{ }}}` marks and have `set foldmethod=marker` in my .vimrc.
How can I prevent vim from closing folds when moving lines? | You can disable folding before doing `:m+1` by using `zi`. And then enable it again with `zi`.
You can also add a special mapping for that in your .vimrc :
```
""move line up/down with Shift+up/down
nnoremap <S-Up> zi:m-2<CR>zi
nnoremap <S-Down> zi:m+<CR>zi
inoremap <S-Up> <Esc>zi:m-2<CR>zia
inoremap <S-Down> <Esc>z... |
3,175 | <p>I tried today to perform a search on every files of a project.
I use <a href="https://github.com/kien/ctrlp.vim" rel="nofollow noreferrer">Ctrl-P</a> and search on lines like so : </p>
<p><img src="https://i.stack.imgur.com/wCgWm.png" alt="screenshot"></p>
<p>But the result of the search is only on the previously ... | [
{
"answer_id": 3176,
"author": "romainl",
"author_id": 54,
"author_profile": "https://vi.stackexchange.com/users/54",
"pm_score": 5,
"selected": true,
"text": "<p><code>:CtrlPLine</code> is actually supposed to work on listed buffers.</p>\n\n<p>If you <em>absolutely</em> want to use that... | 2015/05/05 | [
"https://vi.stackexchange.com/questions/3175",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1821/"
] | I tried today to perform a search on every files of a project.
I use [Ctrl-P](https://github.com/kien/ctrlp.vim) and search on lines like so :

But the result of the search is only on the previously opened file. Here I open only `main.php`.
Do you know a way to sear... | `:CtrlPLine` is actually supposed to work on listed buffers.
If you *absolutely* want to use that feature on every file in your project, you could add them to the argument list (and thus the buffer list) with something like:
```
:argadd **/*.php
```
but that doesn't sound like a very good idea for performance reaso... |
3,177 | <p>I have an ftplugin under <code>&runtimepath/ftplugin/c.vim</code> which sets all my preferred options for c files. However, I would also like to use the same settings for <code>cpp</code> files. I could just copy the settings over, but that seems redundant. Is there a way of loading an ftplugin for more than ... | [
{
"answer_id": 3178,
"author": "Martin Tournoij",
"author_id": 51,
"author_profile": "https://vi.stackexchange.com/users/51",
"pm_score": 5,
"selected": true,
"text": "<p>The default ftplugin (<code>/usr/share/vim/vim74/ftplugin/cpp.vim</code> on my system) should already do this:</p>\n\... | 2015/05/05 | [
"https://vi.stackexchange.com/questions/3177",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/865/"
] | I have an ftplugin under `&runtimepath/ftplugin/c.vim` which sets all my preferred options for c files. However, I would also like to use the same settings for `cpp` files. I could just copy the settings over, but that seems redundant. Is there a way of loading an ftplugin for more than one filetype? | The default ftplugin (`/usr/share/vim/vim74/ftplugin/cpp.vim` on my system) should already do this:
```
" Only do this when not done yet for this buffer
if exists("b:did_ftplugin")
finish
endif
" Behaves just like C
runtime! ftplugin/c.vim ftplugin/c_*.vim ftplugin/c/*.vim
```
`runtime` should be relative to the ... |
3,196 | <p>When using the command-line history window, I'd like to go back to the file I use it on to see what I'm working with. When revisualizing a block of code (<code>gv</code>), the cursor will go to the top after entering command-line history (<code>q:</code>). How do I switch between these two windows/panes?</p>
<p><im... | [
{
"answer_id": 3198,
"author": "romainl",
"author_id": 54,
"author_profile": "https://vi.stackexchange.com/users/54",
"pm_score": 3,
"selected": true,
"text": "<h2><em>Generic</em> answer:</h2>\n\n<p><code><C-w>p</code> moves the cursor to the <em>previous</em> window.</p>\n\n<p>Se... | 2015/05/08 | [
"https://vi.stackexchange.com/questions/3196",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/2020/"
] | When using the command-line history window, I'd like to go back to the file I use it on to see what I'm working with. When revisualizing a block of code (`gv`), the cursor will go to the top after entering command-line history (`q:`). How do I switch between these two windows/panes?
 consider a file to be binar... | 2015/05/08 | [
"https://vi.stackexchange.com/questions/3206",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/467/"
] | Is there any way to determine within Vim that the file which I'm editing is either in text or binary format?
For example:
```
vim http://example.com/
```
vs:
```
vim http://cdn.sstatic.net/vi/img/apple-touch-icon.png
```
Something that would return either True or False based on the content of the current file. O... | Most programs (such as `grep`, `git`, `mercurial`, etc.) consider a file to be binary if it contains a NULL byte.
You can check this with Vim like so:
```
fun! IsBinary()
return !!search('\%u0000', 'wn')
endfun
```
Note that this searches the entire buffer; and won't be very fast for large files. A faster way w... |
3,211 | <p>In <a href="https://vi.stackexchange.com/a/3209/467">here</a> it's suggested that Vim can do automatic uncompression of gzip/zip files (including other formats) and it's something built-in.</p>
<p>How do I open compressed file then?</p>
<p>Sample scenario:</p>
<pre><code>curl https://html1-f.scribdassets.com/3ltyuje... | [
{
"answer_id": 3212,
"author": "kenorb",
"author_id": 467,
"author_profile": "https://vi.stackexchange.com/users/467",
"pm_score": 2,
"selected": false,
"text": "<p>Using external Unix tools is easy:</p>\n\n<pre><code>:%!gzip -d\n:%!gunzip -d\n</code></pre>\n"
},
{
"answer_id": 3... | 2015/05/08 | [
"https://vi.stackexchange.com/questions/3211",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/467/"
] | In [here](https://vi.stackexchange.com/a/3209/467) it's suggested that Vim can do automatic uncompression of gzip/zip files (including other formats) and it's something built-in.
How do I open compressed file then?
Sample scenario:
```
curl https://html1-f.scribdassets.com/3ltyujem84drr4o/pages/4-e661572124.jsonp | ... | Starting it 2005 vim added support for editing zip files natively. The build in support uses native zip utilities (zip, gzip, jar, xpi, etc) to manipulate these files. It does not look as if there is a direct way to interact with a compressed stream of data unless you use external tools.
```
vim <zipfile>
```
should... |
3,213 | <p>I'd like to remove everything apart of my pattern match.</p>
<p>For example I've the following line:</p>
<pre><code>window.page4_callback(["here \"is\" some text"]);
</code></pre>
<p>and I'd like to leave the text only within the double quotes, so the expected output is:</p>
<pre><code>here \"is\" some text
</c... | [
{
"answer_id": 3215,
"author": "Martin Tournoij",
"author_id": 51,
"author_profile": "https://vi.stackexchange.com/users/51",
"pm_score": 4,
"selected": true,
"text": "<p>There are probably a bunch of ways to do this; here's my attempt:</p>\n\n<pre><code>:%s/.*\"\\(.\\{-}\\)\".*/\\1/\n</... | 2015/05/08 | [
"https://vi.stackexchange.com/questions/3213",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/467/"
] | I'd like to remove everything apart of my pattern match.
For example I've the following line:
```
window.page4_callback(["here \"is\" some text"]);
```
and I'd like to leave the text only within the double quotes, so the expected output is:
```
here \"is\" some text
```
Matching pattern is `/".*"` and its remov... | There are probably a bunch of ways to do this; here's my attempt:
```
:%s/.*"\(.\{-}\)".*/\1/
```
The key part is `"\(.\{-}\)"`; this non-greedily matches everything in between quotes. This will match:
>
> window.page4\_callback([`"here is some text"`]);
>
>
>
The parentheses are there to start a subgroup, so ... |
3,227 | <p>When I try to open a file from multiple vim instances, I get an error with several options:</p>
<pre><code>Swap file "~/.vim/tmp/file.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort:
</code></pre>
<p>What is the difference between "Quit" and "Abort"? </p>
<p>My first guess was, wh... | [
{
"answer_id": 3229,
"author": "lcd047",
"author_id": 1577,
"author_profile": "https://vi.stackexchange.com/users/1577",
"pm_score": 5,
"selected": false,
"text": "<p>Try this: run <code>vim file1</code> in a terminal, then run <code>vim -p file1 file2</code> in a different terminal. Th... | 2015/05/12 | [
"https://vi.stackexchange.com/questions/3227",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/9/"
] | When I try to open a file from multiple vim instances, I get an error with several options:
```
Swap file "~/.vim/tmp/file.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort:
```
What is the difference between "Quit" and "Abort"?
My first guess was, when I'm trying to open multiple fi... | Try this: run `vim file1` in a terminal, then run `vim -p file1 file2` in a different terminal. The second command will prompt you as above. If you answer `Quit`, you still get to edit `file2`. If you answer `Abort` you just quit Vim, thus "aborting any further commands". |
3,231 | <p>Say that I am on line 20 and I would like to yank line 4, how can I do that?</p>
<p>And similarly, how can I yank a line relative to my cursor position, say the one 3 lines up?</p>
| [
{
"answer_id": 3232,
"author": "Martin Tournoij",
"author_id": 51,
"author_profile": "https://vi.stackexchange.com/users/51",
"pm_score": 7,
"selected": true,
"text": "<p>From <a href=\"http://vimhelp.appspot.com/change.txt.html#E850\" rel=\"noreferrer\"><code>:help :yank</code></a>:</p>... | 2015/05/12 | [
"https://vi.stackexchange.com/questions/3231",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/634/"
] | Say that I am on line 20 and I would like to yank line 4, how can I do that?
And similarly, how can I yank a line relative to my cursor position, say the one 3 lines up? | From [`:help :yank`](http://vimhelp.appspot.com/change.txt.html#E850):
```
:[range]y[ank] [x] Yank `[range]` lines [into register x].
```
So, to yank line 4, one would type:
```
:4yank
```
Note you can easily do this from insert mode with `<C-o>`; this allows you to
execute one command, after which you're re... |
3,250 | <p>I'm currently using vim-dispatch to run tests on my code which outputs the test results to the quickfix panel via tmux. However, all colors seem to be disabled in the output.</p>
<p>There's <a href="https://github.com/tpope/vim-dispatch/issues/51" rel="noreferrer">this</a> two year old issue where tpope talks about... | [
{
"answer_id": 3256,
"author": "lcd047",
"author_id": 1577,
"author_profile": "https://vi.stackexchange.com/users/1577",
"pm_score": 5,
"selected": true,
"text": "<p>If you want your tests to embed colour codes (presumably ANSI) in their output and then have the colours show in the quick... | 2015/05/13 | [
"https://vi.stackexchange.com/questions/3250",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/2061/"
] | I'm currently using vim-dispatch to run tests on my code which outputs the test results to the quickfix panel via tmux. However, all colors seem to be disabled in the output.
There's [this](https://github.com/tpope/vim-dispatch/issues/51) two year old issue where tpope talks about it a bit, but that's all i've managed... | If you want your tests to embed colour codes (presumably ANSI) in their output and then have the colours show in the quickfix window, you're out of luck.
However the quickfix buffer is just a buffer, you can add highlighting patterns to it. For example to highlight `Ok:` and `Err:` you could create a file `~/.vim/afte... |
3,259 | <p>VIM knows to identify the start and end of code functions with the <code>[[</code> and <code>]}</code> commands. <strong>How might I use this to colour the gutters or line number backgrounds differently for each function?</strong></p>
<p>The issue is that I often maintain large PHP files written by inexperienced pe... | [
{
"answer_id": 3260,
"author": "romainl",
"author_id": 54,
"author_profile": "https://vi.stackexchange.com/users/54",
"pm_score": 2,
"selected": false,
"text": "<p>You can't highlight line numbers individually.</p>\n\n<p>Signs may help you but you would need to place an awful lot of them... | 2015/05/13 | [
"https://vi.stackexchange.com/questions/3259",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/989/"
] | VIM knows to identify the start and end of code functions with the `[[` and `]}` commands. **How might I use this to colour the gutters or line number backgrounds differently for each function?**
The issue is that I often maintain large PHP files written by inexperienced people who lack the concept of maintainability.... | Here's a different solution which may be of help: put the current function name in the `statusline`:

Vim doesn't really have a concept of a "dynamic" statusline; but we can work around that by setting a new statusline on certain autocmd events and/o... |
3,261 | <p>Often when I'm in Insert mode, I'll hit <kbd>Esc</kbd> to get into Normal mode, and then immediately hit <kbd>O</kbd> to begin a new line above the cursor and go into Insert mode there.</p>
<p>But when I do that, there is a 1-second delay after I hit the <kbd>O</kbd> before there is any visible response. Furthermor... | [
{
"answer_id": 3262,
"author": "Ingo Karkat",
"author_id": 970,
"author_profile": "https://vi.stackexchange.com/users/970",
"pm_score": 4,
"selected": false,
"text": "<p>This happens only in the terminal, but not in GVIM, right? The reason is that Vim cannot distinguish between the indiv... | 2015/05/13 | [
"https://vi.stackexchange.com/questions/3261",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/2065/"
] | Often when I'm in Insert mode, I'll hit `Esc` to get into Normal mode, and then immediately hit `O` to begin a new line above the cursor and go into Insert mode there.
But when I do that, there is a 1-second delay after I hit the `O` before there is any visible response. Furthermore if I begin typing the new text duri... | This happens only in the terminal, but not in GVIM, right? The reason is that Vim cannot distinguish between the individual types keys and an ANSI Escape sequence starting with the same keys (i.e. `^[O...`, `<Esc>` followed by `O` in your case).
You can read about all the underlying complexities at `:help 'timeout'` (... |
3,267 | <p>Suppose I have a file that contains:</p>
<pre><code>Time: 60 minutes
Seconds: 3600
Milliseconds: 36000
</code></pre>
<p>I would like to replace any word with <code>seconds</code>.</p>
<pre><code>%s/seconds/time/g
</code></pre>
<p>What am looking for is after the replace,</p>
<pre><code>Time: 60 minutes
Time: 36... | [
{
"answer_id": 3268,
"author": "jecxjo",
"author_id": 895,
"author_profile": "https://vi.stackexchange.com/users/895",
"pm_score": 3,
"selected": false,
"text": "<p>Swapping via regular expressions is performed by the ex command</p>\n\n<pre><code>:{range}s/pattern/string/{flags} {count}\... | 2015/05/13 | [
"https://vi.stackexchange.com/questions/3267",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/2077/"
] | Suppose I have a file that contains:
```
Time: 60 minutes
Seconds: 3600
Milliseconds: 36000
```
I would like to replace any word with `seconds`.
```
%s/seconds/time/g
```
What am looking for is after the replace,
```
Time: 60 minutes
Time: 3600
MilliTime: 36000
```
Basically, I would like to know how I can be ... | Swapping via regular expressions is performed by the ex command
```
:{range}s/pattern/string/{flags} {count}
```
If you wish to replace instances of a work on a specific line you can supply the exact line with the absolute location. To swap matches only on line 2:
```
:2s/Seconds/time
```
Or you can use a relativ... |
3,276 | <p>I've the following example:</p>
<pre><code>vim -E http://example.com/
</code></pre>
<p>where I'd like to search for <code><head></code> tag.</p>
<p>It seems that search only works when the lines are separated, but when the lines are joined together (<code>%j</code>) then it doesn't work and it says:</p>
<b... | [
{
"answer_id": 3278,
"author": "kenorb",
"author_id": 467,
"author_profile": "https://vi.stackexchange.com/users/467",
"pm_score": 3,
"selected": true,
"text": "<p>In vim we can read (<code>:help :range</code>):</p>\n\n<blockquote>\n <p><code>/{pattern}[/]</code> - the next line where... | 2015/05/14 | [
"https://vi.stackexchange.com/questions/3276",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/467/"
] | I've the following example:
```
vim -E http://example.com/
```
where I'd like to search for `<head>` tag.
It seems that search only works when the lines are separated, but when the lines are joined together (`%j`) then it doesn't work and it says:
>
> Search hit BOTTOM, continuing at TOP
>
>
>
What I'm doing ... | In vim we can read (`:help :range`):
>
> `/{pattern}[/]` - the next line where {pattern} matches
>
>
>
That means if there is no next line - no match can be found, because there is only one current line (all lines together).
So to search starting from the first/current line, we need to use `0;/foo`.
>
> `0;/th... |
3,279 | <p>I have a log file for what should be simple counter values, formatted as:</p>
<pre><code>0 1 2 3 4 5 6 7
8 9 10 11 12 13 14 15
16 17 18 19 20 21 22 23
etc...
</code></pre>
<p>I'm looking for a way to find if there's anywhere in the log where the counter glitched, for example:</p>
<pre><code>0 3 2 3 4 5 6 7
</code... | [
{
"answer_id": 3281,
"author": "Peter Rincker",
"author_id": 778,
"author_profile": "https://vi.stackexchange.com/users/778",
"pm_score": 4,
"selected": true,
"text": "<p>I doubt Vim's regex's are powerful enough to handle that kind of pattern. However you can use any kind of generic pro... | 2015/05/14 | [
"https://vi.stackexchange.com/questions/3279",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/889/"
] | I have a log file for what should be simple counter values, formatted as:
```
0 1 2 3 4 5 6 7
8 9 10 11 12 13 14 15
16 17 18 19 20 21 22 23
etc...
```
I'm looking for a way to find if there's anywhere in the log where the counter glitched, for example:
```
0 3 2 3 4 5 6 7
```
The `0 3 2` part is erroneous and wha... | I doubt Vim's regex's are powerful enough to handle that kind of pattern. However you can use any kind of generic programing language to fit your need. Here is an awk version:
```
:%!awk '{for(i=1;i<=NF;i++) { if(i+$1-1\!=$i) { print; break;}}}'
```
Using the `!` command to filter the entire file, `%`, with an awk p... |
3,291 | <p>How to search for line containing unclosed parenthesis.</p>
<pre><code>/([^)]*$
</code></pre>
<p>works only for non-nested parenthesis.</p>
<p>If the closing parenthesis is present in the next lines, it should still be a match.</p>
<p>for example :</p>
<pre><code>foo( bar, bar
bar, bar );
</code></pre>
<p... | [
{
"answer_id": 3292,
"author": "Ingo Karkat",
"author_id": 970,
"author_profile": "https://vi.stackexchange.com/users/970",
"pm_score": 2,
"selected": false,
"text": "<p>It is hard to match balanced parentheses with regular expressions, but fortunately, Vim has built-in motions for <code... | 2015/05/15 | [
"https://vi.stackexchange.com/questions/3291",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/2056/"
] | How to search for line containing unclosed parenthesis.
```
/([^)]*$
```
works only for non-nested parenthesis.
If the closing parenthesis is present in the next lines, it should still be a match.
for example :
```
foo( bar, bar
bar, bar );
```
should be a match. | Done it myself
```
function Unclosed(pattern, pattern2)
" Store current pos
let l:matchpos = getpos('.')
" Initialize return
let l:ret = 0
" Search Pattern, no wrap
while search(a:pattern, "W", "", "") > 0
" Search for pair only in current line
if eval(searchpair(a:pattern... |
3,298 | <p>Vim normally writes <code><EOL></code> for the last line only when there was one in the original file.</p>
<p>How to make vim to write a new line at the end of a file all the time (when the file is not binary and there isn't already one)?</p>
<p>I've tested <code>eol</code> option, but it didn't work as expe... | [
{
"answer_id": 3301,
"author": "Ingo Karkat",
"author_id": 970,
"author_profile": "https://vi.stackexchange.com/users/970",
"pm_score": 3,
"selected": false,
"text": "<p>Vim only omits the EOL if the file is opened as <code>'binary'</code> <em>and</em> the <code>'endofline'</code> option... | 2015/05/15 | [
"https://vi.stackexchange.com/questions/3298",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/467/"
] | Vim normally writes `<EOL>` for the last line only when there was one in the original file.
How to make vim to write a new line at the end of a file all the time (when the file is not binary and there isn't already one)?
I've tested `eol` option, but it didn't work as expected.
See also: [Preserve missing end-of-lin... | ### Basic info
Vim doesn't show latest newline in the buffer but actually vim always place EOL at the end of the file when you write it, because it standard for text files in Unix systems. You can find more information about this [here](https://unix.stackexchange.com/questions/18743/whats-the-point-in-adding-a-new-lin... |