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 |
|---|---|---|---|---|---|---|
4,847 | <p>I'd like to edit a file in-place by appending a line, only if doesn't exist yet to make my script bullet-proof.</p>
<p>Normally I'd do something like:</p>
<pre><code>cat >> ~/.bashrc <<EOF
export PATH=~/.composer/vendor/bin:\$PATH
EOF
</code></pre>
<p>It is also possible to do it via ansible (<code>li... | [
{
"answer_id": 4933,
"author": "JJoao",
"author_id": 3002,
"author_profile": "https://vi.stackexchange.com/users/3002",
"pm_score": 1,
"selected": false,
"text": "<p>I normally use:</p>\n\n<pre><code>perl -i -p0e '$_.=\"export PATH=~/bin:\\$PATH\\n\" unless m!~/bin:!' ~/.bashrc\n</code><... | 2015/09/24 | [
"https://vi.stackexchange.com/questions/4847",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/467/"
] | I'd like to edit a file in-place by appending a line, only if doesn't exist yet to make my script bullet-proof.
Normally I'd do something like:
```
cat >> ~/.bashrc <<EOF
export PATH=~/.composer/vendor/bin:\$PATH
EOF
```
It is also possible to do it via ansible (`line`+`insertafter=EOF`+`regexp`), but it's another ... | If you want *bulletproof*, you probably want something a little more portable than the complicated options above. I would stick to [POSIX features of `ex`](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ex.html) and make it stupid-simple: Just remove the line if it's there (regardless of how many times it's ... |
4,848 | <p>I have the following mapping in my project:</p>
<pre><code>nnoremap <F7> :execute '!gtags'<cr> :cscope kill -1<cr> :cscope add CTAGS<cr>
</code></pre>
<p>Under certain conditions I want to be able to execute this mapping from a script, i.e.</p>
<pre><code>if (mycondition)
execute 'normal... | [
{
"answer_id": 4933,
"author": "JJoao",
"author_id": 3002,
"author_profile": "https://vi.stackexchange.com/users/3002",
"pm_score": 1,
"selected": false,
"text": "<p>I normally use:</p>\n\n<pre><code>perl -i -p0e '$_.=\"export PATH=~/bin:\\$PATH\\n\" unless m!~/bin:!' ~/.bashrc\n</code><... | 2015/09/24 | [
"https://vi.stackexchange.com/questions/4848",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/2865/"
] | I have the following mapping in my project:
```
nnoremap <F7> :execute '!gtags'<cr> :cscope kill -1<cr> :cscope add CTAGS<cr>
```
Under certain conditions I want to be able to execute this mapping from a script, i.e.
```
if (mycondition)
execute 'normal <F7>'
endif
```
The code above didn't work.
Does anybody ... | If you want *bulletproof*, you probably want something a little more portable than the complicated options above. I would stick to [POSIX features of `ex`](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ex.html) and make it stupid-simple: Just remove the line if it's there (regardless of how many times it's ... |
4,850 | <p>I'm not sure if I should ask this problem on vim or on Linux/Ubuntu forum. </p>
<p>The thing is, I opened multiple terminals on my desktop, and several of them opened various of <code>*.txt</code> files. Not all of them are saved.</p>
<p>Then my desktop partially broke down. I can ssh it from my laptop. Is there a... | [
{
"answer_id": 4851,
"author": "muru",
"author_id": 205,
"author_profile": "https://vi.stackexchange.com/users/205",
"pm_score": 3,
"selected": true,
"text": "<p>If you can modify those files, it's likely that Vim created swap files for them. Swap files have extensions <code>.swp</code>,... | 2015/09/25 | [
"https://vi.stackexchange.com/questions/4850",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1080/"
] | I'm not sure if I should ask this problem on vim or on Linux/Ubuntu forum.
The thing is, I opened multiple terminals on my desktop, and several of them opened various of `*.txt` files. Not all of them are saved.
Then my desktop partially broke down. I can ssh it from my laptop. Is there any way to know which files a... | If you can modify those files, it's likely that Vim created swap files for them. Swap files have extensions `.swp`, `.swo`, ..., etc. You can search for these files using `find`. Looking in your home directory, for example:
```
find ~ -type f -name '.*.sw?'
```
If the Vim programs are still running, you could expedi... |
4,870 | <p>I use vim with ruby. I have a habit of opening and closing brackets when I define new function or a block.</p>
<p>For example I would type:</p>
<pre><code>array.map {}_ # _ - cursor position after finishing typing
</code></pre>
<p>So I am still in <strong>Insert</strong> mode I have a mapping <code>imap jk <es... | [
{
"answer_id": 4851,
"author": "muru",
"author_id": 205,
"author_profile": "https://vi.stackexchange.com/users/205",
"pm_score": 3,
"selected": true,
"text": "<p>If you can modify those files, it's likely that Vim created swap files for them. Swap files have extensions <code>.swp</code>,... | 2015/09/26 | [
"https://vi.stackexchange.com/questions/4870",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4594/"
] | I use vim with ruby. I have a habit of opening and closing brackets when I define new function or a block.
For example I would type:
```
array.map {}_ # _ - cursor position after finishing typing
```
So I am still in **Insert** mode I have a mapping `imap jk <esc>` to get me out to normal mode. Cursor is going back... | If you can modify those files, it's likely that Vim created swap files for them. Swap files have extensions `.swp`, `.swo`, ..., etc. You can search for these files using `find`. Looking in your home directory, for example:
```
find ~ -type f -name '.*.sw?'
```
If the Vim programs are still running, you could expedi... |
4,873 | <p>I'd like to install VIM via apt-get, but I'm not sure if I get all of its features. </p>
<p>Is there a difference between this, and compiling it from source?</p>
| [
{
"answer_id": 4875,
"author": "statox",
"author_id": 1841,
"author_profile": "https://vi.stackexchange.com/users/1841",
"pm_score": 3,
"selected": false,
"text": "<p>Indeed the version you get with <code>apt-get install vim</code> doesn't have all the features of a version compiled with... | 2015/09/26 | [
"https://vi.stackexchange.com/questions/4873",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4663/"
] | I'd like to install VIM via apt-get, but I'm not sure if I get all of its features.
Is there a difference between this, and compiling it from source? | If you look at the options used to build the various packages (in [`debian/rules`](https://salsa.debian.org/vim-team/vim/blob/debian/sid/debian/rules)), you'll see
```
OPTFLAGS+=--with-features=huge
...
NOINTERPFLAGS:=--disable-luainterp
NOINTERPFLAGS+=--disable-mzschemeinterp
NOINTERPFLAGS+=--disable-perlinterp
ife... |
4,893 | <p>While working <a href="https://github.com/plasticboy/vim-markdown" rel="noreferrer">a Markdown plugin</a>, we've wanted to change the filetype from <code>mkd</code> to <code>markdown</code> to increase compatibility with other plugins.</p>
<p>To avoid breaking users <code>.vimrc</code> that had autocommands like:</... | [
{
"answer_id": 4897,
"author": "Christian Brabandt",
"author_id": 71,
"author_profile": "https://vi.stackexchange.com/users/71",
"pm_score": 4,
"selected": true,
"text": "<p>Use</p>\n\n<pre><code>:autocmd FileType *markdown* :echom \"a\"\n</code></pre>\n\n<p>This will match for the mk.ma... | 2015/09/28 | [
"https://vi.stackexchange.com/questions/4893",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/2038/"
] | While working [a Markdown plugin](https://github.com/plasticboy/vim-markdown), we've wanted to change the filetype from `mkd` to `markdown` to increase compatibility with other plugins.
To avoid breaking users `.vimrc` that had autocommands like:
```
autocmd FileType mkd echo 'a'
```
we've tried using:
```
set fil... | Use
```
:autocmd FileType *markdown* :echom "a"
```
This will match for the mk.markdown pattern as well as the regular markdown pattern. It's important to keep the '\*' to have the pattern match even when other subtypes have been provided (otherwise markdown would not match the string mkd.markdown, since this is imp... |
4,894 | <p><code>ignorecase</code> is a global option, so it's not possible to locally set ic</p>
<pre><code>:setlocal ic
</code></pre>
<p>This is a bit unfortunate, since I work on buffers in which I need to search case insensitively and other buffers in which I need to search case sensitively.</p>
<p>So, is there a trick ... | [
{
"answer_id": 4895,
"author": "muru",
"author_id": 205,
"author_profile": "https://vi.stackexchange.com/users/205",
"pm_score": 3,
"selected": false,
"text": "<p>You can always prefix your search expression with <code>\\c</code> to enforce case insensitivity (and <code>\\C</code> for ca... | 2015/09/28 | [
"https://vi.stackexchange.com/questions/4894",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/985/"
] | `ignorecase` is a global option, so it's not possible to locally set ic
```
:setlocal ic
```
This is a bit unfortunate, since I work on buffers in which I need to search case insensitively and other buffers in which I need to search case sensitively.
So, is there a trick to set `ic` locally in a buffer. | I guess the usual trick is to set ignorecase and smartcase and depending on what you need, search using only lower case (which means to ignore the case for that particular search) or search using mixed case, if you need to have the search match the provided case.
The other alternative is to use the '\c' and '\C' atoms... |
4,901 | <p>Via <a href="https://code.google.com/p/conque/" rel="nofollow" title="Conque">Conque</a> I use vim as an IDE for all my coding. I am starting to work in python, which is persnickety about spacing, so to test deeply indented subroutines or code blocks, I need to gate code sent to the terminal with <code>%cpaste</code... | [
{
"answer_id": 6252,
"author": "Pak",
"author_id": 1115,
"author_profile": "https://vi.stackexchange.com/users/1115",
"pm_score": 1,
"selected": false,
"text": "<p>Unfortunately, I'm not sure I fully understand the problem you are having or what you are trying to achieve. From what I ca... | 2015/09/28 | [
"https://vi.stackexchange.com/questions/4901",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4686/"
] | Via [Conque](https://code.google.com/p/conque/ "Conque") I use vim as an IDE for all my coding. I am starting to work in python, which is persnickety about spacing, so to test deeply indented subroutines or code blocks, I need to gate code sent to the terminal with `%cpaste` and `--`. That is, if I am interactively edi... | It's possible to get this behaviour *without* changing ConqueTerm's code itself. The code below applies your desired behaviour to linewise visual mode selections\*.
It works by adding the gates to the buffer, sending the whole lot over to ConqueTerm (using the same code that ConqueTerm itself uses in its mapping), and... |
4,902 | <p>I need to search for lines which contain some word but do <em>not</em> contain a second word.</p>
<p>For example, find lines that contain the word "This" but not the word "red"</p>
<p>so that for a file containing these lines</p>
<pre><code>This is a blue coat
This is a red coat
This is a purple coat
That is a c... | [
{
"answer_id": 4903,
"author": "romainl",
"author_id": 54,
"author_profile": "https://vi.stackexchange.com/users/54",
"pm_score": 5,
"selected": false,
"text": "<p>You can use this command to print lines containing <code>This</code> and not <code>red</code>:</p>\n\n<pre><code>:g/\\(.*Thi... | 2015/09/28 | [
"https://vi.stackexchange.com/questions/4902",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4667/"
] | I need to search for lines which contain some word but do *not* contain a second word.
For example, find lines that contain the word "This" but not the word "red"
so that for a file containing these lines
```
This is a blue coat
This is a red coat
This is a purple coat
That is a coat
```
The search would locate t... | And there is also another way with `:global` command, as follows:
```
:g/This\C/v/red/p
```
and the first `:g` command filter the lines contains `This`, and then passed into the second `:v` command to show lines that don't contain `red`, and at last, `p` (short for `print`) is applied to those lines with matches.
T... |
4,906 | <p>When I am writting a Latex document I generally like to keep an 80 column
line width to keep things easy to read. However I don't like to use text
wrapping because it can get in the way of typing equations. </p>
<p>Normally I will type a paragraph without caring how long the lines are, and eventually they graduall... | [
{
"answer_id": 4903,
"author": "romainl",
"author_id": 54,
"author_profile": "https://vi.stackexchange.com/users/54",
"pm_score": 5,
"selected": false,
"text": "<p>You can use this command to print lines containing <code>This</code> and not <code>red</code>:</p>\n\n<pre><code>:g/\\(.*Thi... | 2015/09/29 | [
"https://vi.stackexchange.com/questions/4906",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4692/"
] | When I am writting a Latex document I generally like to keep an 80 column
line width to keep things easy to read. However I don't like to use text
wrapping because it can get in the way of typing equations.
Normally I will type a paragraph without caring how long the lines are, and eventually they gradually get long... | And there is also another way with `:global` command, as follows:
```
:g/This\C/v/red/p
```
and the first `:g` command filter the lines contains `This`, and then passed into the second `:v` command to show lines that don't contain `red`, and at last, `p` (short for `print`) is applied to those lines with matches.
T... |
4,909 | <p>What is the appropriate way to make shortcuts for phrases like ‘on the other hand’? I tried <code>imap otoh on the other hand</code>, but that produces an undesireable lag after all <code>o</code>s.</p>
| [
{
"answer_id": 4910,
"author": "romainl",
"author_id": 54,
"author_profile": "https://vi.stackexchange.com/users/54",
"pm_score": 4,
"selected": true,
"text": "<p>Take a look at <code>:help abbreviations</code>:</p>\n\n<pre><code>iabbrev otoh on the other hand\n</code></pre>\n"
},
{
... | 2015/09/29 | [
"https://vi.stackexchange.com/questions/4909",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4505/"
] | What is the appropriate way to make shortcuts for phrases like ‘on the other hand’? I tried `imap otoh on the other hand`, but that produces an undesireable lag after all `o`s. | Take a look at `:help abbreviations`:
```
iabbrev otoh on the other hand
``` |
4,914 | <p>This is more of a specific deeper dive into vanilla Vim then the question <a href="https://vi.stackexchange.com/questions/2493/can-i-make-vim-also-save-small-deletions-into-register-1">Can I make Vim also save “small deletions” into register "1?</a>.</p>
<p>A common text editing situation I run into is to yank a te... | [
{
"answer_id": 4917,
"author": "romainl",
"author_id": 54,
"author_profile": "https://vi.stackexchange.com/users/54",
"pm_score": 4,
"selected": true,
"text": "<p>If you don't use a specific register, the text you yank systematically goes into register <code>0</code> where it will stay u... | 2015/09/29 | [
"https://vi.stackexchange.com/questions/4914",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/544/"
] | This is more of a specific deeper dive into vanilla Vim then the question [Can I make Vim also save “small deletions” into register "1?](https://vi.stackexchange.com/questions/2493/can-i-make-vim-also-save-small-deletions-into-register-1).
A common text editing situation I run into is to yank a text string and then at... | If you don't use a specific register, the text you yank systematically goes into register `0` where it will stay until you yank something else.
This means that you can still use what you yanked, even if you cut stuff in the mean time.
Paste from register `0` in normal mode: `"0p`.
Insert content of register `0` in i... |
4,924 | <p>When I am coding in c++, I want vim to expand <code>(</code> into <code>()<++></code> and place the cursor in the parenthesis. I do this by putting the following line in one of the files loaded at startup:</p>
<pre><code>inoremap ( ()<++><Left><Left><Left><Left><Left>
... | [
{
"answer_id": 4926,
"author": "Luc Hermitte",
"author_id": 626,
"author_profile": "https://vi.stackexchange.com/users/626",
"pm_score": 0,
"selected": false,
"text": "<p>[copy paste of the answer given on SO...]</p>\n\n<p>Install <a href=\"https://github.com/LucHermitte/lh-brackets/\" r... | 2015/09/30 | [
"https://vi.stackexchange.com/questions/4924",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4708/"
] | When I am coding in c++, I want vim to expand `(` into `()<++>` and place the cursor in the parenthesis. I do this by putting the following line in one of the files loaded at startup:
```
inoremap ( ()<++><Left><Left><Left><Left><Left>
```
However, I would like this binding to be disabled in comments, like
```... | You can make use of expression mappings. The basic idea is to test the current syntax and only expand, if it is not a comment. That is basically what all the plugins will be hiding from you:
`:inoremap <silent><expr> ( synIDattr(synIDtrans(synID(line('.'), col('.')-1, 'name')),'name')=~?"comment"?"(":"()<++><Left><Left... |
4,944 | <p>I am trying to reverse a string, so that <code>'abc defg hij'</code> becomes <code>'jih gfed cba'</code>. The solution I came up with is</p>
<pre><code>join(reverse(split(l:text, '.\zs')), '')
</code></pre>
<p>Is there a more elegant solution or should I stick with what I have come up with?</p>
| [
{
"answer_id": 4949,
"author": "JJoao",
"author_id": 3002,
"author_profile": "https://vi.stackexchange.com/users/3002",
"pm_score": 5,
"selected": true,
"text": "<p>Your solution is very elegant! An alternative if you are in Unix based env:</p>\n\n<pre><code>!!rev\n</code></pre>\n"
},
... | 2015/10/01 | [
"https://vi.stackexchange.com/questions/4944",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/985/"
] | I am trying to reverse a string, so that `'abc defg hij'` becomes `'jih gfed cba'`. The solution I came up with is
```
join(reverse(split(l:text, '.\zs')), '')
```
Is there a more elegant solution or should I stick with what I have come up with? | Your solution is very elegant! An alternative if you are in Unix based env:
```
!!rev
``` |
4,947 | <p>According to <code>:help strpart()</code>, the parameters <code>start</code> and <code>len</code> are bytes, not characters, so that <a href="https://i.stack.imgur.com/zCKWh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/zCKWh.png" alt="enter image description here"></a></p>
<p>returns a string of 2 char... | [
{
"answer_id": 4950,
"author": "Sato Katsura",
"author_id": 2313,
"author_profile": "https://vi.stackexchange.com/users/2313",
"pm_score": 4,
"selected": true,
"text": "<p>Something like this should work:</p>\n\n<pre><code>function! Strpartw(src, start, ...)\n return a:0 ?\n \\... | 2015/10/01 | [
"https://vi.stackexchange.com/questions/4947",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/985/"
] | According to `:help strpart()`, the parameters `start` and `len` are bytes, not characters, so that [](https://i.stack.imgur.com/zCKWh.png)
returns a string of 2 characters, starting with the letter *Beth*. What I'd like to have is a function, that I ... | Something like this should work:
```
function! Strpartw(src, start, ...)
return a:0 ?
\ join(split(a:src, '.\zs')[a:start : (a:start + a:1 - 1)], '') :
\ join(split(a:src, '.\zs')[a:start :], '')
endfunction
``` |
4,962 | <p>Say I do a regex search for a class of characters, e.g.:</p>
<pre><code>/[clsktb]
</code></pre>
<p>Is there a way to either sort lines by the number of matched characters, or to show the number of matches next to the line numbers?</p>
| [
{
"answer_id": 4964,
"author": "JJoao",
"author_id": 3002,
"author_profile": "https://vi.stackexchange.com/users/3002",
"pm_score": 1,
"selected": false,
"text": "<p>Many Vims provide support for some scripting languages (Perl, Ruby, Python). If your vim has Perl support (some distributi... | 2015/10/02 | [
"https://vi.stackexchange.com/questions/4962",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/411/"
] | Say I do a regex search for a class of characters, e.g.:
```
/[clsktb]
```
Is there a way to either sort lines by the number of matched characters, or to show the number of matches next to the line numbers? | Here is a variation:
```
:%s/^/\=len(split(getline('.'), '[clsktb]\zs')).' '/
```
That searches for line start, and for each line, gets its content and checks how many matches it has and puts the result back on the line. |
4,968 | <p>I am new to vim, and I use netrw as a file explorer. </p>
<p>Frequently hit shift-P to open a file in a buffer. Sometimes I accidentally hit <a href="http://vimdoc.sourceforge.net/htmldoc/pi_netrw.html#netrw-O" rel="nofollow noreferrer">shift-O</a>, and netrw will start obtaining the file. How do I cancel cancel ... | [
{
"answer_id": 5106,
"author": "TMB",
"author_id": 3241,
"author_profile": "https://vi.stackexchange.com/users/3241",
"pm_score": 3,
"selected": true,
"text": "<p>Just call</p>\n\n<pre><code>:set statusline&\n</code></pre>\n"
},
{
"answer_id": 5557,
"author": "user21497",... | 2015/10/02 | [
"https://vi.stackexchange.com/questions/4968",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/3241/"
] | I am new to vim, and I use netrw as a file explorer.
Frequently hit shift-P to open a file in a buffer. Sometimes I accidentally hit [shift-O](http://vimdoc.sourceforge.net/htmldoc/pi_netrw.html#netrw-O), and netrw will start obtaining the file. How do I cancel cancel that?
Two changes I see happen are a new split o... | Just call
```
:set statusline&
``` |
4,969 | <p>What is the <code>~/.vim</code> file used for, if anything, other than plugins? Is it part of Vim, or was it "invented" by plugin managers like Vundle?</p>
| [
{
"answer_id": 4970,
"author": "garyjohn",
"author_id": 2055,
"author_profile": "https://vi.stackexchange.com/users/2055",
"pm_score": 3,
"selected": false,
"text": "<p>It's an optional part of Vim proper and predated the plugin managers. It can be used for plugins you write yourself, fo... | 2015/10/03 | [
"https://vi.stackexchange.com/questions/4969",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4674/"
] | What is the `~/.vim` file used for, if anything, other than plugins? Is it part of Vim, or was it "invented" by plugin managers like Vundle? | I don't have conclusive evidence, but:
* `.vim` is one of the default values of [`'runtimepath'`](http://vimhelp.appspot.com/options.txt.html#%27runtimepath%27):
```
'runtimepath' 'rtp' vimfiles
'runtimepath' 'rtp' string (default:
Unix: "$H... |
4,981 | <p>I'd like to be able to create the commands</p>
<pre><code>nmap oo o
nmap oi o<Esc>
nmap OO O
nmap OI O<Esc>
</code></pre>
<p>but the problem is that <code>o</code> triggers immediately and the second character ends up in Insert mode. <code>nnoremap o <nop></code> doesn't fix things.</p>
<p>Can I... | [
{
"answer_id": 4970,
"author": "garyjohn",
"author_id": 2055,
"author_profile": "https://vi.stackexchange.com/users/2055",
"pm_score": 3,
"selected": false,
"text": "<p>It's an optional part of Vim proper and predated the plugin managers. It can be used for plugins you write yourself, fo... | 2015/10/05 | [
"https://vi.stackexchange.com/questions/4981",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4674/"
] | I'd like to be able to create the commands
```
nmap oo o
nmap oi o<Esc>
nmap OO O
nmap OI O<Esc>
```
but the problem is that `o` triggers immediately and the second character ends up in Insert mode. `nnoremap o <nop>` doesn't fix things.
Can I "disable" the `o` command while still allowing it to be mapped?
Obvious... | I don't have conclusive evidence, but:
* `.vim` is one of the default values of [`'runtimepath'`](http://vimhelp.appspot.com/options.txt.html#%27runtimepath%27):
```
'runtimepath' 'rtp' vimfiles
'runtimepath' 'rtp' string (default:
Unix: "$H... |
4,990 | <p>I'm using vim a lot and I'm trying to optimize few movements I do with too much key pressed. </p>
<p>For exemple I have this :</p>
<pre><code>module SanitizeIdsParams
def self.my_method ids
...code
end
end
</code></pre>
<p>And I want this</p>
<pre><code>module SanitizeIdsParams
def self.my_method ids
... | [
{
"answer_id": 4992,
"author": "romainl",
"author_id": 54,
"author_profile": "https://vi.stackexchange.com/users/54",
"pm_score": 3,
"selected": true,
"text": "<p>Once you have your visual selection you can do:</p>\n\n<pre><code>:'<,'>t'>\n</code></pre>\n\n<p>(it's actually <cod... | 2015/10/06 | [
"https://vi.stackexchange.com/questions/4990",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/3357/"
] | I'm using vim a lot and I'm trying to optimize few movements I do with too much key pressed.
For exemple I have this :
```
module SanitizeIdsParams
def self.my_method ids
...code
end
end
```
And I want this
```
module SanitizeIdsParams
def self.my_method ids
...code
end
def self.my_method ids
... | Once you have your visual selection you can do:
```
:'<,'>t'>
```
(it's actually `:t'>` because Vim adds the visual range automatically)
to copy it after the visual selection and do:
```
'[O<Esc>
```
to add an empty line.
If you don't want to use visual selection, something like this should work:
```
:,/end/t/... |
4,995 | <p>When I open a large number of files in vim with tabs only the first <code>tabpagemax</code> files are in tabs and any more than that are available by doing <code>:n</code>. After I close several of the open tabs how do I 'refresh' the tabs with the untabbed files?</p>
| [
{
"answer_id": 4996,
"author": "Christian Brabandt",
"author_id": 71,
"author_profile": "https://vi.stackexchange.com/users/71",
"pm_score": 4,
"selected": true,
"text": "<p>You can use <code>:tab ball</code> to open remaining buffers from the buffer list in new tabs. However, if you hav... | 2015/10/06 | [
"https://vi.stackexchange.com/questions/4995",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4761/"
] | When I open a large number of files in vim with tabs only the first `tabpagemax` files are in tabs and any more than that are available by doing `:n`. After I close several of the open tabs how do I 'refresh' the tabs with the untabbed files? | You can use `:tab ball` to open remaining buffers from the buffer list in new tabs. However, if you have more buffers left, than your 'tabpagemax' option, the last tab will open split windows for the remaining ones.
Perhaps this works better:
```
:set tabpagemax=99
:tab ball
```
or even `:exe "tab ball" &tabpagemax... |
5,028 | <p>When editing html in Vim, I'll write the class name of the section that I am working on like this:</p>
<pre><code>mid-med
</code></pre>
<p>It is untagged plain text.</p>
<p>I'll call tcomment to comment that out. What I expect to have happen is this:</p>
<pre><code><!-- mid-med -->
</code></pre>
<p>Instead I g... | [
{
"answer_id": 5040,
"author": "Sato Katsura",
"author_id": 2313,
"author_profile": "https://vi.stackexchange.com/users/2313",
"pm_score": 3,
"selected": true,
"text": "<p>Add this to a file <code>~/.vim/ftplugin/html.vim</code>:</p>\n\n<pre><code>let g:tcomment#replacements_xml = {}\n</... | 2015/10/08 | [
"https://vi.stackexchange.com/questions/5028",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4803/"
] | When editing html in Vim, I'll write the class name of the section that I am working on like this:
```
mid-med
```
It is untagged plain text.
I'll call tcomment to comment that out. What I expect to have happen is this:
```
<!-- mid-med -->
```
Instead I get this:
```
<!-- mid-med -->
```
tcomment is conv... | Add this to a file `~/.vim/ftplugin/html.vim`:
```
let g:tcomment#replacements_xml = {}
``` |
5,029 | <p>I'm trying to create a key mapping that makes switching buffers quicker and easier - something like:</p>
<pre><code>set wildmenu
nnoremap <Tab> :buffer<space><Tab>
</code></pre>
<p>The problem is, this mapping leaves me at the end of a command line that looks like:</p>
<pre><code>:buffer ^I
</co... | [
{
"answer_id": 5030,
"author": "statox",
"author_id": 1841,
"author_profile": "https://vi.stackexchange.com/users/1841",
"pm_score": 3,
"selected": true,
"text": "<p>You need to <code>set wildcharm=<Tab></code> and the following mapping will do what you want:</p>\n\n<pre><code>nnor... | 2015/10/08 | [
"https://vi.stackexchange.com/questions/5029",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4808/"
] | I'm trying to create a key mapping that makes switching buffers quicker and easier - something like:
```
set wildmenu
nnoremap <Tab> :buffer<space><Tab>
```
The problem is, this mapping leaves me at the end of a command line that looks like:
```
:buffer ^I
```
when I want it to start tabbing through the list of b... | You need to `set wildcharm=<Tab>` and the following mapping will do what you want:
```
nnoremap <Tab> :buffer <Tab>
```
See [`:h 'wildcharm'`](http://vimdoc.sourceforge.net/htmldoc/options.html#%27wildcharm%27) and [`:h 'wildchar'`](http://vimdoc.sourceforge.net/htmldoc/options.html#%27wildchar%27):
* `wildchar` de... |
5,032 | <p>I use vim in the terminal as well as gvim. My issue is that in the terminal <kbd>g</kbd><kbd>x</kbd> opens urls without a problem but in gVim nothing happens.</p>
<p>Has anyone else experienced this issue and found a fix?</p>
<p>I'm using gvim 7.4 with patches 1-52.</p>
| [
{
"answer_id": 5034,
"author": "Christian Brabandt",
"author_id": 71,
"author_profile": "https://vi.stackexchange.com/users/71",
"pm_score": 4,
"selected": true,
"text": "<p>I just tried this on a debian with XFCE desktop environment and I can reproduce the issue. Turns out, that gvim ca... | 2015/10/08 | [
"https://vi.stackexchange.com/questions/5032",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4807/"
] | I use vim in the terminal as well as gvim. My issue is that in the terminal `g``x` opens urls without a problem but in gVim nothing happens.
Has anyone else experienced this issue and found a fix?
I'm using gvim 7.4 with patches 1-52. | I just tried this on a debian with XFCE desktop environment and I can reproduce the issue. Turns out, that gvim calls xdg-open URL to open the URL, but unfortunately, this did not return anything or display an error message.
However, I could fix this, by using `setsid xdg-open` which you need to set for the g:netrw
`... |
5,038 | <p>For example, this text:</p>
<pre><code>2:26
3:04
3:14
5:38
4:12
10:30
6:29
6:53
11:49
9:33
4:17
7:49
6:10
6:04
6:28
6:40
4:21
</code></pre>
<p>(These are actually minute:second format, not hour:minute, if it matters. So ideally the sum would compute hours from the total minutes and give the answer hours:minutes:s... | [
{
"answer_id": 5039,
"author": "Wildcard",
"author_id": 4676,
"author_profile": "https://vi.stackexchange.com/users/4676",
"pm_score": 1,
"selected": false,
"text": "<p>There may be a better way, but here is the hacky native solution I used. It won't work as written if any of the number... | 2015/10/09 | [
"https://vi.stackexchange.com/questions/5038",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4676/"
] | For example, this text:
```
2:26
3:04
3:14
5:38
4:12
10:30
6:29
6:53
11:49
9:33
4:17
7:49
6:10
6:04
6:28
6:40
4:21
```
(These are actually minute:second format, not hour:minute, if it matters. So ideally the sum would compute hours from the total minutes and give the answer hours:minutes:seconds.)
I know there are ... | One powerful function of vim is piping an area thru an external command.
(I think this is not what you are looking for, but, just for the record):
```
:%!awk -F: '{a=$2*60+$1} END {printf("\%d:\%02d",a/60,a\%60)}'
```
---
\thanks{Wildcard} for pointing out the "`10:09`" problem and solution |
5,048 | <p>I love to use Vim as simple IDE when compiling C/C++ programs (let say with gcc on a Linux terminal), just inside Vim with command:</p>
<pre><code>:w | make | cw
</code></pre>
<p>In that way:</p>
<ul>
<li>the <code>:w</code> vim command save editing</li>
<li>the <code>:make</code> INTERNAL vim command invoke the ext... | [
{
"answer_id": 5053,
"author": "joeytwiddle",
"author_id": 630,
"author_profile": "https://vi.stackexchange.com/users/630",
"pm_score": 5,
"selected": true,
"text": "<p>Vim displays the \"Press ENTER\" prompt when the number of lines printed in the command area is greater than the number... | 2015/10/09 | [
"https://vi.stackexchange.com/questions/5048",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/983/"
] | I love to use Vim as simple IDE when compiling C/C++ programs (let say with gcc on a Linux terminal), just inside Vim with command:
```
:w | make | cw
```
In that way:
* the `:w` vim command save editing
* the `:make` INTERNAL vim command invoke the external make program using
makefile.
* the `:cw` vim command the ... | Vim displays the "Press ENTER" prompt when the number of lines printed in the command area is greater than the number of lines it has available. This is to ensure the user doesn't miss a message.
The issue has been [documented in Vim's help](http://vimdoc.sourceforge.net/htmldoc/message.html#press-enter) (`:h press-en... |
5,050 | <p>I use Vim's spellchecking feature. Given that I work with many technical terms and LaTeX commands, I tend to add many them to my personal dictionary in <code>~/.vim/spell/en.utf-8.add</code>.</p>
<p>I would like to share this file across multiple machines, so that when I add a word to the file on one machine, it is ... | [
{
"answer_id": 5051,
"author": "zomgdavidbowie",
"author_id": 4823,
"author_profile": "https://vi.stackexchange.com/users/4823",
"pm_score": 0,
"selected": false,
"text": "<p>I sync my .vim folder to my machines using Dropbox. Whenever I've made a change to my configuration, I'll throw i... | 2015/10/09 | [
"https://vi.stackexchange.com/questions/5050",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4819/"
] | I use Vim's spellchecking feature. Given that I work with many technical terms and LaTeX commands, I tend to add many them to my personal dictionary in `~/.vim/spell/en.utf-8.add`.
I would like to share this file across multiple machines, so that when I add a word to the file on one machine, it is also added on other ... | Vim uses the `spl` file to do the checks, and the `spl` file is generated from the `add` file. We can speculate on whether the `spl` file is portable across different machines and Vim versions, but it's easier (and safer) to re-generate it as needed. Now, the `spl` file is re-generated automatically when you add words ... |
5,056 | <p>I have a function I wrote specifically for a certain session in vim. Manually redefining it every time I load the session is tedious. Is there any way custom functions can be saved with the session? If not, what're some options for speeding up reloading that function every time I load the session?</p>
| [
{
"answer_id": 5119,
"author": "Vlad GURDIGA",
"author_id": 4922,
"author_profile": "https://vi.stackexchange.com/users/4922",
"pm_score": 0,
"selected": false,
"text": "<p>Assuming that “certain session” means “certain project” and “certain directory” I would try to use the per-project ... | 2015/10/09 | [
"https://vi.stackexchange.com/questions/5056",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1166/"
] | I have a function I wrote specifically for a certain session in vim. Manually redefining it every time I load the session is tedious. Is there any way custom functions can be saved with the session? If not, what're some options for speeding up reloading that function every time I load the session? | Put the function in a file with the same name as your session file but ending in `x.vim` as described in item 10 under
```
:help mks
``` |
5,067 | <p>Is it possible to make the surround plugin work on <code>`TeX-style quotes'</code> and <code>``TeX-style double quotes''</code>? (Normally, if <code>`this is quoted'</code>| and <code>`this'</code>, <code>va'</code> will select from the first closing mark to the second (if the cursor is at |).)</p>
| [
{
"answer_id": 5070,
"author": "FDinoff",
"author_id": 46,
"author_profile": "https://vi.stackexchange.com/users/46",
"pm_score": 4,
"selected": true,
"text": "<p>You can create a customize surround by defining a variable <code>g:surround_{key code}</code></p>\n\n<p>So for example you co... | 2015/10/10 | [
"https://vi.stackexchange.com/questions/5067",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4505/"
] | Is it possible to make the surround plugin work on ``TeX-style quotes'` and ```TeX-style double quotes''`? (Normally, if ``this is quoted'`| and ``this'`, `va'` will select from the first closing mark to the second (if the cursor is at |).) | You can create a customize surround by defining a variable `g:surround_{key code}`
So for example you could do
```
let g:surround_96 = "`\r'"
```
Where 96 is the key code for ```. You can make this more readable by putting by letting vim determine the key code by using
```
let g:surround_{char2nr("`")} = "`\r'"
... |
5,080 | <p><code>:s/pattern/replacement</code> operates on the first match and
<code>:s/pattern/replacement/g</code> on all.</p>
<p>How to operate only on the last one?</p>
| [
{
"answer_id": 5081,
"author": "ryuichiro",
"author_id": 2961,
"author_profile": "https://vi.stackexchange.com/users/2961",
"pm_score": 5,
"selected": true,
"text": "<p>I would use <a href=\"http://vimhelp.appspot.com/pattern.txt.html#%2F%5Czs\"><code>\\zs</code></a></p>\n\n<pre><code>:%... | 2015/10/11 | [
"https://vi.stackexchange.com/questions/5080",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4505/"
] | `:s/pattern/replacement` operates on the first match and
`:s/pattern/replacement/g` on all.
How to operate only on the last one? | I would use [`\zs`](http://vimhelp.appspot.com/pattern.txt.html#%2F%5Czs)
```
:%s/.*\zspattern/replacement/
```
A little bit of explanation:
* `.` represents any single character
* `*` represents greedy matching (as many as possible)
In Vim you can use zero-width anchors `\zs` and `\ze` to define the start and the... |
5,091 | <p>If I want to delete every word, that is easy, because I would do something like this:</p>
<pre><code>:s%/WORD//g
</code></pre>
<p>But what if I want to do <code>xyz</code> to every occurrence of "WORD"? For example, let's say I want to delete every line that contains "WORD". I can think of a couple ways to do this... | [
{
"answer_id": 5092,
"author": "Luc Hermitte",
"author_id": 626,
"author_profile": "https://vi.stackexchange.com/users/626",
"pm_score": 2,
"selected": false,
"text": "<p>It seems you are looking for <code>:global</code>.</p>\n\n<pre><code>:g/WORD/d_\n</code></pre>\n"
},
{
"answe... | 2015/10/13 | [
"https://vi.stackexchange.com/questions/5091",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/2920/"
] | If I want to delete every word, that is easy, because I would do something like this:
```
:s%/WORD//g
```
But what if I want to do `xyz` to every occurrence of "WORD"? For example, let's say I want to delete every line that contains "WORD". I can think of a couple ways to do this, but none of them seem ideal.
1)
... | You can use the `:global` and `:normal` commands for this. The `:global` command has the following syntax:
```
:global/{pattern}/{command}
```
This will run "command" on every occurrence of "pattern". You can then use the `:normal` command to run a series of keystrokes on each occurrence of a word using `:global`. L... |
5,108 | <p>I have this in my <code>.vimrc</code>:</p>
<pre><code>set directory=~/.vim/tmp-backup-swapfiles
</code></pre>
<p>This directory is read- and writable by me, sensibly enough. It is part of the local filesystem and never inaccessible.</p>
<p>However, vim seems to often ignore this and instead use <code>~/tmp</code... | [
{
"answer_id": 5111,
"author": "ryuichiro",
"author_id": 2961,
"author_profile": "https://vi.stackexchange.com/users/2961",
"pm_score": 2,
"selected": true,
"text": "<p>Use</p>\n<pre><code>:set dir?\n</code></pre>\n<p>to see which directories are used to store your swap files. If you ins... | 2015/10/14 | [
"https://vi.stackexchange.com/questions/5108",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4913/"
] | I have this in my `.vimrc`:
```
set directory=~/.vim/tmp-backup-swapfiles
```
This directory is read- and writable by me, sensibly enough. It is part of the local filesystem and never inaccessible.
However, vim seems to often ignore this and instead use `~/tmp`. I've sometimes thought it does this with files from a... | Use
```
:set dir?
```
to see which directories are used to store your swap files. If you insist on having just one directory, you could use
```
set directory=~/.vim/tmp-backup-swapfiles//
```
Using double trailing slashes in the path tells Vim to create swap files using the whole path of the files being edited to... |
5,110 | <p>Say I have a python script with a runtime error:</p>
<pre><code>$ cat example.py
#! /usr/bin/env python3
a = 1/0
</code></pre>
<p>which gives:</p>
<pre><code>$ python3 example.py
Traceback (most recent call last):
File "example.py", line 3, in <module>
a = 1/0
ZeroDivisionError: division by zero
<... | [
{
"answer_id": 10143,
"author": "Chris Hanning",
"author_id": 9976,
"author_profile": "https://vi.stackexchange.com/users/9976",
"pm_score": 0,
"selected": false,
"text": "<p>Not an automatic method but the python Traceback states the line number --- 3 in your example --- and so invoking... | 2015/10/14 | [
"https://vi.stackexchange.com/questions/5110",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4498/"
] | Say I have a python script with a runtime error:
```
$ cat example.py
#! /usr/bin/env python3
a = 1/0
```
which gives:
```
$ python3 example.py
Traceback (most recent call last):
File "example.py", line 3, in <module>
a = 1/0
ZeroDivisionError: division by zero
```
I want Vim to jump to the problematic ... | Vim comes with a set of "compiler" scripts, one of which is called ["pyunit"](https://vimhelp.appspot.com/quickfix.txt.html#compiler-pyunit). If you run `:compiler pyunit` and then `:make` (with your suggested value for `'makeprg'`), quickfix is populated as you expect. However, it only works well if there's one level ... |
5,114 | <p>I am trying to get use the help files more, and therefore I would like to make so I can just put the cursor over a setting in my <code>.vimrc</code> and press <code>Ctrl-]</code> to open the relevant section in the help files.</p>
<p>If I e.g. write <code>:help nocompatible</code>, it brings up the relevant help se... | [
{
"answer_id": 5115,
"author": "muru",
"author_id": 205,
"author_profile": "https://vi.stackexchange.com/users/205",
"pm_score": 2,
"selected": false,
"text": "<p>The help system's tag files are probably present, but loaded only for the <code>help</code> system. You could probably define... | 2015/10/14 | [
"https://vi.stackexchange.com/questions/5114",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4882/"
] | I am trying to get use the help files more, and therefore I would like to make so I can just put the cursor over a setting in my `.vimrc` and press `Ctrl-]` to open the relevant section in the help files.
If I e.g. write `:help nocompatible`, it brings up the relevant help section. However, if I move my cursor over th... | The help system's tag files are probably present, but loaded only for the `help` system. You could probably define a mapping, like:
```
nnoremap <c-]> :exec "h " . expand("<cword>")<cr>
```
`<cword>` contains the word currently under the cursor, so we use `expand?("<cword>")` to get its value and run the `:h[elp]` c... |
5,123 | <p>I know that in vim I can add </p>
<pre><code>set nocompatible
</code></pre>
<p>in <code>.vimrc</code> to avoid that arrow keys display A, B, C, D in insert mode.</p>
<p>But I'm using vi <em>Version 4.0 (gritter) 12/25/06</em>.</p>
<p>How can I obtain the same behavior? </p>
<p><strong>== EDIT == (1)</strong></p... | [
{
"answer_id": 7541,
"author": "jecxjo",
"author_id": 895,
"author_profile": "https://vi.stackexchange.com/users/895",
"pm_score": 2,
"selected": false,
"text": "<p>You could create an alias that sets your <code>$TERM</code> variable</p>\n\n<pre><code>alias vi='TERM=rxvt-unicode-256color... | 2015/10/15 | [
"https://vi.stackexchange.com/questions/5123",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4926/"
] | I know that in vim I can add
```
set nocompatible
```
in `.vimrc` to avoid that arrow keys display A, B, C, D in insert mode.
But I'm using vi *Version 4.0 (gritter) 12/25/06*.
How can I obtain the same behavior?
**== EDIT == (1)**
I'm using the [vi version from Arch Linux](https://www.archlinux.org/packages/c... | You could create an alias that sets your `$TERM` variable
```
alias vi='TERM=rxvt-unicode-256color vi'
```
Add that to your shell's rc file and it should be defined for every terminal you launch. |
5,128 | <p>I use <code>set matchpairs+=<:></code> in my config (to help when editing HTML, for instance), but I just noticed it made vim very slow when editing emails.</p>
<p>Is there a way to have this setting without paying a performance penalty? (e.g., automatically disabling it in cases like emails when it's obvious... | [
{
"answer_id": 5131,
"author": "fruglemonkey",
"author_id": 4932,
"author_profile": "https://vi.stackexchange.com/users/4932",
"pm_score": 3,
"selected": false,
"text": "<p>If your emails have a particular file type, you could use <code>BufRead</code> or <code>BufNewFile</code> or <code>... | 2015/10/15 | [
"https://vi.stackexchange.com/questions/5128",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4819/"
] | I use `set matchpairs+=<:>` in my config (to help when editing HTML, for instance), but I just noticed it made vim very slow when editing emails.
Is there a way to have this setting without paying a performance penalty? (e.g., automatically disabling it in cases like emails when it's obviously not relevant to see the ... | The slowness of delimiter matching is not caused by vim itself but by the [matchparen plugin](https://github.com/vim/vim/blob/master/runtime/plugin/matchparen.vim), which is part of the vim distribution and loaded by default in `/etc/vim/vimrc` in Debian. (This is why I still had the problem without a vimrc.)
Fortunat... |
5,132 | <p>I have no idea how swap files are formatted, but I'm wondering if the information in them can be directly examined somehow.</p>
<p>I notice that trying to do this indirectly, by creating an empty file with the same name and/or path and loading it, works, which implies the entire content of the original is in the sw... | [
{
"answer_id": 5160,
"author": "Wildcard",
"author_id": 4676,
"author_profile": "https://vi.stackexchange.com/users/4676",
"pm_score": 1,
"selected": false,
"text": "<p>You can directly examine the actual bit-level file contents of any file using <code>hexdump -C</code>.</p>\n\n<p>The <c... | 2015/10/16 | [
"https://vi.stackexchange.com/questions/5132",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4913/"
] | I have no idea how swap files are formatted, but I'm wondering if the information in them can be directly examined somehow.
I notice that trying to do this indirectly, by creating an empty file with the same name and/or path and loading it, works, which implies the entire content of the original is in the swap.
Accor... | You can find information about the format from [the source](https://github.com/vim/vim/blob/cb86893114ce33dc9c7bd4ff992b05c12406b35d/src/memline.c).
>
> NB! Swapfiles are *“binary”* files with for example fixed offsets for various data. For example at byte number N in the file it expect to find specific data. In othe... |
5,146 | <p>I'd like to append a custom string at the end of the file.</p>
<p>For example using <code>:read</code> command this works: </p>
<pre><code>:$r !echo my string
</code></pre>
<p>however is there any more portable way of doing that (without executing external program)?</p>
<p>I've tried:</p>
<pre><code>:$r "my str... | [
{
"answer_id": 5149,
"author": "romainl",
"author_id": 54,
"author_profile": "https://vi.stackexchange.com/users/54",
"pm_score": 4,
"selected": true,
"text": "<p>Yes, you can use <code>:put</code>:</p>\n\n<pre><code>:$put='my string'\n</code></pre>\n\n<p>See <code>:help :put</code>.</p>... | 2015/10/17 | [
"https://vi.stackexchange.com/questions/5146",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/467/"
] | I'd like to append a custom string at the end of the file.
For example using `:read` command this works:
```
:$r !echo my string
```
however is there any more portable way of doing that (without executing external program)?
I've tried:
```
:$r "my string"
```
but it's just duplicating content of my file (the s... | Yes, you can use `:put`:
```
:$put='my string'
```
See `:help :put`. |
5,154 | <p>I dislike the default way vim open the help window. I just want to open the help window vertically. </p>
<p>So I want to remap the <code>help</code> command to <code>vert help</code>. </p>
<p>What I put in vimrc is:</p>
<pre><code>:noremap h vert h
</code></pre>
<p>But it doesn't work.</p>
| [
{
"answer_id": 5155,
"author": "garyjohn",
"author_id": 2055,
"author_profile": "https://vi.stackexchange.com/users/2055",
"pm_score": 2,
"selected": false,
"text": "<p>The mapping you defined works in normal, visual and operator-pending modes and does not automatically change modes. Tha... | 2015/10/18 | [
"https://vi.stackexchange.com/questions/5154",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1276/"
] | I dislike the default way vim open the help window. I just want to open the help window vertically.
So I want to remap the `help` command to `vert help`.
What I put in vimrc is:
```
:noremap h vert h
```
But it doesn't work. | The mapping you defined works in normal, visual and operator-pending modes and does not automatically change modes. That is, when you type `h`, you effectively send to Vim the key sequence `vert h`, which enters visual mode (`v`), selects to the end of the current word (`e`), and replaces the visually-selected region (... |
5,158 | <p>I want to organize my vimrc better, so I want to put all the custom functions at bottom:</p>
<pre><code>"different setting between different os
if MyDetectOS() ==? "windows"
set rtp+=~/vimfiles/bundle/Vundle.vim/
let path='~/vimfiles/bundle'
else
set rtp+=~/.vim/bundle/Vundle.vim
endif
if MyDetectOS() ... | [
{
"answer_id": 5162,
"author": "Christian Brabandt",
"author_id": 71,
"author_profile": "https://vi.stackexchange.com/users/71",
"pm_score": 1,
"selected": false,
"text": "<p>The error says it all:</p>\n\n<p><code>E117: Unknown function: MyDetectOS</code></p>\n\n<p>You can't call a funct... | 2015/10/18 | [
"https://vi.stackexchange.com/questions/5158",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1276/"
] | I want to organize my vimrc better, so I want to put all the custom functions at bottom:
```
"different setting between different os
if MyDetectOS() ==? "windows"
set rtp+=~/vimfiles/bundle/Vundle.vim/
let path='~/vimfiles/bundle'
else
set rtp+=~/.vim/bundle/Vundle.vim
endif
if MyDetectOS() ==? "linux"
... | The way to understand this is that a function decleration is just an assignment, similar to `x = 2`.
So when you do:
```
function! MyDetectOS()
[...]
endfunction
```
You're really just doing:
```
MyDetectOS = function!
[...]
endfunction
```
So it doesn't work for the same reason that something like this ... |
5,175 | <p>Here is my use case:</p>
<p>I have lots of code which because of style enforcement we write newlines after and before each open and close brace (respectively). </p>
<p>Example: </p>
<pre><code>function func(args) {
statement 1;
statement 2;
if (condition) {
statement 3;
}
}
</code></... | [
{
"answer_id": 13889,
"author": "lonetwin",
"author_id": 11553,
"author_profile": "https://vi.stackexchange.com/users/11553",
"pm_score": 1,
"selected": false,
"text": "<p>First off, that's a shitty style enforcement and you have my sympathies. Instead of <em>hiding</em> how about creati... | 2015/10/19 | [
"https://vi.stackexchange.com/questions/5175",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/390/"
] | Here is my use case:
I have lots of code which because of style enforcement we write newlines after and before each open and close brace (respectively).
Example:
```
function func(args) {
statement 1;
statement 2;
if (condition) {
statement 3;
}
}
```
While this is nice and easy to ... | It is possible to abuse folds to hide extra empty lines. Here is how one could do it:
```
function! SkipNewlineFoldExpr()
let l:curline = getline(v:lnum)
" fold begins at {$ or one line before }$
if l:curline[-1:] == '{' || getline(v:lnum + 1)[-1:] == '}'
return '>1'
endif
" fold ends one l... |
5,176 | <p>When I'm going through text and, for instance, adding backticks around certain words or quotes or whatever, it is irritating that I have to press Esc or Ctrl-[ after each insert. The inserts (and appends) are different, so <code>.</code> doesn't help much.</p>
<p>Is there anything similar to <code>r</code> that re... | [
{
"answer_id": 5177,
"author": "Qix - MONICA WAS MISTREATED",
"author_id": 3164,
"author_profile": "https://vi.stackexchange.com/users/3164",
"pm_score": 5,
"selected": true,
"text": "<p>If there isn't (I haven't looked), you can use this mapping in your <code>.vimrc</code>:</p>\n\n<pre>... | 2015/10/19 | [
"https://vi.stackexchange.com/questions/5176",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4676/"
] | When I'm going through text and, for instance, adding backticks around certain words or quotes or whatever, it is irritating that I have to press Esc or Ctrl-[ after each insert. The inserts (and appends) are different, so `.` doesn't help much.
Is there anything similar to `r` that returns to normal mode after a sing... | If there isn't (I haven't looked), you can use this mapping in your `.vimrc`:
```
nnoremap <C-I> i <ESC>r
```
It `i`nserts, places a space, `ESC`apes, and starts a single letter `r`eplace. This gets mapped to `Ctrl``I`.
It's a hack, and will leave a hanging space if you hit escape before you type a letter - but it'... |
5,188 | <p>I want all of my files ending in <code>.tex</code> to have line length 80. So whenever I open a <code>.tex</code> file in vim I type <code>:set tw=79</code>. What would I put in my .vimrc to automate this?</p>
<p>What if I wanted it to work with a specific list of filetypes, say, <code>.md</code>, <code>.txt</code>... | [
{
"answer_id": 5189,
"author": "ap0",
"author_id": 4413,
"author_profile": "https://vi.stackexchange.com/users/4413",
"pm_score": 5,
"selected": true,
"text": "<p>Instead of checking the extension and setting the textwidth accordingly you could simply create a <code>tex.vim</code> (the n... | 2015/10/19 | [
"https://vi.stackexchange.com/questions/5188",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4960/"
] | I want all of my files ending in `.tex` to have line length 80. So whenever I open a `.tex` file in vim I type `:set tw=79`. What would I put in my .vimrc to automate this?
What if I wanted it to work with a specific list of filetypes, say, `.md`, `.txt`, and `.tex`? | Instead of checking the extension and setting the textwidth accordingly you could simply create a `tex.vim` (the name must match the filetype) file in `.vim/ftplugin/` or for Windows `$HOME/vimfiles/ftplugin/` and set textwidth there. This will help you to keep your .vimrc clean.
Your `.vim/ftplugin/tex.vim` file woul... |
5,196 | <p>I am relatively new to using <code>vim</code>. I have to admit it is a powerful tool, however it can be very frustrating if one doesn't learn how to use it.</p>
<p>Whatever, there is one or two things that annoy me terribly:</p>
<ol>
<li><p>How can I get to the end of the previous line/start of the next one?</p>
... | [
{
"answer_id": 5198,
"author": "ap0",
"author_id": 4413,
"author_profile": "https://vi.stackexchange.com/users/4413",
"pm_score": 1,
"selected": false,
"text": "<p>Simple solution (by simple I mean no fancy mappings or similar). </p>\n\n<p><strong>For <code>1</code></strong> are the comb... | 2015/10/20 | [
"https://vi.stackexchange.com/questions/5196",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4972/"
] | I am relatively new to using `vim`. I have to admit it is a powerful tool, however it can be very frustrating if one doesn't learn how to use it.
Whatever, there is one or two things that annoy me terribly:
1. How can I get to the end of the previous line/start of the next one?
Assume I have this text file:
```
abc... | You can use the `whichwrap` setting to change this behaviour. Try `:set whichwrap+=<,>,h,l` to allow the left and right arrow keys and `h` and `l` to wrap. See `:help whichwrap` for more options. |
5,201 | <p>I edit C++ code in <code>.cpp</code> files, while template code goes into <code>.tcc</code> files. When I open such a file, no syntax highlighting is available. I tried <code>set syntax=cpp</code> in a a <code>tpp.vim</code> file in <code>~/.vim/ftplugin/</code>, but it does not do anything, while in the editor it w... | [
{
"answer_id": 5202,
"author": "edi9999",
"author_id": 1543,
"author_profile": "https://vi.stackexchange.com/users/1543",
"pm_score": 5,
"selected": false,
"text": "<p>You could do (in your global <code>.vimrc</code>): </p>\n\n<pre><code>autocmd BufEnter *.tpp :setlocal filetype=cpp\n</c... | 2015/10/20 | [
"https://vi.stackexchange.com/questions/5201",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1066/"
] | I edit C++ code in `.cpp` files, while template code goes into `.tcc` files. When I open such a file, no syntax highlighting is available. I tried `set syntax=cpp` in a a `tpp.vim` file in `~/.vim/ftplugin/`, but it does not do anything, while in the editor it works. Is there some way to have vim treat specific extensi... | The preferred approach is to create a `~/.vim/filetype.vim`, as mentioned in `:help 43.2` and explained in [Vim FAQ 26.8](http://vimhelp.appspot.com/vim_faq.txt.html#faq-26.8):
>
> A better alternative to the above approach is to create a filetype.vim
> file in the ~/.vim directory (or in one of the directories spec... |
5,205 | <p>How does one search for a pattern in ex command output? For example, how to search for a file name pattern in the output of <code>:scriptnames</code> command? In the help for all flavours of <code>grep</code> and <code>vimgrep</code> there is only <code>{file}</code> as a place where to perform search.</p>
| [
{
"answer_id": 5207,
"author": "romainl",
"author_id": 54,
"author_profile": "https://vi.stackexchange.com/users/54",
"pm_score": 3,
"selected": false,
"text": "<p>First, you need to grab the output of <code>scriptnames</code> and put it into a buffer.</p>\n\n<p>You can use <code>:redir<... | 2015/10/20 | [
"https://vi.stackexchange.com/questions/5205",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1378/"
] | How does one search for a pattern in ex command output? For example, how to search for a file name pattern in the output of `:scriptnames` command? In the help for all flavours of `grep` and `vimgrep` there is only `{file}` as a place where to perform search. | You could do:
`:redir => scriptn | sil exe 'scriptnames' | redir end | echo(system('grep pattern',scriptn))`
What it does:
```
:redir => scriptn "redirect following output to variable scriptn
:sil exe 'scriptnames' "silently execute scriptnames
:redir end ... |
5,225 | <p>I'm using console vim within a tmux window, therefore occasionally vim doesn't recognize that files have been modified (gvim does it on a focus change AFAIK) and in order to avoid getting inconsistent buffers, I manually ask vim to reload them all using</p>
<pre><code>:bufdo :e
</code></pre>
<p>However, after this... | [
{
"answer_id": 5226,
"author": "mMontu",
"author_id": 1405,
"author_profile": "https://vi.stackexchange.com/users/1405",
"pm_score": 4,
"selected": true,
"text": "<p>What you are experiencing seems to be a feature. From <code>:help bufdo</code>:</p>\n\n<pre><code> Note: While this com... | 2015/10/22 | [
"https://vi.stackexchange.com/questions/5225",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/5005/"
] | I'm using console vim within a tmux window, therefore occasionally vim doesn't recognize that files have been modified (gvim does it on a focus change AFAIK) and in order to avoid getting inconsistent buffers, I manually ask vim to reload them all using
```
:bufdo :e
```
However, after this syntax highlighting is lo... | What you are experiencing seems to be a feature. From `:help bufdo`:
```
Note: While this command is executing, the Syntax
autocommand event is disabled by adding it to
'eventignore'. This considerably speeds up editing
each buffer.
```
Nevertheless, you probably should focus on which settings you a... |
5,228 | <p>I edit quite a few BibTeX files, and I regularly forget the trailing commas: </p>
<p>For example: </p>
<pre><code>@Book{cooke2015british,
author = {Cooke, Lez},
title = {British Television Drama},
publisher = {Palgrave on behalf of the British Film Institute},
year = {2015},
keywords = {about}
address = {Lon... | [
{
"answer_id": 5235,
"author": "Vitor",
"author_id": 599,
"author_profile": "https://vi.stackexchange.com/users/599",
"pm_score": 4,
"selected": true,
"text": "<p>Quick and dirty solution:</p>\n\n<pre><code>:match Error /^\\s\\+.*,\\@<!\\ze\\n\\s\\+\\w/\n</code></pre>\n\n<p>You could ... | 2015/10/22 | [
"https://vi.stackexchange.com/questions/5228",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/5007/"
] | I edit quite a few BibTeX files, and I regularly forget the trailing commas:
For example:
```
@Book{cooke2015british,
author = {Cooke, Lez},
title = {British Television Drama},
publisher = {Palgrave on behalf of the British Film Institute},
year = {2015},
keywords = {about}
address = {London},
isbn = {978-18... | Quick and dirty solution:
```
:match Error /^\s\+.*,\@<!\ze\n\s\+\w/
```
You could also create a special syntax for BibTeX files using the same pattern.
Some explanations on the used regular expression:
1. `^\s\+` searches for indented keywords.
2. `\ze` stops the pattern matching such that the next line is not ma... |
5,233 | <p>I want ctrl-h, ctrl-j, ctrl-k and ctrl-l in insert mode to behave like the arrow keys. I have this (among other things) in my <code>.vimrc</code>:</p>
<pre><code>inoremap <C-j> <Down>
inoremap <C-k> <Up>
inoremap <C-h> <Left>
inoremap <C-l> <Right>
</code></pre>
<... | [
{
"answer_id": 5242,
"author": "Amir H. Sadoughi",
"author_id": 947,
"author_profile": "https://vi.stackexchange.com/users/947",
"pm_score": 1,
"selected": false,
"text": "<p>Look at this: <a href=\"https://stackoverflow.com/questions/9092982/mapping-c-j-to-something-in-vim\">https://sta... | 2015/10/22 | [
"https://vi.stackexchange.com/questions/5233",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/2920/"
] | I want ctrl-h, ctrl-j, ctrl-k and ctrl-l in insert mode to behave like the arrow keys. I have this (among other things) in my `.vimrc`:
```
inoremap <C-j> <Down>
inoremap <C-k> <Up>
inoremap <C-h> <Left>
inoremap <C-l> <Right>
```
Now, everything works fine except for ctrl-j. When I press ctrl-j, it will add in a... | Due to legacy reasons, vim generally treats key events as a terminal emulator would treat them, even in "GUI" versions (e.g. gvim). A terminal emulator would produce e.g. the byte 0x08 for `Ctrl-H`, which is why the byte is sometimes printed as `^H`. The characters `@` to `_` in the ASCII table (covering the uppercase ... |
5,239 | <p>I know that I can delete from the cursor till and including the first occurence of a character <i>x</i> with <code>dfx</code>. This only works on one line. How can I delete from the current cursor position till the first occurence of <i>x</i> when <i>x</i> is not in the same line?</p>
<p>E.g., if the cursor is after... | [
{
"answer_id": 5240,
"author": "romainl",
"author_id": 54,
"author_profile": "https://vi.stackexchange.com/users/54",
"pm_score": 6,
"selected": true,
"text": "<p>Use <code>/</code> for forward search:</p>\n\n<pre><code>d/x<CR>\n</code></pre>\n\n<p>and <code>?</code> for backward s... | 2015/10/22 | [
"https://vi.stackexchange.com/questions/5239",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/5011/"
] | I know that I can delete from the cursor till and including the first occurence of a character *x* with `dfx`. This only works on one line. How can I delete from the current cursor position till the first occurence of *x* when *x* is not in the same line?
E.g., if the cursor is after the first space in
>
> yada yada... | Use `/` for forward search:
```
d/x<CR>
```
and `?` for backward search:
```
d?x<CR>
``` |
5,259 | <p>Given the following files with two trailing spaces at the end:</p>
<pre><code>$ echo "test1 " > test1.txt; echo "test2 " > test2.txt; echo "test3 " > test3.txt
$ hexdump -C *.txt
00000000 74 65 73 74 31 20 20 0a 74 65 73 74 32 20 20 0a |test1 .test2 .|
00000010 74 65 73 74 33 20 20 0a ... | [
{
"answer_id": 5260,
"author": "Christian Brabandt",
"author_id": 71,
"author_profile": "https://vi.stackexchange.com/users/71",
"pm_score": 3,
"selected": true,
"text": "<p>When using <code>:argdo</code> Vim executes the command and then loads the next buffer. By default, it will theref... | 2015/10/25 | [
"https://vi.stackexchange.com/questions/5259",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/467/"
] | Given the following files with two trailing spaces at the end:
```
$ echo "test1 " > test1.txt; echo "test2 " > test2.txt; echo "test3 " > test3.txt
$ hexdump -C *.txt
00000000 74 65 73 74 31 20 20 0a 74 65 73 74 32 20 20 0a |test1 .test2 .|
00000010 74 65 73 74 33 20 20 0a |test3 .... | When using `:argdo` Vim executes the command and then loads the next buffer. By default, it will therefore unload the current buffer before moving to the next buffer and if the current buffer is modified, it will abort the changes (without the '!' attribute, the argdo will then simply fail).
This means that after you... |
5,265 | <p>For testing purposes I've opened the following file:</p>
<pre><code>vim http://example.com/
</code></pre>
<p>And I'm using the following command to delete a highlighted multi-line pattern:</p>
<pre><code>:/<body\_.\{-}body>/d
</code></pre>
<p>which matches multiple lines, but only removes for the first lin... | [
{
"answer_id": 5266,
"author": "Peter Lewerin",
"author_id": 2942,
"author_profile": "https://vi.stackexchange.com/users/2942",
"pm_score": 5,
"selected": true,
"text": "<p>The feasibility of deleting parts of lines is elusive and a better vimmer than I will have to explain that. If anyo... | 2015/10/25 | [
"https://vi.stackexchange.com/questions/5265",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/467/"
] | For testing purposes I've opened the following file:
```
vim http://example.com/
```
And I'm using the following command to delete a highlighted multi-line pattern:
```
:/<body\_.\{-}body>/d
```
which matches multiple lines, but only removes for the first line.
As for workaround (for this particular case) it wor... | The feasibility of deleting parts of lines is elusive and a better vimmer than I will have to explain that. If anyone cares to donate an explanation I'd be happy to add it to this answer.
But it's quite possible to delete groups of rows that match a beginning pattern and an ending pattern. The most obvious way, I thin... |
5,271 | <p>An example (The <code>^</code> is the cursor position):</p>
<p><strong>Before:</strong></p>
<pre><code>a bc def ghi
j k l mn o p q rs
^
</code></pre>
<p><strong>After:</strong></p>
<pre><code>a bc def ghimn o p q rs
^
</code></pre>
<p><strong>or at least:</strong></p>
<pre><code>a bc def ghim... | [
{
"answer_id": 5274,
"author": "VanLaser",
"author_id": 1800,
"author_profile": "https://vi.stackexchange.com/users/1800",
"pm_score": 4,
"selected": false,
"text": "<p>Well, you can combine the \"backward search\" motion and the <code>delete</code> operator:</p>\n\n<pre><code>d?$<Ent... | 2015/10/26 | [
"https://vi.stackexchange.com/questions/5271",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/5010/"
] | An example (The `^` is the cursor position):
**Before:**
```
a bc def ghi
j k l mn o p q rs
^
```
**After:**
```
a bc def ghimn o p q rs
^
```
**or at least:**
```
a bc def ghimn o p q rs
^
```
I know I can use `d0i<BS>`, but I want a faster way to do this and I want to remain in ... | Try `d0kJx`
Deletes backwards to the beginning of the line, moves up, then joins the two lines and then removes the space in between the two joined lines.
You don't have to leave normal mode with this. |
5,273 | <p>Fully realizing the heritage of <code>vi</code>, I know that its predecessor (<code>ex</code>) could be, and was, used for command line processing of files ("sed-style", if you like).</p>
<p>The manpage says:</p>
<blockquote>
<p><code>-c</code> {command}</p>
<p>{command} will be executed after the first fil... | [
{
"answer_id": 5275,
"author": "Martin Tournoij",
"author_id": 51,
"author_profile": "https://vi.stackexchange.com/users/51",
"pm_score": 4,
"selected": true,
"text": "<p>An \"ex command\" means anything that you type in the commandline after the <code>:</code>, such as <code>:write</cod... | 2015/10/26 | [
"https://vi.stackexchange.com/questions/5273",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1726/"
] | Fully realizing the heritage of `vi`, I know that its predecessor (`ex`) could be, and was, used for command line processing of files ("sed-style", if you like).
The manpage says:
>
> `-c` {command}
>
>
> {command} will be executed after the first file has been read. {command} is interpreted as an Ex command. If t... | An "ex command" means anything that you type in the commandline after the `:`, such as `:write`, it doesn't really have anything to do with "ex mode", as such. ex mode is a "mode" where you only have the commandline, and not the graphical editor ("vi" stands for "visual ex mode").
So it's really as simple as:
```
vim... |
5,276 | <p>I would like to find multiple files and open them all in tabs within the same vim instance.</p>
| [
{
"answer_id": 5277,
"author": "andorov",
"author_id": 4761,
"author_profile": "https://vi.stackexchange.com/users/4761",
"pm_score": 3,
"selected": false,
"text": "<pre><code>find \"$PWD\" -name '*.txt' -exec vim -p {} +\n</code></pre>\n"
},
{
"answer_id": 5278,
"author": "N... | 2015/10/03 | [
"https://vi.stackexchange.com/questions/5276",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4761/"
] | I would like to find multiple files and open them all in tabs within the same vim instance. | ```
vim -p `find . -name '*.txt'`
```
Putting the `find` command between backticks executes `find` before running the full command and the results replace what's between the backticks. So before running the full command it will have this form `vim -p result1 result2 ... resultN` . |
5,279 | <p>There are various <a href="https://vi.stackexchange.com/questions/2954/how-do-i-disable-syntastic-for-python-files">questions</a> <a href="https://stackoverflow.com/questions/20030603/vim-syntastic-how-to-disable-the-checker">and</a> <a href="https://stackoverflow.com/questions/31818109/how-to-selectively-disable-ch... | [
{
"answer_id": 5284,
"author": "ap0",
"author_id": 4413,
"author_profile": "https://vi.stackexchange.com/users/4413",
"pm_score": 1,
"selected": false,
"text": "<p>You could disable syntax checking for a specific filetype by overriding the default checker and tell him to use none.</p>\n\... | 2015/10/26 | [
"https://vi.stackexchange.com/questions/5279",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/5057/"
] | There are various [questions](https://vi.stackexchange.com/questions/2954/how-do-i-disable-syntastic-for-python-files) [and](https://stackoverflow.com/questions/20030603/vim-syntastic-how-to-disable-the-checker) [answers](https://stackoverflow.com/questions/31818109/how-to-selectively-disable-checkers-for-certain-file-... | From the [syntastic docs](https://github.com/scrooloose/syntastic/blob/1926693d1bcf786a526ff0980bc120ab4bad0dee/doc/syntastic.txt#L480-L513):
>
>
> ```
> 'syntastic_mode_map'
> Default: { "mode": "active",
> "active_filetypes": [],
> "passi... |
5,286 | <p>I want to make block commenting easy. To comment out a range of lines, what I can do is something like: <code>:17,21s/^/#</code> This will comment lines 17 to 21 in Python. But I don't want to write the whole string search and replacement pattern all the time.</p>
<p>Initially I thought of making a parameterized ma... | [
{
"answer_id": 5301,
"author": "fruglemonkey",
"author_id": 4932,
"author_profile": "https://vi.stackexchange.com/users/4932",
"pm_score": 2,
"selected": true,
"text": "<blockquote>\n <p>Now doing something like :17,21Co will achieve the task and I can do :17,21Co// (for adding // inste... | 2015/10/27 | [
"https://vi.stackexchange.com/questions/5286",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/5019/"
] | I want to make block commenting easy. To comment out a range of lines, what I can do is something like: `:17,21s/^/#` This will comment lines 17 to 21 in Python. But I don't want to write the whole string search and replacement pattern all the time.
Initially I thought of making a parameterized mapping for this, where... | >
> Now doing something like :17,21Co will achieve the task and I can do :17,21Co// (for adding // instead of default #)
>
>
>
tpope's commentary does this, just tab-expand the command into `:17,21Commentary`. It'll autodetect filetypes so you don't have to worry about passing `#` or `//`. It wont comment blank li... |
5,290 | <p>I had <code>vim</code> open in a terminal; I needed to check some other things so I typed Ctrl-Z. When I later type <code>fg</code>, it just stopped again:</p>
<pre><code>myprompt$ fg
vim newfile path/to/existingfile
[1]+ Stopped vim newfile path/to/existingfile
[1]+ Stopped vim... | [
{
"answer_id": 5291,
"author": "Wildcard",
"author_id": 4676,
"author_profile": "https://vi.stackexchange.com/users/4676",
"pm_score": 2,
"selected": false,
"text": "<p>Okay, I handled it via <code>kill %1</code>, then <code>vim</code> and then within vim, <code>:recover newfile</code>. ... | 2015/10/27 | [
"https://vi.stackexchange.com/questions/5290",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4676/"
] | I had `vim` open in a terminal; I needed to check some other things so I typed Ctrl-Z. When I later type `fg`, it just stopped again:
```
myprompt$ fg
vim newfile path/to/existingfile
[1]+ Stopped vim newfile path/to/existingfile
[1]+ Stopped vim newfile path/to/existingfile
mypromp... | Okay, I handled it via `kill %1`, then `vim` and then within vim, `:recover newfile`. Still don't know why it happened but I'm very happy there was a way to recover the file!
The swap file hung around and made vim complain next time I opened the file, so I just removed the swapfile after the file was recovered properl... |
5,293 | <p>I am a big fan of text objects, and I like their composability. For example, if I have</p>
<pre><code>\label{sec:this-is-a-section}
</code></pre>
<p>I can easily copy the <code>sec:this-is-a-section</code> part by navigating inside, and pressing <code>yi}</code> and use this, for example, to paste it after a <code... | [
{
"answer_id": 5294,
"author": "Sato Katsura",
"author_id": 2313,
"author_profile": "https://vi.stackexchange.com/users/2313",
"pm_score": 2,
"selected": false,
"text": "<p>The <a href=\"https://github.com/nelstrom/vim-visual-star-search\" rel=\"nofollow\">visual-star-search</a> plugin c... | 2015/10/28 | [
"https://vi.stackexchange.com/questions/5293",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1937/"
] | I am a big fan of text objects, and I like their composability. For example, if I have
```
\label{sec:this-is-a-section}
```
I can easily copy the `sec:this-is-a-section` part by navigating inside, and pressing `yi}` and use this, for example, to paste it after a `\ref{` somewhere else.
What I am missing is a good ... | Pasting in commandline-mode from a register is done via `<C-r>`(see `:h <C-r>`, this also works in insert mode). So you could simply yank your text object, be it via `yi}` or visual selection, and then type `/<C-r>"<Enter>` to search for it. |
5,298 | <p>I’m exploring Vim’s capabilities and somehow stumbled upon this task. It’s constructed, but I’m curious:
Is there a one-liner colon command that can </p>
<ol>
<li>find the first line that matches a pattern p (say, begins with „bla“)</li>
<li>find the first line after this line that doesn’t match p and</li>
<li>move... | [
{
"answer_id": 5302,
"author": "Karl Yngve Lervåg",
"author_id": 21,
"author_profile": "https://vi.stackexchange.com/users/21",
"pm_score": 2,
"selected": false,
"text": "<p>You can do something like this:</p>\n\n<pre><code>:/^bla/,/^\\(bla\\)\\@!/;4,5 m .\n</code></pre>\n\n<p>Here <code... | 2015/10/28 | [
"https://vi.stackexchange.com/questions/5298",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/5089/"
] | I’m exploring Vim’s capabilities and somehow stumbled upon this task. It’s constructed, but I’m curious:
Is there a one-liner colon command that can
1. find the first line that matches a pattern p (say, begins with „bla“)
2. find the first line after this line that doesn’t match p and
3. move lines 4-5 after the line... | Use the following syntax:
```
:/\(bla[^\n]*\)\+\zs/;4,5m.
```
which finds multiple (`+`) occurrences of `bla` followed by new line characters (`[^\n]`), then place the cursor (`;`) where we set our start of match (`\zs`) and move our range of lines (`4,5`) at the current cursor position. See: `:help :/`.
To insert ... |
5,310 | <p>When I am in a CSS file with a blank line, like this:</p>
<p><a href="https://i.stack.imgur.com/pZ6pk.png" rel="noreferrer"><img src="https://i.stack.imgur.com/pZ6pk.png" alt="enter image description here"></a></p>
<p>and I want to simply make a new line and move down to it, by hitting <kbd>Enter</kbd> , vim is au... | [
{
"answer_id": 5311,
"author": "the_velour_fog",
"author_id": 4603,
"author_profile": "https://vi.stackexchange.com/users/4603",
"pm_score": 4,
"selected": false,
"text": "<p>I found a couple of ways to solve the problem.</p>\n\n<h3>1. reload the buffer after running <code>:filetype inde... | 2015/10/30 | [
"https://vi.stackexchange.com/questions/5310",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4603/"
] | When I am in a CSS file with a blank line, like this:
[](https://i.stack.imgur.com/pZ6pk.png)
and I want to simply make a new line and move down to it, by hitting `Enter` , vim is auto inserting a tab character, e.g.
[![enter image description here... | I found a couple of ways to solve the problem.
### 1. reload the buffer after running `:filetype indent off`
Vim's docs (`:help :filetype-indent-off`) provided an explanation:
>
> You can disable `:filetype indent on` with:
>
>
>
> ```
> :filetype indent off
>
> ```
>
> This actually loads the file "indoff.vi... |
5,325 | <p>I came across this video about Vim. I would like to ask how can you create a presentation like in the video which seems to run inside Vim.</p>
<p>On some slides there are also real pictures displayed. Check 7:25 and 25:20 of the video.</p>
<p><a href="https://www.youtube.com/watch?v=MquaityA1SM" rel="nofollow">htt... | [
{
"answer_id": 5327,
"author": "cee",
"author_id": 5016,
"author_profile": "https://vi.stackexchange.com/users/5016",
"pm_score": 2,
"selected": false,
"text": "<p>I was watching that video yesterday and had basically the same question.<br>\nAs <code>Wildcard</code> already pointed out, ... | 2015/11/01 | [
"https://vi.stackexchange.com/questions/5325",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/5123/"
] | I came across this video about Vim. I would like to ask how can you create a presentation like in the video which seems to run inside Vim.
On some slides there are also real pictures displayed. Check 7:25 and 25:20 of the video.
<https://www.youtube.com/watch?v=MquaityA1SM>
Anyone knows how this is done?
Thanks! | I was watching that video yesterday and had basically the same question.
As `Wildcard` already pointed out, I am pretty sure that the images are not directly displayed in Vim.
What I did for my current presentation is just a little bash script that opens all markdown files (\*.md) in a separate tab. The script also... |
5,333 | <p>Is there a shortcut to move the Visual area as a whole?</p>
<p>For instance, after entering Visual mode linewise to make the next line selected.</p>
<p>Right now this is achieved by:</p>
<ul>
<li><kbd>V</kbd> Start Visual mode linewise</li>
<li><kbd>j</kbd> move one line down -> now 2 lines are selected</li>
<li>... | [
{
"answer_id": 5478,
"author": "Yekoof",
"author_id": 2498,
"author_profile": "https://vi.stackexchange.com/users/2498",
"pm_score": -1,
"selected": false,
"text": "<p>If you're amenable to a plugin, perhaps this is an option:</p>\n\n<p><a href=\"https://github.com/matze/vim-move\" rel=\... | 2015/11/02 | [
"https://vi.stackexchange.com/questions/5333",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1881/"
] | Is there a shortcut to move the Visual area as a whole?
For instance, after entering Visual mode linewise to make the next line selected.
Right now this is achieved by:
* `V` Start Visual mode linewise
* `j` move one line down -> now 2 lines are selected
* `o` select the other end
* `j` move that end one line down -... | You can create a mapping for this:
```
:vnoremap <C-j> jojo
:vnoremap <C-k> koko
```
In this case I mapped it in visual mode to `Ctrl+j` and `Ctrl+k` |
5,339 | <p>I have the following command in my vimrc:</p>
<pre><code>execute "set path+=".getcwd()."/**"
</code></pre>
<p>It works well if current working directory is like <code>/home/tamlok/my_work/</code>. However, if the directory contains spaces, such as <code>D:\Program Files\vim\</code>, vim will complain.</p>
<p>I su... | [
{
"answer_id": 5341,
"author": "EvergreenTree",
"author_id": 865,
"author_profile": "https://vi.stackexchange.com/users/865",
"pm_score": 5,
"selected": true,
"text": "<p>The function you are looking for is <code>fnameescape()</code>. It will escape all special characters in a given str... | 2015/11/04 | [
"https://vi.stackexchange.com/questions/5339",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4754/"
] | I have the following command in my vimrc:
```
execute "set path+=".getcwd()."/**"
```
It works well if current working directory is like `/home/tamlok/my_work/`. However, if the directory contains spaces, such as `D:\Program Files\vim\`, vim will complain.
I suppose that I can fix this using `substitute()` function... | The function you are looking for is `fnameescape()`. It will escape all special characters in a given string containing a path to a file to match the standard of the current operating system.
For more on this see `:help fnameescape()` |
5,354 | <p>Let's say I have a X11 server that's hanging, keeping me from saving the work from the XTerm Vim session that X11 server controls. (Not GVim, just regular Vim-in-XTerm.)</p>
<p>Is there a way that I could (from a different terminal) tell the running Vim process to "save all & exit" from the command line? By sen... | [
{
"answer_id": 5500,
"author": "muru",
"author_id": 205,
"author_profile": "https://vi.stackexchange.com/users/205",
"pm_score": 6,
"selected": true,
"text": "<p>Having recently run into this problem (via another way: Vim running on a remote server, and I'd forgotten screen), I decided t... | 2015/11/05 | [
"https://vi.stackexchange.com/questions/5354",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1726/"
] | Let's say I have a X11 server that's hanging, keeping me from saving the work from the XTerm Vim session that X11 server controls. (Not GVim, just regular Vim-in-XTerm.)
Is there a way that I could (from a different terminal) tell the running Vim process to "save all & exit" from the command line? By sending a signal,... | Having recently run into this problem (via another way: Vim running on a remote server, and I'd forgotten screen), I decided to hunt for a way.
The first idea was to look up the file descriptors used by Vim and try writing to it. Vim's fds point to the psedoterminal opened by the terminal emulator, naturally enough:
... |
5,362 | <p>I have a file that looks like this.</p>
<pre><code>Move to 230.00
Hold
Hold
Hold
Hold
Hold
Hold
Move to 00.00
Hold
Hold
Hold
Hold
Hold
FooBar
Hold
Spam
Hold
</code></pre>
<p>I would like it to look like this:</p>
<pre><code>Move to 230.00
Hold
Move to 00.00
Hold
FooBar
Hold
Spam
Hold
</code></pre>
<p>I'm ... | [
{
"answer_id": 5363,
"author": "Wildcard",
"author_id": 4676,
"author_profile": "https://vi.stackexchange.com/users/4676",
"pm_score": 3,
"selected": false,
"text": "<p>If you want to remove ALL adjacent identical lines, not just <code>Hold</code>, you can do it extremely easily with an ... | 2015/11/05 | [
"https://vi.stackexchange.com/questions/5362",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/2920/"
] | I have a file that looks like this.
```
Move to 230.00
Hold
Hold
Hold
Hold
Hold
Hold
Move to 00.00
Hold
Hold
Hold
Hold
Hold
FooBar
Hold
Spam
Hold
```
I would like it to look like this:
```
Move to 230.00
Hold
Move to 00.00
Hold
FooBar
Hold
Spam
Hold
```
I'm sure there must be a way that vim could quickly d... | I think the following command should work :
```
:%s/^\(.*\)\(\n\1\)\+$/\1/
```
Explanation :
We use the substitution command on the whole file to change `pattern` into `string` :
```
:%s/pattern/string/
```
Here `pattern` is `^\(.*\)\(\n\1\)\+$` and `string` is `\1`.
`pattern` can be broken down like this :
... |
5,371 | <p>I defined some highlights in the vimrc file and it works well in gvim. However after I <code>mksession</code> and sourced it back, I found that some (maybe all) of the custom highlights were lost and vim used the default settings of the colorscheme.<br>
The <code>sessionoptions</code> is <code>blank,buffers,curdir,f... | [
{
"answer_id": 5395,
"author": "saginaw",
"author_id": 4939,
"author_profile": "https://vi.stackexchange.com/users/4939",
"pm_score": 4,
"selected": true,
"text": "<p>Your last <a href=\"https://vi.stackexchange.com/questions/5371/vim-lost-custom-highlight-settings-after-recovering-from-... | 2015/11/06 | [
"https://vi.stackexchange.com/questions/5371",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4754/"
] | I defined some highlights in the vimrc file and it works well in gvim. However after I `mksession` and sourced it back, I found that some (maybe all) of the custom highlights were lost and vim used the default settings of the colorscheme.
The `sessionoptions` is `blank,buffers,curdir,folds,help,options,tabpages,wins... | Your last [comment](https://vi.stackexchange.com/questions/5371/vim-lost-custom-highlight-settings-after-recovering-from-sessions#comment8261_5371) says that your default colorscheme is sourced twice : once before your custom highlight groups, and once after.
The second time it's loaded, your custom highlight groups m... |
5,374 | <p>I am very new to Vim and this problem has stumped me.</p>
<p>I am using vim to delete all lines containing a certain word. I have tried saving the edited text with to a new file but it always contains the exact same lines as the original file. What command do I use to save my edited text to a new file and keep the ... | [
{
"answer_id": 5375,
"author": "saginaw",
"author_id": 4939,
"author_profile": "https://vi.stackexchange.com/users/4939",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not sure this is what you want, but let's say you've opened a file called foo, and after editing it you want to save... | 2015/11/06 | [
"https://vi.stackexchange.com/questions/5374",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/5199/"
] | I am very new to Vim and this problem has stumped me.
I am using vim to delete all lines containing a certain word. I have tried saving the edited text with to a new file but it always contains the exact same lines as the original file. What command do I use to save my edited text to a new file and keep the original f... | I'm not sure to understand your need.
If you only want to save lines filtered into a new file, you can play with
```
" equivalent to "grep the_word > the-filename"
:let @a =''
:v/the_word/y A
:call writefile(@a, 'the-filename')
```
However a more likely scenario is: if you do multiple edits, `:saveas` will permit t... |
5,383 | <p>I am a heavy user of the argument list and I always have the files which are important for my current task in it.</p>
<p>Now I started to use netrw more often to search through the files system.
But I can't find a way to add the files and to add it to the argument list.</p>
<p>So is it possible to <code>:arge</cod... | [
{
"answer_id": 5385,
"author": "romainl",
"author_id": 54,
"author_profile": "https://vi.stackexchange.com/users/54",
"pm_score": 3,
"selected": true,
"text": "<p>You can do the following:</p>\n\n<pre><code>c make the current netrw directory the current vim director... | 2015/11/06 | [
"https://vi.stackexchange.com/questions/5383",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/350/"
] | I am a heavy user of the argument list and I always have the files which are important for my current task in it.
Now I started to use netrw more often to search through the files system.
But I can't find a way to add the files and to add it to the argument list.
So is it possible to `:arge` a file from within netrw? | You can do the following:
```
c make the current netrw directory the current vim directory
:arge <C-r><C-f><CR> edit the file under the cursor
```
Adding this line to your `vimrc` should allow you to avoid the `c` step:
```
let g:netrw_keepdir = 0
``` |
5,388 | <p>When I write a German text containing something like <code>abücd</code> for instance and to a <code>dw</code> in front, it will only delete the <code>ab</code> since it does not interpret <code>ü</code> as a word character.</p>
<p>When I edit reStructuredText, I have</p>
<pre><code>iskeyword=38,42,43,45,47-58,60-6... | [
{
"answer_id": 5404,
"author": "Martin Tournoij",
"author_id": 51,
"author_profile": "https://vi.stackexchange.com/users/51",
"pm_score": 4,
"selected": true,
"text": "<p>The <code>@</code> character in <code>iskeyword</code> includes all characters for which <code>isalpha()</code> (C fu... | 2015/11/06 | [
"https://vi.stackexchange.com/questions/5388",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/5210/"
] | When I write a German text containing something like `abücd` for instance and to a `dw` in front, it will only delete the `ab` since it does not interpret `ü` as a word character.
When I edit reStructuredText, I have
```
iskeyword=38,42,43,45,47-58,60-62,64-90,97-122,_
```
That explains why the umlauts are not mark... | The `@` character in `iskeyword` includes all characters for which `isalpha()` (C function) is TRUE; in modern (last 20 years) libc implementations this also looks for unicode characters.
Your second `iskeyword` uses `97-122` (a-z) and `64-90` (A-Z), which doesn't include all the variants with the various diacritics (... |
5,390 | <p>I want to modify files with <code>vim</code> without changing the creation time stamps.</p>
<p>The docs doesn't seem to mention anything about such possibility.</p>
<p>I'd like to achieve this without turning off the swap/recover feature.</p>
<p>One alternative would be to store the time somewhere and then overwr... | [
{
"answer_id": 5391,
"author": "Sato Katsura",
"author_id": 2313,
"author_profile": "https://vi.stackexchange.com/users/2313",
"pm_score": 1,
"selected": false,
"text": "<p>What you want is not possible to implement in UNIX using standard userspace functions. The <code>ctime</code> of a... | 2015/11/06 | [
"https://vi.stackexchange.com/questions/5390",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4432/"
] | I want to modify files with `vim` without changing the creation time stamps.
The docs doesn't seem to mention anything about such possibility.
I'd like to achieve this without turning off the swap/recover feature.
One alternative would be to store the time somewhere and then overwrite it when exiting, I guess. | Sato's answer would be correct on a standard Unix-derivative, where `ctime` is often mistaken for creation time but is actually inode change time, and "preserving" it doesn't really make sense. However, I asked what OS the poster is using because Mac OS X maintains a separate create time that is an actual creation date... |
5,393 | <p>The only documentation for installing YCM seems to be for Vundle and I'm fairly new to vim-plug and plugins in general so I'm not sure how well it translates to vim-plug.</p>
| [
{
"answer_id": 5396,
"author": "warsong",
"author_id": 5214,
"author_profile": "https://vi.stackexchange.com/users/5214",
"pm_score": 2,
"selected": false,
"text": "<p>I managed to install it.</p>\n\n<p>What I did was install python for neovim using </p>\n\n<pre><code>pip install neovim\... | 2015/11/07 | [
"https://vi.stackexchange.com/questions/5393",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/5214/"
] | The only documentation for installing YCM seems to be for Vundle and I'm fairly new to vim-plug and plugins in general so I'm not sure how well it translates to vim-plug. | neovim version 0.1 has breaking changes. It uses directory `~/.config/nvim`
(On Mac OS X. Linux or Windows may use slightly different paths.)
If you want your neovim configuration independent of vim configuration,
you can rename `.nvimrc` to `~/.config/nvim/init.vim` (See the docs [here](https://neovim.io/doc/user/vi... |
5,398 | <p>I'm looking for a way to execute some code within a function conditionally depending on the presence of some text within the edited file. I found a way to do it which works but doesn't feel very "clean".</p>
<p>Here's what I have:</p>
<pre><code>function! foo()
(...)
let v:errmsg = 'ok'
execute "silent... | [
{
"answer_id": 5408,
"author": "EvergreenTree",
"author_id": 865,
"author_profile": "https://vi.stackexchange.com/users/865",
"pm_score": 4,
"selected": true,
"text": "<p>The function you are looking for is <code>search()</code>. This function will search starting at the cursor position... | 2015/11/07 | [
"https://vi.stackexchange.com/questions/5398",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/2058/"
] | I'm looking for a way to execute some code within a function conditionally depending on the presence of some text within the edited file. I found a way to do it which works but doesn't feel very "clean".
Here's what I have:
```
function! foo()
(...)
let v:errmsg = 'ok'
execute "silent! normal! :/" . l:pat... | The function you are looking for is `search()`. This function will search starting at the cursor position, and when a match is found its line number will be returned. If no match is found, 0 is returned. The `'ignorecase'`, `'smartcase'`, and `'magic'` options are used on the search pattern. Note that if you want to ch... |
5,401 | <p>I have two blocks of text and I want to merge them. However, the problem is that the blocks are not synchronous and I want to place one in front of the other completely. For example, suppose we have the following block of text:</p>
<pre><code>aaaaaaaa
aaaaaaaa
aaaaaaaa
aaaaaaaa
aaaaaaaa
</code></pre>
<p>and the fo... | [
{
"answer_id": 5405,
"author": "VanLaser",
"author_id": 1800,
"author_profile": "https://vi.stackexchange.com/users/1800",
"pm_score": 4,
"selected": true,
"text": "<p>Select all 'bbbb..' text using <code>Ctrl-V</code> (visual block selection mode), yank; then go to the last char of the ... | 2015/11/08 | [
"https://vi.stackexchange.com/questions/5401",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/5222/"
] | I have two blocks of text and I want to merge them. However, the problem is that the blocks are not synchronous and I want to place one in front of the other completely. For example, suppose we have the following block of text:
```
aaaaaaaa
aaaaaaaa
aaaaaaaa
aaaaaaaa
aaaaaaaa
```
and the following block:
```
bbbbbb... | Select all 'bbbb..' text using `Ctrl-V` (visual block selection mode), yank; then go to the last char of the first `aaaa...` string, hit `Ctrl-V` again; go down to the last `aaaa ...` string, while staying in the same column (so cursor is still on the last `a` character). You are still in block selection mode. Hit 'p' ... |
5,406 | <p>When I open a file with <code>.md</code> extension, the filetype is set to <code>markdown</code>, as expected. But the <code>ftplugin</code> for HTML is also loaded as I can see since I have some insert mode mappings in there to auto-insert html entities in place of umlauts. I opened <code>ftplugin/markdown.vim</cod... | [
{
"answer_id": 5407,
"author": "romainl",
"author_id": 54,
"author_profile": "https://vi.stackexchange.com/users/54",
"pm_score": 4,
"selected": true,
"text": "<p>Vim already comes with Markdown support so what happens is that you have two Markdown ftplugins doing the same thing. Since y... | 2015/11/08 | [
"https://vi.stackexchange.com/questions/5406",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1066/"
] | When I open a file with `.md` extension, the filetype is set to `markdown`, as expected. But the `ftplugin` for HTML is also loaded as I can see since I have some insert mode mappings in there to auto-insert html entities in place of umlauts. I opened `ftplugin/markdown.vim` and found this
```
" runtime! ftplugin/html... | Vim already comes with Markdown support so what happens is that you have two Markdown ftplugins doing the same thing. Since you "fixed" one (`~/.vim/ftplugin/markdown.vim`) without "fixing" the other (`$VIMRUNTIME/ftplugin/markdown.vim`), your fix is simply overridden by the built-in ftplugin.
If you insist on disabli... |
5,416 | <p>I installed both plugins using Pathogen, but they don't work together as it should be. That is, if I use TAB, I get SuperTab's completion (autocomplete what I have previously written) whereas if I use CTRL + SPACE I get Jedi's completion (everything from libs: classes, modules, etc).</p>
<p>In theory, if both plugi... | [
{
"answer_id": 5417,
"author": "Martin Tournoij",
"author_id": 51,
"author_profile": "https://vi.stackexchange.com/users/51",
"pm_score": 0,
"selected": false,
"text": "<p>The default for SuperTab is to use <code><C-p></code> completion, vim-jedi, however, starts with <code><C-S... | 2015/11/09 | [
"https://vi.stackexchange.com/questions/5416",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/-1/"
] | I installed both plugins using Pathogen, but they don't work together as it should be. That is, if I use TAB, I get SuperTab's completion (autocomplete what I have previously written) whereas if I use CTRL + SPACE I get Jedi's completion (everything from libs: classes, modules, etc).
In theory, if both plugins are ins... | As a simple solution, try adding this line to your vimrc:
```
let g:SuperTabDefaultCompletionType = "context"
```
This will result in the following behavior, which should be what you need in most cases:
```
/usr/l<tab> # will use filename completion
myvar.t<tab> # will use user completion if completefunc set, or
... |
5,418 | <p>I have a language which uses statement like</p>
<pre><code>WHILE ... DO
..
END_WHILE
</code></pre>
<p>I can do the following in the corresponding synthax file</p>
<pre><code>syn keyword LangKeys WHILE DO END_WHILE
syn region LangBlock start="WHILE" end="END_WHILE" fold transparent
</code></pre>
<p>which allows ... | [
{
"answer_id": 5417,
"author": "Martin Tournoij",
"author_id": 51,
"author_profile": "https://vi.stackexchange.com/users/51",
"pm_score": 0,
"selected": false,
"text": "<p>The default for SuperTab is to use <code><C-p></code> completion, vim-jedi, however, starts with <code><C-S... | 2015/11/09 | [
"https://vi.stackexchange.com/questions/5418",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/2170/"
] | I have a language which uses statement like
```
WHILE ... DO
..
END_WHILE
```
I can do the following in the corresponding synthax file
```
syn keyword LangKeys WHILE DO END_WHILE
syn region LangBlock start="WHILE" end="END_WHILE" fold transparent
```
which allows me to highlight correctly the different keywords ... | As a simple solution, try adding this line to your vimrc:
```
let g:SuperTabDefaultCompletionType = "context"
```
This will result in the following behavior, which should be what you need in most cases:
```
/usr/l<tab> # will use filename completion
myvar.t<tab> # will use user completion if completefunc set, or
... |
5,425 | <p>Is it possible to pipe an unsaved buffer to an external command and then replace the buffer by the command’s output? </p>
| [
{
"answer_id": 5426,
"author": "Christian Brabandt",
"author_id": 71,
"author_profile": "https://vi.stackexchange.com/users/71",
"pm_score": 1,
"selected": false,
"text": "<p>Yes that should be possible. One possibility: the <code>system()</code> function takes as optional argument the i... | 2015/11/09 | [
"https://vi.stackexchange.com/questions/5425",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4505/"
] | Is it possible to pipe an unsaved buffer to an external command and then replace the buffer by the command’s output? | You can use the "filter" command,`:!`, which like most commands can be prefixed with a range:
```
:{range}!cmd
```
If you prefix this with a range, it will pipe those lines to the command's stdin, and replace those lines with the program's output. In this case you want to use `%` as the range, which means the entire... |
5,436 | <p>I am editing a .sql file in Vim:</p>
<pre><code>INSERT INTO apps_forms (app_id, form_id) VALUES
(1, 1),
</code></pre>
<p>What I'm looking to do is yank the <code>(1, 1),</code> line and paste it 137 times; however, I want the <em>second</em> number in parenthesis to be incremented each time. The output would look ... | [
{
"answer_id": 5437,
"author": "saginaw",
"author_id": 4939,
"author_profile": "https://vi.stackexchange.com/users/4939",
"pm_score": 5,
"selected": true,
"text": "<p>Put your cursor on the <code>(1, 1),</code> line then type :</p>\n\n<pre><code>qaVypt)<C-a>q135@a\n</code></pre>\n\... | 2015/11/10 | [
"https://vi.stackexchange.com/questions/5436",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/5251/"
] | I am editing a .sql file in Vim:
```
INSERT INTO apps_forms (app_id, form_id) VALUES
(1, 1),
```
What I'm looking to do is yank the `(1, 1),` line and paste it 137 times; however, I want the *second* number in parenthesis to be incremented each time. The output would look like:
```
INSERT INTO apps_forms (app_id, f... | Put your cursor on the `(1, 1),` line then type :
```
qaVypt)<C-a>q135@a
```
Explanation :
`qa` begins the recording of a macro inside the register **a** (you could choose another letter).
`Vyp` duplicates the current line, by selecting the whole line (V), copying it (y) and then pasting it below (p).
`t)` move... |
5,439 | <p>When my cursor is on a URL that ends with a trailing slash, for example : <code>http://www.google.com/</code></p>
<p>... if I type <code>gx</code> to open the link in my browser, curl is also called to download the webpage and the html code is displayed in a new buffer whose name is the URL ("<a href="http://www.go... | [
{
"answer_id": 5556,
"author": "user21497",
"author_id": 2377,
"author_profile": "https://vi.stackexchange.com/users/2377",
"pm_score": 3,
"selected": true,
"text": "<p>Try netrw v155d ; it won't treat the url ending with a \"/\" as a file to be obtained. You can get it from <a href=\"h... | 2015/11/11 | [
"https://vi.stackexchange.com/questions/5439",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4939/"
] | When my cursor is on a URL that ends with a trailing slash, for example : `http://www.google.com/`
... if I type `gx` to open the link in my browser, curl is also called to download the webpage and the html code is displayed in a new buffer whose name is the URL ("<http://www.google.com>").
Is there a way to tell vim... | Try netrw v155d ; it won't treat the url ending with a "/" as a file to be obtained. You can get it from <http://www.drchip.org/astronaut/vim/index.html#NETRW> . |
5,441 | <p>As per the title, is it possible to split the <code>vimrc</code> file in several sub-files? Keep separate files for groups of settings that concern one <strong><em>thing</em></strong>? This <em>thing</em> might be anything, any kind of user-defined group of settings. For example,</p>
<p><strong>[updated]</strong>... | [
{
"answer_id": 5443,
"author": "Christian Brabandt",
"author_id": 71,
"author_profile": "https://vi.stackexchange.com/users/71",
"pm_score": 6,
"selected": true,
"text": "<p>Yes this is possible and useful and even considered best practice. They are called filetype plugins in Vim speech.... | 2015/11/11 | [
"https://vi.stackexchange.com/questions/5441",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1963/"
] | As per the title, is it possible to split the `vimrc` file in several sub-files? Keep separate files for groups of settings that concern one ***thing***? This *thing* might be anything, any kind of user-defined group of settings. For example,
**[updated]**
* keep all *Python(-mode)* related settings in `vimrc.python-... | Yes this is possible and useful and even considered best practice. They are called filetype plugins in Vim speech. And Vim even comes with many filetype plugins (as well as indent and syntax files) for several languages.
You need to enable this in your `.vimrc` like this:
```
filetype plugin on
```
then put your sp... |
5,458 | <p>Is it possible to add a sign to be displayed in the signs column whenever the line has a ToDo group (ToDo,FIXME...).</p>
<p>Tweaking my colorscheme I changed the highlight of the Todo group, but would like to have an indicator in the signs column, like Syntastic errors and warnings.</p>
| [
{
"answer_id": 5459,
"author": "saginaw",
"author_id": 4939,
"author_profile": "https://vi.stackexchange.com/users/4939",
"pm_score": 4,
"selected": true,
"text": "<p>Try this function :</p>\n\n<pre><code>function! SignKeyword()\n\n silent! sign undefine todo\n\n sign define todo t... | 2015/11/12 | [
"https://vi.stackexchange.com/questions/5458",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/-1/"
] | Is it possible to add a sign to be displayed in the signs column whenever the line has a ToDo group (ToDo,FIXME...).
Tweaking my colorscheme I changed the highlight of the Todo group, but would like to have an indicator in the signs column, like Syntastic errors and warnings. | Try this function :
```
function! SignKeyword()
silent! sign undefine todo
sign define todo text=>> texthl=Search
g/\v\C(<TODO>|<FIXME>)/execute "sign place 9999 line=" . line('.')
\ . " name=todo buffer=" . bufnr('')
nohlsearch
endfunction
```
Now call the function on the command line :
``... |
5,461 | <p><strong>What I want</strong></p>
<p>I want create a mapping which comments a line into a box, for example</p>
<pre><code>textline
</code></pre>
<p>shall be transformed to</p>
<pre><code>" ##############################################################################
" textline
" #################################... | [
{
"answer_id": 5468,
"author": "saginaw",
"author_id": 4939,
"author_profile": "https://vi.stackexchange.com/users/4939",
"pm_score": 2,
"selected": false,
"text": "<p>This should work :</p>\n\n<pre><code>function! CommentBox()\n\n \" PREPARATIONS\n\n \" prefix is the number we hit... | 2015/11/13 | [
"https://vi.stackexchange.com/questions/5461",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/3282/"
] | **What I want**
I want create a mapping which comments a line into a box, for example
```
textline
```
shall be transformed to
```
" ##############################################################################
" textline
" ##############################################################################
```
Depe... | I created a [plugin](https://github.com/cbaumhardt/vim-commentary-boxed) which does exactly that.
Just plug it in into your `.vimrc`, e.g. using [vim-plug](https://github.com/junegunn/vim-plug):
```
Plug 'cbaumhardt/vim-commentary-boxed'
```
After installing, define a custom mapping in your `.virmc`, e.g. `<leader>... |
5,462 | <p>If I have a couple of lines of vimscript that I want to test before putting in my vimrc, is it possible to visually select, then source them?</p>
<p>I have tried </p>
<ul>
<li>make visual selection <kbd>v</kbd>, then motions to make selection etc, then</li>
<li><code>:'<,'>so</code></li>
</ul>
<p>But vim gi... | [
{
"answer_id": 5463,
"author": "saginaw",
"author_id": 4939,
"author_profile": "https://vi.stackexchange.com/users/4939",
"pm_score": 5,
"selected": true,
"text": "<p>On the command line hit <code><C-u></code> then type <code>@*</code> and enter.</p>\n\n<p><code><C-u></code> ... | 2015/11/13 | [
"https://vi.stackexchange.com/questions/5462",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4603/"
] | If I have a couple of lines of vimscript that I want to test before putting in my vimrc, is it possible to visually select, then source them?
I have tried
* make visual selection `v`, then motions to make selection etc, then
* `:'<,'>so`
But vim gives an error
>
> no range allowed
>
>
>
also
```
:'<,'>w | s... | On the command line hit `<C-u>` then type `@*` and enter.
`<C-u>` will delete the visual range `'<,'>` that has been automatically inserted if some text is visually selected.
`:@*` will execute the content of the `*` register which contains whatever is visually selected at the moment.
Even if the text that is select... |
5,469 | <p>When writing Greek, sigmas at the ends of words should have a different form. Can I do something automatically to replace: μῖσοσ by μῖσος, and so in all such cases?</p>
| [
{
"answer_id": 5483,
"author": "Thomas Baruchel",
"author_id": 5139,
"author_profile": "https://vi.stackexchange.com/users/5139",
"pm_score": 1,
"selected": false,
"text": "<p>Since a final sigma is quickly followed with a space <em>even if a punctuation marks immediately followf it</em>... | 2015/11/13 | [
"https://vi.stackexchange.com/questions/5469",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4505/"
] | When writing Greek, sigmas at the ends of words should have a different form. Can I do something automatically to replace: μῖσοσ by μῖσος, and so in all such cases? | Since a final sigma is quickly followed with a space *even if a punctuation marks immediately followf it* (except for the end-of-line case), you could do this: define the folowwing function (in your `~/.vimrc` file) and remap the *space* key in insert mode to this function.
```
" The function checks whether a final gr... |
5,488 | <p>Today I learned how to fold/unfold in Vim; it's quite handy. </p>
<p>Unexpectedly, when I exit a file and reenter it, the folds I created are gone (unfolded). </p>
<p>In our company's large project there are quite a lot of sticky (legacy) code blocks which are kind of obsolete but indispensable.</p>
<p>I really... | [
{
"answer_id": 5884,
"author": "Sukima",
"author_id": 544,
"author_profile": "https://vi.stackexchange.com/users/544",
"pm_score": 3,
"selected": false,
"text": "<p>I do exactly this for one file I refer to a lot <code>NOTES.otl</code> I performed the following in my <code>.vimrc</code>:... | 2015/11/16 | [
"https://vi.stackexchange.com/questions/5488",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/3085/"
] | Today I learned how to fold/unfold in Vim; it's quite handy.
Unexpectedly, when I exit a file and reenter it, the folds I created are gone (unfolded).
In our company's large project there are quite a lot of sticky (legacy) code blocks which are kind of obsolete but indispensable.
I really need to fold them nearly ... | I do exactly this for one file I refer to a lot `NOTES.otl` I performed the following in my `.vimrc`:
```
" Useful for my Quick Notes feature in my tmuxrc
augroup QuickNotes
au BufWrite,VimLeave NOTES.otl mkview
au BufRead NOTES.otl silent loadview
augroup END
```
What this means is that in your case y... |
5,489 | <p>I'm reworking a section of logic in some C code to avoid a memory leak that looks like this:</p>
<pre><code>switch (result) {
case CASE_1:
return report(...);
case CASE_2:
return report(...);
/*
* More cases follow with the same pattern.
*/
}
</code></pre>
<p>I've used <code>%s/return report/report/</c... | [
{
"answer_id": 5490,
"author": "saginaw",
"author_id": 4939,
"author_profile": "https://vi.stackexchange.com/users/4939",
"pm_score": 4,
"selected": true,
"text": "<p>If I understand your post correctly, you had this snippet of C code :</p>\n\n<pre><code>switch (result) {\ncase CASE_1:\n... | 2015/11/16 | [
"https://vi.stackexchange.com/questions/5489",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/-1/"
] | I'm reworking a section of logic in some C code to avoid a memory leak that looks like this:
```
switch (result) {
case CASE_1:
return report(...);
case CASE_2:
return report(...);
/*
* More cases follow with the same pattern.
*/
}
```
I've used `%s/return report/report/` to remove the `return` statement... | If I understand your post correctly, you had this snippet of C code :
```
switch (result) {
case CASE_1:
return report("...");
case CASE_2:
return report("...");
}
```
And you wanted to transform it to :
```
switch (result) {
case CASE_1:
report("...");
break;
case CASE_2:
report("...");
... |
5,495 | <p>I'm trying to understand how can I use operator with subsequent motion inside a mapping. For example:</p>
<pre><code>nmap /c c{here we pending for a motion}/<C-r>"<CR>
</code></pre>
<p>The map should do the following: </p>
<ol>
<li>Activate <code>c</code> operator and listen for the next motion;</li>
... | [
{
"answer_id": 5496,
"author": "mMontu",
"author_id": 1405,
"author_profile": "https://vi.stackexchange.com/users/1405",
"pm_score": 2,
"selected": false,
"text": "<p>It is easier to implement (and to document) complex mappings by using functions:</p>\n\n<pre><code>function! DoMagic()\n ... | 2015/11/16 | [
"https://vi.stackexchange.com/questions/5495",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/5321/"
] | I'm trying to understand how can I use operator with subsequent motion inside a mapping. For example:
```
nmap /c c{here we pending for a motion}/<C-r>"<CR>
```
The map should do the following:
1. Activate `c` operator and listen for the next motion;
2. Eg, I can type here `t,` to change everything before the next... | vim supports operator-mapping `:h map-operator`.
What you need is an `operatorfunc`, and a mapping. for your needs, the followings codes work. Well it is just an example, you refine further.
```
nmap <silent> /c :set opfunc=SpecialChange<CR>g@
function! SpecialChange(type)
silent exec 'normal! `[v`]d'
s... |
5,501 | <p>Is it possible to programmatically let a function knows its own name?</p>
<p>What I am looking for is something which would allow me to write this code (or something similar):</p>
<pre><code>function! myUtils#TestMe() abort
let l:_self = " a way to get the current function name
echom l:_self
endfunction
</... | [
{
"answer_id": 5503,
"author": "VanLaser",
"author_id": 1800,
"author_profile": "https://vi.stackexchange.com/users/1800",
"pm_score": 5,
"selected": true,
"text": "<p>Yes, there is :) Example:</p>\n\n<pre><code>function! Testing()\n \" this is the droid you're looking for\n echo s... | 2015/11/16 | [
"https://vi.stackexchange.com/questions/5501",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/5328/"
] | Is it possible to programmatically let a function knows its own name?
What I am looking for is something which would allow me to write this code (or something similar):
```
function! myUtils#TestMe() abort
let l:_self = " a way to get the current function name
echom l:_self
endfunction
```
Which, once calle... | Yes, there is :) Example:
```
function! Testing()
" this is the droid you're looking for
echo substitute(expand('<sfile>'), '.*\(\.\.\|\s\)', '', '')
" compare with this (not what you want, just for reference)
echo expand('<sfile>')
endfunction
function! OutsideTesting()
call Testing()
endfunction... |
5,505 | <p>I have this keymap: <code>map <F3> :hi Tab gui=underline guifg=8 ctermbg=8<CR></code> and I know that, I can clear group by <code>:hi clear Tab</code>, but how to map only F3 to do this? I want one key to turn on/off this higlight group, like: <code>map <F3> :set number!<CR></code>.</p>
<p>R... | [
{
"answer_id": 5506,
"author": "saginaw",
"author_id": 4939,
"author_profile": "https://vi.stackexchange.com/users/4939",
"pm_score": 1,
"selected": false,
"text": "<p>I may be wrong but I don't think you can give a decimal number as a value for the <code>guifg</code> attribute (<code>gu... | 2015/11/17 | [
"https://vi.stackexchange.com/questions/5505",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/5335/"
] | I have this keymap: `map <F3> :hi Tab gui=underline guifg=8 ctermbg=8<CR>` and I know that, I can clear group by `:hi clear Tab`, but how to map only F3 to do this? I want one key to turn on/off this higlight group, like: `map <F3> :set number!<CR>`.
Regards. | Here is a different approach, doing it in a single line:
```
nnoremap <expr><silent> <f3> synIDattr(hlID('Tab'),'underline')?':hi clear Tab<cr>':':hi Tab gui=underline guifg=8 ctermbg=8<cr>'
```
This uses expression mappings to check the underline attribute of the Tab highlighting. If there exists one, it will clea... |
5,508 | <p>I'm trying to navigate to next dot in a file using windows version of vim:</p>
<pre><code>f.
</code></pre>
<p>but it doesn't do anything as well as all other similar commands:</p>
<pre><code>F.
d.
D.
</code></pre>
<p>What is correct way to do it?</p>
| [
{
"answer_id": 5513,
"author": "apparat",
"author_id": 5331,
"author_profile": "https://vi.stackexchange.com/users/5331",
"pm_score": 2,
"selected": false,
"text": "<p>The <code>f</code> command only works within the current line. But you can use the sentence motions <code>(</code> \"one... | 2015/11/17 | [
"https://vi.stackexchange.com/questions/5508",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/5341/"
] | I'm trying to navigate to next dot in a file using windows version of vim:
```
f.
```
but it doesn't do anything as well as all other similar commands:
```
F.
d.
D.
```
What is correct way to do it? | You can use the [Clever-F](https://github.com/rhysd/clever-f.vim) or [Vim-Sneak](https://github.com/justinmk/vim-sneak) plugins to make the `f` and `t` motions automatically search over multiple lines, because usually they will only search within the current line. |
5,531 | <p>I remapped my hjkl keys to ijkl, but in netrw, "i" switches view styles.</p>
<p>How to change this? Is it possible to change this?</p>
| [
{
"answer_id": 5532,
"author": "saginaw",
"author_id": 4939,
"author_profile": "https://vi.stackexchange.com/users/4939",
"pm_score": 4,
"selected": true,
"text": "<p>If you want your cursor to move left when pressing <code>i</code> in the built-in file browser netrw, then try adding the... | 2015/11/19 | [
"https://vi.stackexchange.com/questions/5531",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/5365/"
] | I remapped my hjkl keys to ijkl, but in netrw, "i" switches view styles.
How to change this? Is it possible to change this? | If you want your cursor to move left when pressing `i` in the built-in file browser netrw, then try adding the following code in your `$MYVIMRC` file :
```
augroup netrw_mapping
autocmd!
autocmd filetype netrw call NetrwMapping()
augroup END
function! NetrwMapping()
noremap <buffer> i h
endfunction
```
... |
5,533 | <p>I would like to be able to hide certain lines in my buffer from showing up at all (and being able to toggle seeing them). I found <a href="https://vi.stackexchange.com/questions/2280/show-only-matching-lines">similar questions</a>, but they don't solve my problem. I don't want to use folds for this.</p>
<p><strong>... | [
{
"answer_id": 5539,
"author": "saginaw",
"author_id": 4939,
"author_profile": "https://vi.stackexchange.com/users/4939",
"pm_score": 3,
"selected": false,
"text": "<p>I don't know how to achieve exactly what you want, only a part.</p>\n\n<p>You want to hide some text inside <code>~/.vim... | 2015/11/19 | [
"https://vi.stackexchange.com/questions/5533",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/3282/"
] | I would like to be able to hide certain lines in my buffer from showing up at all (and being able to toggle seeing them). I found [similar questions](https://vi.stackexchange.com/questions/2280/show-only-matching-lines), but they don't solve my problem. I don't want to use folds for this.
**What do I want exactly?**
... | I don't know how to achieve exactly what you want, only a part.
You want to hide some text inside `~/.vimrc` (for example).
First we need to know which highlight group handles the text you want to hide.
Add this mapping to your `~/.vimrc` :
```
map <F10> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . ... |
5,534 | <p>I use <a href="https://github.com/haya14busa/incsearch.vim" rel="nofollow">this plugin</a> (incsearch.vim) which changes the search function in vim by highlighting the text dynamically while typing the regex after <code>/</code> or <code>?</code>.</p>
<p>For the plugin to work I had to add these lines in my <code>~... | [
{
"answer_id": 5535,
"author": "saginaw",
"author_id": 4939,
"author_profile": "https://vi.stackexchange.com/users/4939",
"pm_score": 0,
"selected": false,
"text": "<p>I think I found. I tried the other way around the first time, sorry.</p>\n\n<pre><code>map / <Plug>(incsearch-for... | 2015/11/19 | [
"https://vi.stackexchange.com/questions/5534",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4939/"
] | I use [this plugin](https://github.com/haya14busa/incsearch.vim) (incsearch.vim) which changes the search function in vim by highlighting the text dynamically while typing the regex after `/` or `?`.
For the plugin to work I had to add these lines in my `~/.vimrc` :
```
map / <Plug>(incsearch-forward)
map ? <Plug>(... | >
> I would like to modify those mappings, so that the plugin's functions
> are still called but the search begins automatically with \v, the very
> magic mode is enabled and I don't have to escape (, ), {, + etc.
>
>
>
You can achieve that by using your previous mappings, by changing some plugin options. This a... |
5,536 | <p>I am looking for a complete list of the key descriptions commonly used for remapping keys.</p>
| [
{
"answer_id": 5537,
"author": "saginaw",
"author_id": 4939,
"author_profile": "https://vi.stackexchange.com/users/4939",
"pm_score": 4,
"selected": true,
"text": "<pre><code>:help key-notation\n</code></pre>\n\n<p>They are described in the <a href=\"https://vimhelp.appspot.com/intro.txt... | 2015/11/19 | [
"https://vi.stackexchange.com/questions/5536",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/-1/"
] | I am looking for a complete list of the key descriptions commonly used for remapping keys. | ```
:help key-notation
```
They are described in the [help](https://vimhelp.appspot.com/intro.txt.html#key-notation).
```
notation meaning equivalent decimal value(s) ~
-----------------------------------------------------------------------
<Nul> zero CTRL-@ 0 (stored as 10) *<Nul>... |
5,540 | <p>I am currently working on a custom syntax highlighting for vim. I want to highlight lines starting with a space, but only if they contain any letters or numbers.</p>
<p>I could achieve this result with the syn match <code>'^ .*.[a-zA-Z].*'</code>, but I want the highlight to be working only if the previous line doe... | [
{
"answer_id": 5537,
"author": "saginaw",
"author_id": 4939,
"author_profile": "https://vi.stackexchange.com/users/4939",
"pm_score": 4,
"selected": true,
"text": "<pre><code>:help key-notation\n</code></pre>\n\n<p>They are described in the <a href=\"https://vimhelp.appspot.com/intro.txt... | 2015/11/19 | [
"https://vi.stackexchange.com/questions/5540",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/5372/"
] | I am currently working on a custom syntax highlighting for vim. I want to highlight lines starting with a space, but only if they contain any letters or numbers.
I could achieve this result with the syn match `'^ .*.[a-zA-Z].*'`, but I want the highlight to be working only if the previous line does not end with a "=".... | ```
:help key-notation
```
They are described in the [help](https://vimhelp.appspot.com/intro.txt.html#key-notation).
```
notation meaning equivalent decimal value(s) ~
-----------------------------------------------------------------------
<Nul> zero CTRL-@ 0 (stored as 10) *<Nul>... |
5,546 | <p>From <a href="http://vimdoc.sourceforge.net/htmldoc/autocmd.html#%7Bevent%7D" rel="nofollow">the Vim event documentation</a>:</p>
<blockquote>
<p>Vim recognizes the following events. Vim ignores the case of event
names (e.g., you can use "BUFread" or "bufread" instead of "BufRead").</p>
</blockquote>
<p>So in... | [
{
"answer_id": 5713,
"author": "cuonglm",
"author_id": 1892,
"author_profile": "https://vi.stackexchange.com/users/1892",
"pm_score": 1,
"selected": false,
"text": "<p>After checking all the plugins, I found the issue due to the <a href=\"https://sourceware.org/git/gitweb.cgi?p=systemtap... | 2015/11/20 | [
"https://vi.stackexchange.com/questions/5546",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/1892/"
] | From [the Vim event documentation](http://vimdoc.sourceforge.net/htmldoc/autocmd.html#%7Bevent%7D):
>
> Vim recognizes the following events. Vim ignores the case of event
> names (e.g., you can use "BUFread" or "bufread" instead of "BufRead").
>
>
>
So in [my custom\_filetype.vim](https://github.com/Gnouc/dot_co... | I looked into the source and I think I found the problem. If you look in the [help](https://vimhelp.appspot.com/autocmd.txt.html#:au) (`:h :au`) you will see this:
```
:au[tocmd] [group] {event} {pat} [nested] {cmd}
Add {cmd} to the list of commands that Vim will
execute automatically on {event} for a ... |
5,549 | <p>I am looking for a transformation that would change this text:</p>
<pre><code> text
indented
text
double
indented
text
indented
again
</code></pre>
<p>to:</p>
<pre><code>text
indented
text
double
indented
text
... | [
{
"answer_id": 5551,
"author": "saginaw",
"author_id": 4939,
"author_profile": "https://vi.stackexchange.com/users/4939",
"pm_score": 1,
"selected": false,
"text": "<p>The following code add a mapping <code><leader>s</code> that should do what you want on the specific file you prov... | 2015/11/20 | [
"https://vi.stackexchange.com/questions/5549",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/2978/"
] | I am looking for a transformation that would change this text:
```
text
indented
text
double
indented
text
indented
again
```
to:
```
text
indented
text
double
indented
text
indented
again
```
But then ... | Delete the text linewise and then paste with `]p` with your cursor from an empty line.
```
dG]p
```
Here `]p` is doing all the hard work. `]p` will paste the text, but will adjust the indent to the current line.
For more help see:
```
:h ]p
``` |
5,567 | <p>Currently, I use <a href="https://github.com/junegunn/vim-plug" rel="nofollow">vim-plug</a> for managing plugins and <a href="https://github.com/flazz/vim-colorschemes" rel="nofollow">vim-colorschemes</a> for my colorschemes - which doesn't work.</p>
<p><strong>Approach 1:</strong></p>
<p>in my init.vim:</p>
<pr... | [
{
"answer_id": 5665,
"author": "toogley",
"author_id": 2354,
"author_profile": "https://vi.stackexchange.com/users/2354",
"pm_score": 4,
"selected": true,
"text": "<p>Although, i haven't found out what exactly was the problem or how i could solve it in the expected way (just placing colo... | 2015/11/21 | [
"https://vi.stackexchange.com/questions/5567",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/2354/"
] | Currently, I use [vim-plug](https://github.com/junegunn/vim-plug) for managing plugins and [vim-colorschemes](https://github.com/flazz/vim-colorschemes) for my colorschemes - which doesn't work.
**Approach 1:**
in my init.vim:
```
Plug 'flazz/vim-colorschemes'
[...]
syntax on
colorscheme babymate256
set background=d... | Although, i haven't found out what exactly was the problem or how i could solve it in the expected way (just placing colorscheme babymate256 in my config as everyone else does)
**=>** i now use just `autocmd VimEnter * colorscheme babymate256`
(which is not as fine as without an autocmd, but it doesn't disorganize up... |
5,571 | <p><a href="http://vim.wikia.com/wiki/Toggle_auto-indenting_for_code_paste" rel="noreferrer">This</a> wikia page explains how to paste text from a different application into vim when in insert mode. Simply apply the command <code>set paste</code> and things will work as expected. After you are done, just enter command ... | [
{
"answer_id": 5572,
"author": "Christian Brabandt",
"author_id": 71,
"author_profile": "https://vi.stackexchange.com/users/71",
"pm_score": 3,
"selected": true,
"text": "<p>As the <a href=\"https://vimhelp.appspot.com/options.txt.html#%27paste%27\" rel=\"nofollow\">documentation states<... | 2015/11/22 | [
"https://vi.stackexchange.com/questions/5571",
"https://vi.stackexchange.com",
"https://vi.stackexchange.com/users/4562/"
] | [This](http://vim.wikia.com/wiki/Toggle_auto-indenting_for_code_paste) wikia page explains how to paste text from a different application into vim when in insert mode. Simply apply the command `set paste` and things will work as expected. After you are done, just enter command `set nopaste` to go back to the original s... | As the [documentation states](https://vimhelp.appspot.com/options.txt.html#%27paste%27) setting the `paste` option disables many features:
```
When the 'paste' option is switched on (also when it was already on):
- mapping in Insert mode and Command-line mode is disabled
- abbreviation... |